@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | $s3 = sin($bank/2); |
57 | 57 | $c1c2 = $c1*$c2; |
58 | 58 | $s1s2 = $s1*$s2; |
59 | - $w =$c1c2*$c3 - $s1s2*$s3; |
|
60 | - $x =$c1c2*$s3 + $s1s2*$c3; |
|
61 | - $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
62 | - $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
63 | - return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
59 | + $w = $c1c2*$c3 - $s1s2*$s3; |
|
60 | + $x = $c1c2*$s3 + $s1s2*$c3; |
|
61 | + $y = $s1*$c2*$c3 + $c1*$s2*$s3; |
|
62 | + $z = $c1*$s2*$c3 - $s1*$c2*$s3; |
|
63 | + return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w); |
|
64 | 64 | // return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365'); |
65 | 65 | |
66 | 66 | } |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | $min = false; |
82 | 82 | $allhistory = false; |
83 | 83 | $filter['source'] = array(); |
84 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
85 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
86 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
87 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
88 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
89 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
90 | -if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
91 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
92 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
93 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
94 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
84 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
85 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
86 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
87 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
88 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
89 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
90 | +if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING); |
|
91 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
92 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
93 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
94 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
95 | 95 | /* |
96 | 96 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
97 | 97 | $min = true; |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | $from_archive = true; |
139 | 139 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
140 | 140 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
141 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
142 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
143 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
144 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
145 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
146 | - $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter); |
|
141 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
142 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
143 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
144 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
145 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
146 | + $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter); |
|
147 | 147 | } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) { |
148 | 148 | $from_archive = true; |
149 | 149 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
@@ -153,46 +153,46 @@ discard block |
||
153 | 153 | $begindate = $_COOKIE['archive_begin']; |
154 | 154 | $enddate = $_COOKIE['archive_end']; |
155 | 155 | |
156 | - $archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT); |
|
157 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
158 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
156 | + $archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT); |
|
157 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
158 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
159 | 159 | // echo 'Begin : '.$begindate.' - End : '.$enddate."\n"; |
160 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
160 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
161 | 161 | } elseif ($tracker) { |
162 | 162 | $coord = array(); |
163 | 163 | if (isset($_GET['coord']) && $_GET['coord'] != '') { |
164 | - $coord = explode(',',$_GET['coord']); |
|
165 | - if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
|
164 | + $coord = explode(',', $_GET['coord']); |
|
165 | + if (!(filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) |
|
166 | 166 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
167 | 167 | $coord = array(); |
168 | 168 | } |
169 | 169 | } |
170 | - $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord,$filter,true); |
|
170 | + $spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord, $filter, true); |
|
171 | 171 | } elseif ($marine) { |
172 | 172 | $coord = array(); |
173 | 173 | if (isset($_GET['coord']) && $_GET['coord'] != '') { |
174 | - $coord = explode(',',$_GET['coord']); |
|
175 | - if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
|
174 | + $coord = explode(',', $_GET['coord']); |
|
175 | + if (!(filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) |
|
176 | 176 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
177 | 177 | $coord = array(); |
178 | 178 | } |
179 | 179 | } |
180 | - $spotter_array = $MarineLive->getMinLastLiveMarineData($coord,$filter,true); |
|
180 | + $spotter_array = $MarineLive->getMinLastLiveMarineData($coord, $filter, true); |
|
181 | 181 | } else { |
182 | 182 | $coord = array(); |
183 | 183 | if (isset($_GET['coord']) && $_GET['coord'] != '') { |
184 | - $coord = explode(',',$_GET['coord']); |
|
185 | - if (!(filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) |
|
184 | + $coord = explode(',', $_GET['coord']); |
|
185 | + if (!(filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) |
|
186 | 186 | && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0)) { |
187 | 187 | $coord = array(); |
188 | 188 | } |
189 | 189 | } |
190 | - $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,true); |
|
190 | + $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, true); |
|
191 | 191 | } |
192 | 192 | //print_r($spotter_array); |
193 | 193 | if (!empty($spotter_array) && isset($coord)) { |
194 | 194 | if (isset($_GET['archive'])) { |
195 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
195 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
196 | 196 | } elseif ($tracker) { |
197 | 197 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
198 | 198 | } elseif ($marine) { |
@@ -203,15 +203,15 @@ discard block |
||
203 | 203 | if ($flightcnt == '') $flightcnt = 0; |
204 | 204 | } else $flightcnt = 0; |
205 | 205 | |
206 | -$sqltime = round(microtime(true)-$begintime,2); |
|
206 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
207 | 207 | $minitime = time(); |
208 | 208 | $maxitime = 0; |
209 | -$lastupdate = filter_input(INPUT_GET,'update',FILTER_SANITIZE_NUMBER_INT); |
|
209 | +$lastupdate = filter_input(INPUT_GET, 'update', FILTER_SANITIZE_NUMBER_INT); |
|
210 | 210 | $modelsdb = array(); |
211 | 211 | if (file_exists(dirname(__FILE__).'/models/modelsdb')) { |
212 | - if (($handle = fopen(dirname(__FILE__).'/models/modelsdb','r')) !== FALSE) { |
|
213 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
214 | - if (isset($row[1]) ){ |
|
212 | + if (($handle = fopen(dirname(__FILE__).'/models/modelsdb', 'r')) !== FALSE) { |
|
213 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
214 | + if (isset($row[1])) { |
|
215 | 215 | $model = $row[0]; |
216 | 216 | $modelsdb[$model] = $row[1]; |
217 | 217 | } |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | } |
222 | 222 | $modelsdb2 = array(); |
223 | 223 | if (file_exists(dirname(__FILE__).'/models/gltf2/modelsdb')) { |
224 | - if (($handle = fopen(dirname(__FILE__).'/models/gltf2/modelsdb','r')) !== FALSE) { |
|
225 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
226 | - if (isset($row[1]) ){ |
|
224 | + if (($handle = fopen(dirname(__FILE__).'/models/gltf2/modelsdb', 'r')) !== FALSE) { |
|
225 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
226 | + if (isset($row[1])) { |
|
227 | 227 | $model = $row[0]; |
228 | 228 | $modelsdb2[$model] = $row[1]; |
229 | 229 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | if (!empty($spotter_array) && is_array($spotter_array)) |
262 | 262 | { |
263 | 263 | $nblatlong = 0; |
264 | - foreach($spotter_array as $spotter_item) |
|
264 | + foreach ($spotter_array as $spotter_item) |
|
265 | 265 | { |
266 | 266 | $j++; |
267 | 267 | //if (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'airwhere') $heightrelative = 'RELATIVE_TO_GROUND'; |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | $output .= '"lastupdate": "'.$lastupdate.'",'; |
304 | 304 | if (isset($spotter_item['format_source'])) $output .= '"format": "'.$spotter_item['format_source'].'",'; |
305 | 305 | if ($tracker) { |
306 | - $output.= '"type": "tracker"'; |
|
306 | + $output .= '"type": "tracker"'; |
|
307 | 307 | } elseif ($marine) { |
308 | - $output.= '"type": "marine"'; |
|
308 | + $output .= '"type": "marine"'; |
|
309 | 309 | } else { |
310 | 310 | if (isset($globalMap3DLiveries) && $globalMap3DLiveries) { |
311 | 311 | $aircraft_icao = $spotter_item['aircraft_icao']; |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | if (isset($airline_icao)) { |
320 | 320 | $imagefile = $aircraft_icao.'-'.$airline_icao.'.png'; |
321 | 321 | if (file_exists(dirname(__FILE__).'/models/gltf2/liveries/'.$imagefile)) { |
322 | - $output.= '"liveries": "'.$globalURL.'/models/gltf2/liveries/'.$imagefile.'",'; |
|
322 | + $output .= '"liveries": "'.$globalURL.'/models/gltf2/liveries/'.$imagefile.'",'; |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | } |
326 | - if ($ident != '') $output.= '"ident": "'.$ident.'",'; |
|
326 | + if ($ident != '') $output .= '"ident": "'.$ident.'",'; |
|
327 | 327 | } |
328 | - $output.= '"gltf2": %gltf2%,'; |
|
329 | - $output.= '"type": "flight"'; |
|
328 | + $output .= '"gltf2": %gltf2%,'; |
|
329 | + $output .= '"type": "flight"'; |
|
330 | 330 | } |
331 | 331 | $output .= '},'; |
332 | 332 | |
@@ -679,8 +679,8 @@ discard block |
||
679 | 679 | $output .= '},'; |
680 | 680 | } |
681 | 681 | } |
682 | - if (isset($onground) && $onground) $output = str_replace('%onground%','true',$output); |
|
683 | - else $output = str_replace('%onground%','false',$output); |
|
682 | + if (isset($onground) && $onground) $output = str_replace('%onground%', 'true', $output); |
|
683 | + else $output = str_replace('%onground%', 'false', $output); |
|
684 | 684 | |
685 | 685 | // $output .= '"heightReference": "CLAMP_TO_GROUND",'; |
686 | 686 | //$output .= '"heightReference": "'.$heightrelative.'",'; |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | $output .= '"cartographicDegrees": ['; |
696 | 696 | if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
697 | 697 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
698 | - $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
698 | + $output .= '"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
699 | 699 | $output .= $spotter_item['longitude'].', '; |
700 | 700 | $output .= $spotter_item['latitude']; |
701 | 701 | $prevlong = $spotter_item['longitude']; |
@@ -723,8 +723,8 @@ discard block |
||
723 | 723 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
724 | 724 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
725 | 725 | } else { |
726 | - $nblatlong = $nblatlong+1; |
|
727 | - $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
726 | + $nblatlong = $nblatlong + 1; |
|
727 | + $output .= ',"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
728 | 728 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
729 | 729 | if ($spotter_item['ground_speed'] == 0) { |
730 | 730 | $output .= $prevlong.', '; |
@@ -764,17 +764,17 @@ discard block |
||
764 | 764 | } |
765 | 765 | $output .= ']'; |
766 | 766 | if (isset($globalArchive) && $globalArchive === TRUE) { |
767 | - if ((time()-$globalLiveInterval) > $minitime) { |
|
768 | - if (time()-$globalLiveInterval > $maxitime) { |
|
769 | - $output = str_replace('%minitime%',date("c",$maxitime),$output); |
|
767 | + if ((time() - $globalLiveInterval) > $minitime) { |
|
768 | + if (time() - $globalLiveInterval > $maxitime) { |
|
769 | + $output = str_replace('%minitime%', date("c", $maxitime), $output); |
|
770 | 770 | } else { |
771 | - $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output); |
|
771 | + $output = str_replace('%minitime%', date("c", time() - $globalLiveInterval), $output); |
|
772 | 772 | } |
773 | 773 | } |
774 | - else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
775 | -} else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
776 | -$output = str_replace('%maxitime%',date("c",$maxitime),$output); |
|
777 | -if ($gltf2) $output = str_replace('%gltf2%','true',$output); |
|
778 | -else $output = str_replace('%gltf2%','false',$output); |
|
774 | + else $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
775 | +} else $output = str_replace('%minitime%', date("c", $minitime), $output); |
|
776 | +$output = str_replace('%maxitime%', date("c", $maxitime), $output); |
|
777 | +if ($gltf2) $output = str_replace('%gltf2%', 'true', $output); |
|
778 | +else $output = str_replace('%gltf2%', 'false', $output); |
|
779 | 779 | print $output; |
780 | 780 | ?> |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | ?> |
12 | 12 | <div class="sub-menu sub-menu-container"> |
13 | 13 | <ul class="nav nav-pills"> |
14 | - <li><a href="<?php print $globalURL; ?>/owner/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
14 | + <li><a href="<?php print $globalURL; ?>/owner/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
15 | 15 | <li class="dropdown"> |
16 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "owner-statistics-aircraft" || strtolower($current_page) == "owner-statistics-registration" || strtolower($current_page) == "owner-statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
16 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "owner-statistics-aircraft" || strtolower($current_page) == "owner-statistics-registration" || strtolower($current_page) == "owner-statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
17 | 17 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
18 | 18 | </a> |
19 | 19 | <ul class="dropdown-menu" role="menu"> |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | </ul> |
24 | 24 | </li> |
25 | 25 | <li class="dropdown"> |
26 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "owner-statistics-departure-airport" || strtolower($current_page) == "owner-statistics-departure-airport-country" || strtolower($current_page) == "owner-statistics-arrival-airport" || strtolower($current_page) == "owner-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
26 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "owner-statistics-departure-airport" || strtolower($current_page) == "owner-statistics-departure-airport-country" || strtolower($current_page) == "owner-statistics-arrival-airport" || strtolower($current_page) == "owner-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
27 | 27 | <?php echo _("Airport"); ?> <span class="caret"></span> |
28 | 28 | </a> |
29 | 29 | <ul class="dropdown-menu" role="menu"> |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | <li><a href="<?php print $globalURL; ?>/owner/statistics/arrival-airport-country/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
34 | 34 | </ul> |
35 | 35 | </li> |
36 | - <li><a href="<?php print $globalURL; ?>/owner/statistics/route/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
37 | - <li><a href="<?php print $globalURL; ?>/owner/statistics/time/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
36 | + <li><a href="<?php print $globalURL; ?>/owner/statistics/route/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
37 | + <li><a href="<?php print $globalURL; ?>/owner/statistics/time/<?php print $owner; ?><?php if (isset($year) && $year != '') echo '/'.$year; ?><?php if (isset($month) && $month != '') echo '/'.$month; ?>" <?php if (strtolower($current_page) == "owner-statistics-time") { print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li> |
|
38 | 38 | </ul> |
39 | 39 | </div> |
40 | 40 | <?php |
@@ -4,16 +4,16 @@ discard block |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | $Spotter = new Spotter(); |
7 | -if (!isset($_GET['aircraft_manufacturer'])){ |
|
7 | +if (!isset($_GET['aircraft_manufacturer'])) { |
|
8 | 8 | header('Location: '.$globalURL.''); |
9 | 9 | } else { |
10 | 10 | //calculuation for the pagination |
11 | - if(!isset($_GET['limit'])) |
|
11 | + if (!isset($_GET['limit'])) |
|
12 | 12 | { |
13 | 13 | $limit_start = 0; |
14 | 14 | $limit_end = 25; |
15 | 15 | $absolute_difference = 25; |
16 | - } else { |
|
16 | + } else { |
|
17 | 17 | $limit_explode = explode(",", $_GET['limit']); |
18 | 18 | if (isset($limit_explode[1])) { |
19 | 19 | $limit_start = $limit_explode[0]; |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | $limit_previous_1 = $limit_start - $absolute_difference; |
33 | 33 | $limit_previous_2 = $limit_end - $absolute_difference; |
34 | 34 | |
35 | - $manufacturer = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)))); |
|
36 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
35 | + $manufacturer = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING)))); |
|
36 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
37 | 37 | $page_url = $globalURL.'/manufacturer/'.$manufacturer; |
38 | 38 | |
39 | 39 | if ($sort != '') { |
40 | - $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,$limit_start.",".$absolute_difference, $sort); |
|
40 | + $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, $limit_start.",".$absolute_difference, $sort); |
|
41 | 41 | } else { |
42 | - $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,$limit_start.",".$absolute_difference, ''); |
|
42 | + $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, $limit_start.",".$absolute_difference, ''); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | if (!empty($spotter_array)) |
46 | 46 | { |
47 | - $title = sprintf(_("Detailed View for %s"),$manufacturer); |
|
47 | + $title = sprintf(_("Detailed View for %s"), $manufacturer); |
|
48 | 48 | |
49 | 49 | require_once('header.php'); |
50 | 50 | print '<div class="select-item">'; |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | $Stats = new Stats(); |
54 | 54 | $all_manufacturers = $Stats->getAllManufacturers(); |
55 | 55 | if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers(); |
56 | - foreach($all_manufacturers as $all_manufacturer) |
|
56 | + foreach ($all_manufacturers as $all_manufacturer) |
|
57 | 57 | { |
58 | - if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
|
58 | + if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
|
59 | 59 | { |
60 | 60 | print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>'; |
61 | 61 | } else { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | print '</div>'; |
73 | 73 | |
74 | 74 | print '<div class="table column">'; |
75 | - print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."),$manufacturer).'</p>'; |
|
75 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."), $manufacturer).'</p>'; |
|
76 | 76 | |
77 | 77 | include('manufacturer-sub-menu.php'); |
78 | 78 | include('table-output.php'); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | } |
9 | 9 | header('Content-Type: text/javascript'); |
10 | 10 | |
11 | -$tskfile = filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL); |
|
11 | +$tskfile = filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL); |
|
12 | 12 | |
13 | 13 | $spotter_array = $TSK->parse_xml($tskfile); |
14 | 14 | |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | if (!empty($spotter_array)) |
17 | 17 | { |
18 | 18 | $j = 0; |
19 | - foreach($spotter_array['Point'] as $spotter_item) |
|
19 | + foreach ($spotter_array['Point'] as $spotter_item) |
|
20 | 20 | { |
21 | 21 | date_default_timezone_set('UTC'); |
22 | 22 | //waypoint plotting |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $output .= '"geometry": {'; |
54 | 54 | $output .= '"type": "LineString",'; |
55 | 55 | $output .= '"coordinates": ['; |
56 | - foreach($spotter_array['Point'] as $spotter_item) |
|
56 | + foreach ($spotter_array['Point'] as $spotter_item) |
|
57 | 57 | { |
58 | 58 | $output .= '['.$spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude'].'],'; |
59 | 59 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | require_once('../require/settings.php'); |
3 | 3 | require_once('../require/class.Language.php'); |
4 | 4 | |
5 | -setcookie("MapFormat",'2d'); |
|
5 | +setcookie("MapFormat", '2d'); |
|
6 | 6 | |
7 | 7 | if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = ''; |
8 | 8 | // Compressed GeoJson is used if true |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | $lastupd = $_GET['archivespeed']*$archiveupdatetime; |
21 | 21 | if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate']; |
22 | 22 | else $enddate = time(); |
23 | - setcookie("archive_begin",$begindate); |
|
24 | - setcookie("archive_end",$enddate); |
|
25 | - setcookie("archive_update",$lastupd); |
|
26 | - setcookie("archive_speed",$archivespeed); |
|
23 | + setcookie("archive_begin", $begindate); |
|
24 | + setcookie("archive_end", $enddate); |
|
25 | + setcookie("archive_update", $lastupd); |
|
26 | + setcookie("archive_speed", $archivespeed); |
|
27 | 27 | ?> |
28 | 28 | document.cookie = 'archive_begin=<?php print $begindate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'; |
29 | 29 | document.cookie = 'archive_end=<?php print $enddate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'; |
@@ -75,16 +75,16 @@ discard block |
||
75 | 75 | <?php |
76 | 76 | } |
77 | 77 | if (isset($_GET['ident'])) { |
78 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
78 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
79 | 79 | } |
80 | 80 | if (isset($_GET['flightaware_id'])) { |
81 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
81 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
82 | 82 | } |
83 | 83 | if (isset($_GET['latitude'])) { |
84 | - $latitude = filter_input(INPUT_GET,'latitude',FILTER_SANITIZE_STRING); |
|
84 | + $latitude = filter_input(INPUT_GET, 'latitude', FILTER_SANITIZE_STRING); |
|
85 | 85 | } |
86 | 86 | if (isset($_GET['longitude'])) { |
87 | - $longitude = filter_input(INPUT_GET,'longitude',FILTER_SANITIZE_STRING); |
|
87 | + $longitude = filter_input(INPUT_GET, 'longitude', FILTER_SANITIZE_STRING); |
|
88 | 88 | } |
89 | 89 | ?> |
90 | 90 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } else { |
113 | 113 | if ((isset($globalCenterLatitude) && $globalCenterLatitude != '' && isset($globalCenterLongitude) && $globalCenterLongitude != '') || isset($_COOKIE['lastcentercoord'])) { |
114 | 114 | if (isset($_COOKIE['lastcentercoord'])) { |
115 | - $lastcentercoord = explode(',',$_COOKIE['lastcentercoord']); |
|
115 | + $lastcentercoord = explode(',', $_COOKIE['lastcentercoord']); |
|
116 | 116 | $viewcenterlatitude = $lastcentercoord[0]; |
117 | 117 | $viewcenterlongitude = $lastcentercoord[1]; |
118 | 118 | $viewzoom = $lastcentercoord[2]; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | || navigator.userAgent.match(/BlackBerry/i) |
134 | 134 | || navigator.userAgent.match(/Windows Phone/i)) |
135 | 135 | { |
136 | - var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) print $viewzoom-1; elseif (isset($viewzoom)) print $viewzoom; else print '8'; ?>; |
|
136 | + var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) print $viewzoom - 1; elseif (isset($viewzoom)) print $viewzoom; else print '8'; ?>; |
|
137 | 137 | } else { |
138 | 138 | var zoom = <?php if (isset($viewzoom)) print $viewzoom; else print '9'; ?>; |
139 | 139 | } |
@@ -227,19 +227,19 @@ discard block |
||
227 | 227 | map.addLayer(yandexLayer); |
228 | 228 | <?php |
229 | 229 | } elseif ($MapType == 'Bing-Aerial') { |
230 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
230 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap'); |
|
231 | 231 | ?> |
232 | 232 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'}); |
233 | 233 | map.addLayer(bingLayer); |
234 | 234 | <?php |
235 | 235 | } elseif ($MapType == 'Bing-Hybrid') { |
236 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
236 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap'); |
|
237 | 237 | ?> |
238 | 238 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'}); |
239 | 239 | map.addLayer(bingLayer); |
240 | 240 | <?php |
241 | 241 | } elseif ($MapType == 'Bing-Road') { |
242 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
242 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap'); |
|
243 | 243 | ?> |
244 | 244 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'}); |
245 | 245 | map.addLayer(bingLayer); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | |
358 | 358 | function update_tsk() { |
359 | 359 | var bbox = map.getBounds().toBBoxString(); |
360 | - var tskLayerQuery = $.getJSON("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php echo filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL); ?>",function (data) { |
|
360 | + var tskLayerQuery = $.getJSON("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php echo filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL); ?>",function (data) { |
|
361 | 361 | tskLayer = L.geoJson(data,{ |
362 | 362 | onEachFeature: function (feature, layer) { |
363 | 363 | tskPopup(feature, layer); |
@@ -17,62 +17,62 @@ discard block |
||
17 | 17 | * @param Array $filter the filter |
18 | 18 | * @return Array the SQL part |
19 | 19 | */ |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
38 | 38 | if ($flt['airlines'][0] != '') { |
39 | 39 | if (isset($flt['source'])) { |
40 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
41 | 41 | } else { |
42 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
42 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
46 | 46 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
47 | 47 | if (isset($flt['source'])) { |
48 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
48 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
49 | 49 | } else { |
50 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
50 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
54 | 54 | if (isset($flt['source'])) { |
55 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
55 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
56 | 56 | } else { |
57 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
57 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
61 | 61 | if (isset($flt['source'])) { |
62 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
62 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
63 | 63 | } else { |
64 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
64 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
68 | 68 | if (isset($flt['source'])) { |
69 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
69 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
73 | 73 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
74 | 74 | if ($filter['airlines'][0] != '') { |
75 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
75 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
83 | 83 | } |
84 | 84 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
85 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
85 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
86 | 86 | } |
87 | 87 | if (isset($filter['source']) && !empty($filter['source'])) { |
88 | 88 | if (count($filter['source']) == 1) { |
89 | 89 | $filter_query_where .= " AND format_source = '".$filter['source'][0]."'"; |
90 | 90 | } else { |
91 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
91 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
119 | 119 | } |
120 | 120 | } |
121 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
121 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
122 | 122 | } |
123 | 123 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
124 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
124 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
125 | 125 | } |
126 | 126 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
127 | 127 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
128 | 128 | if ($filter_query_where != '') { |
129 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
129 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
130 | 130 | } |
131 | 131 | $filter_query = $filter_query_join.$filter_query_where; |
132 | 132 | return $filter_query; |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | if ($limit != '') |
150 | 150 | { |
151 | 151 | $limit_array = explode(',', $limit); |
152 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
153 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
152 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
153 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
154 | 154 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
155 | 155 | { |
156 | 156 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | } else { |
175 | 175 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
176 | 176 | } |
177 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
177 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
178 | 178 | |
179 | 179 | return $spotter_array; |
180 | 180 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | { |
190 | 190 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
191 | 191 | date_default_timezone_set('UTC'); |
192 | - $filter_query = $this->getFilter($filter,true,true); |
|
192 | + $filter_query = $this->getFilter($filter, true, true); |
|
193 | 193 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
194 | 194 | if ($globalDBdriver == 'mysql') { |
195 | 195 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $this->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | echo $e->getMessage(); |
217 | 217 | die; |
218 | 218 | } |
@@ -226,19 +226,19 @@ discard block |
||
226 | 226 | * @return Array the spotter information |
227 | 227 | * |
228 | 228 | */ |
229 | - public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false) |
|
229 | + public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = false) |
|
230 | 230 | { |
231 | 231 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
232 | 232 | date_default_timezone_set('UTC'); |
233 | 233 | $usecoord = false; |
234 | 234 | if (is_array($coord) && !empty($coord)) { |
235 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
236 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
237 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
238 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
235 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
236 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
237 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
238 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
239 | 239 | $usecoord = true; |
240 | 240 | } |
241 | - $filter_query = $this->getFilter($filter,true,true); |
|
241 | + $filter_query = $this->getFilter($filter, true, true); |
|
242 | 242 | |
243 | 243 | if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
244 | 244 | if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | try { |
300 | 300 | $sth = $this->db->prepare($query); |
301 | 301 | $sth->execute(); |
302 | - } catch(PDOException $e) { |
|
302 | + } catch (PDOException $e) { |
|
303 | 303 | echo $e->getMessage(); |
304 | 304 | die; |
305 | 305 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | public function getLiveSpotterCount($filter = array()) |
317 | 317 | { |
318 | 318 | global $globalDBdriver, $globalLiveInterval; |
319 | - $filter_query = $this->getFilter($filter,true,true); |
|
319 | + $filter_query = $this->getFilter($filter, true, true); |
|
320 | 320 | |
321 | 321 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
322 | 322 | if ($globalDBdriver == 'mysql') { |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | try { |
330 | 330 | $sth = $this->db->prepare($query); |
331 | 331 | $sth->execute(); |
332 | - } catch(PDOException $e) { |
|
332 | + } catch (PDOException $e) { |
|
333 | 333 | echo $e->getMessage(); |
334 | 334 | die; |
335 | 335 | } |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | $filter_query = $this->getFilter($filter); |
353 | 353 | |
354 | 354 | if (is_array($coord)) { |
355 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
356 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
357 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
358 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
355 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
356 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
357 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
358 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
359 | 359 | } else return array(); |
360 | 360 | if ($globalDBdriver == 'mysql') { |
361 | 361 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -378,23 +378,23 @@ discard block |
||
378 | 378 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
379 | 379 | $Spotter = new Spotter($this->db); |
380 | 380 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
381 | - $filter_query = $this->getFilter($filter,true,true); |
|
381 | + $filter_query = $this->getFilter($filter, true, true); |
|
382 | 382 | |
383 | 383 | if (is_array($coord)) { |
384 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
385 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
386 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
387 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
384 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
385 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
386 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
387 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
388 | 388 | } else return array(); |
389 | 389 | if ($globalDBdriver == 'mysql') { |
390 | 390 | if (isset($globalArchive) && $globalArchive === TRUE) { |
391 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
391 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
392 | 392 | FROM spotter_live |
393 | 393 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
394 | 394 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
395 | 395 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0'; |
396 | 396 | } else { |
397 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
397 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
398 | 398 | FROM spotter_live |
399 | 399 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
400 | 400 | FROM spotter_live l |
@@ -406,14 +406,14 @@ discard block |
||
406 | 406 | } |
407 | 407 | } else { |
408 | 408 | if (isset($globalArchive) && $globalArchive === TRUE) { |
409 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
409 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
410 | 410 | FROM spotter_live |
411 | 411 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
412 | 412 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
413 | 413 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
414 | 414 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
415 | 415 | } else { |
416 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
416 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
417 | 417 | FROM spotter_live |
418 | 418 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
419 | 419 | FROM spotter_live l |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | try { |
429 | 429 | $sth = $this->db->prepare($query); |
430 | 430 | $sth->execute(); |
431 | - } catch(PDOException $e) { |
|
431 | + } catch (PDOException $e) { |
|
432 | 432 | echo $e->getMessage(); |
433 | 433 | die; |
434 | 434 | } |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | if ($interval == '1m') |
478 | 478 | { |
479 | 479 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
480 | - } else if ($interval == '15m'){ |
|
480 | + } else if ($interval == '15m') { |
|
481 | 481 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
482 | 482 | } |
483 | 483 | } |
@@ -485,14 +485,14 @@ discard block |
||
485 | 485 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
486 | 486 | } |
487 | 487 | |
488 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
488 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
489 | 489 | WHERE spotter_live.latitude <> '' |
490 | 490 | AND spotter_live.longitude <> '' |
491 | 491 | ".$additional_query." |
492 | 492 | HAVING distance < :radius |
493 | 493 | ORDER BY distance"; |
494 | 494 | |
495 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
495 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
496 | 496 | |
497 | 497 | return $spotter_array; |
498 | 498 | } |
@@ -510,9 +510,9 @@ discard block |
||
510 | 510 | date_default_timezone_set('UTC'); |
511 | 511 | |
512 | 512 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
513 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
513 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
514 | 514 | |
515 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
515 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
516 | 516 | |
517 | 517 | return $spotter_array; |
518 | 518 | } |
@@ -523,16 +523,16 @@ discard block |
||
523 | 523 | * @return Array the spotter information |
524 | 524 | * |
525 | 525 | */ |
526 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
526 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
527 | 527 | { |
528 | 528 | $Spotter = new Spotter($this->db); |
529 | 529 | date_default_timezone_set('UTC'); |
530 | 530 | |
531 | 531 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
532 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
532 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
533 | 533 | |
534 | - $date = date('c',$date); |
|
535 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
534 | + $date = date('c', $date); |
|
535 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
536 | 536 | |
537 | 537 | return $spotter_array; |
538 | 538 | } |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | $Spotter = new Spotter($this->db); |
549 | 549 | date_default_timezone_set('UTC'); |
550 | 550 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
551 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
552 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
551 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
552 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
553 | 553 | return $spotter_array; |
554 | 554 | } |
555 | 555 | |
@@ -559,15 +559,15 @@ discard block |
||
559 | 559 | * @return Array the spotter information |
560 | 560 | * |
561 | 561 | */ |
562 | - public function getDateLiveSpotterDataById($id,$date) |
|
562 | + public function getDateLiveSpotterDataById($id, $date) |
|
563 | 563 | { |
564 | 564 | $Spotter = new Spotter($this->db); |
565 | 565 | date_default_timezone_set('UTC'); |
566 | 566 | |
567 | 567 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
568 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
569 | - $date = date('c',$date); |
|
570 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
568 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
569 | + $date = date('c', $date); |
|
570 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
571 | 571 | return $spotter_array; |
572 | 572 | } |
573 | 573 | |
@@ -583,13 +583,13 @@ discard block |
||
583 | 583 | date_default_timezone_set('UTC'); |
584 | 584 | |
585 | 585 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
586 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
586 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
587 | 587 | |
588 | 588 | try { |
589 | 589 | |
590 | 590 | $sth = $this->db->prepare($query); |
591 | 591 | $sth->execute(array(':ident' => $ident)); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | echo $e->getMessage(); |
594 | 594 | die; |
595 | 595 | } |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | * @return Array the spotter information |
605 | 605 | * |
606 | 606 | */ |
607 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
607 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
608 | 608 | { |
609 | 609 | global $globalDBdriver, $globalLiveInterval; |
610 | 610 | date_default_timezone_set('UTC'); |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | try { |
624 | 624 | $sth = $this->db->prepare($query); |
625 | 625 | $sth->execute(array(':id' => $id)); |
626 | - } catch(PDOException $e) { |
|
626 | + } catch (PDOException $e) { |
|
627 | 627 | echo $e->getMessage(); |
628 | 628 | die; |
629 | 629 | } |
@@ -641,12 +641,12 @@ discard block |
||
641 | 641 | { |
642 | 642 | date_default_timezone_set('UTC'); |
643 | 643 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
644 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
644 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
645 | 645 | try { |
646 | 646 | |
647 | 647 | $sth = $this->db->prepare($query); |
648 | 648 | $sth->execute(array(':ident' => $ident)); |
649 | - } catch(PDOException $e) { |
|
649 | + } catch (PDOException $e) { |
|
650 | 650 | echo $e->getMessage(); |
651 | 651 | die; |
652 | 652 | } |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | |
677 | 677 | $sth = $this->db->prepare($query); |
678 | 678 | $sth->execute(); |
679 | - } catch(PDOException $e) { |
|
679 | + } catch (PDOException $e) { |
|
680 | 680 | return "error"; |
681 | 681 | } |
682 | 682 | |
@@ -699,14 +699,14 @@ discard block |
||
699 | 699 | |
700 | 700 | $sth = $this->db->prepare($query); |
701 | 701 | $sth->execute(); |
702 | - } catch(PDOException $e) { |
|
702 | + } catch (PDOException $e) { |
|
703 | 703 | return "error"; |
704 | 704 | } |
705 | 705 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
706 | 706 | $i = 0; |
707 | - $j =0; |
|
707 | + $j = 0; |
|
708 | 708 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
709 | - foreach($all as $row) |
|
709 | + foreach ($all as $row) |
|
710 | 710 | { |
711 | 711 | $i++; |
712 | 712 | $j++; |
@@ -714,9 +714,9 @@ discard block |
||
714 | 714 | if ($globalDebug) echo "."; |
715 | 715 | try { |
716 | 716 | |
717 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
717 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
718 | 718 | $sth->execute(); |
719 | - } catch(PDOException $e) { |
|
719 | + } catch (PDOException $e) { |
|
720 | 720 | return "error"; |
721 | 721 | } |
722 | 722 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -727,9 +727,9 @@ discard block |
||
727 | 727 | if ($i > 0) { |
728 | 728 | try { |
729 | 729 | |
730 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
730 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
731 | 731 | $sth->execute(); |
732 | - } catch(PDOException $e) { |
|
732 | + } catch (PDOException $e) { |
|
733 | 733 | return "error"; |
734 | 734 | } |
735 | 735 | } |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | |
743 | 743 | $sth = $this->db->prepare($query); |
744 | 744 | $sth->execute(); |
745 | - } catch(PDOException $e) { |
|
745 | + } catch (PDOException $e) { |
|
746 | 746 | return "error"; |
747 | 747 | } |
748 | 748 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -790,13 +790,13 @@ discard block |
||
790 | 790 | public function deleteLiveSpotterDataByIdent($ident) |
791 | 791 | { |
792 | 792 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
793 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
793 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
794 | 794 | |
795 | 795 | try { |
796 | 796 | |
797 | 797 | $sth = $this->db->prepare($query); |
798 | 798 | $sth->execute(array(':ident' => $ident)); |
799 | - } catch(PDOException $e) { |
|
799 | + } catch (PDOException $e) { |
|
800 | 800 | return "error"; |
801 | 801 | } |
802 | 802 | |
@@ -812,13 +812,13 @@ discard block |
||
812 | 812 | public function deleteLiveSpotterDataById($id) |
813 | 813 | { |
814 | 814 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
815 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
815 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
816 | 816 | |
817 | 817 | try { |
818 | 818 | |
819 | 819 | $sth = $this->db->prepare($query); |
820 | 820 | $sth->execute(array(':id' => $id)); |
821 | - } catch(PDOException $e) { |
|
821 | + } catch (PDOException $e) { |
|
822 | 822 | return "error"; |
823 | 823 | } |
824 | 824 | |
@@ -836,13 +836,13 @@ discard block |
||
836 | 836 | { |
837 | 837 | global $globalDBdriver, $globalTimezone; |
838 | 838 | if ($globalDBdriver == 'mysql') { |
839 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
839 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
840 | 840 | WHERE spotter_live.ident = :ident |
841 | 841 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
842 | 842 | AND spotter_live.date < UTC_TIMESTAMP()'; |
843 | 843 | $query_data = array(':ident' => $ident); |
844 | 844 | } else { |
845 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
845 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
846 | 846 | WHERE spotter_live.ident = :ident |
847 | 847 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
848 | 848 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -851,8 +851,8 @@ discard block |
||
851 | 851 | |
852 | 852 | $sth = $this->db->prepare($query); |
853 | 853 | $sth->execute($query_data); |
854 | - $ident_result=''; |
|
855 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
854 | + $ident_result = ''; |
|
855 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
856 | 856 | { |
857 | 857 | $ident_result = $row['ident']; |
858 | 858 | } |
@@ -869,13 +869,13 @@ discard block |
||
869 | 869 | { |
870 | 870 | global $globalDBdriver, $globalTimezone; |
871 | 871 | if ($globalDBdriver == 'mysql') { |
872 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
872 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
873 | 873 | WHERE spotter_live.ident = :ident |
874 | 874 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; |
875 | 875 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
876 | 876 | $query_data = array(':ident' => $ident); |
877 | 877 | } else { |
878 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
878 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
879 | 879 | WHERE spotter_live.ident = :ident |
880 | 880 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '20 MINUTES'"; |
881 | 881 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -884,8 +884,8 @@ discard block |
||
884 | 884 | |
885 | 885 | $sth = $this->db->prepare($query); |
886 | 886 | $sth->execute($query_data); |
887 | - $ident_result=''; |
|
888 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
887 | + $ident_result = ''; |
|
888 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
889 | 889 | { |
890 | 890 | $ident_result = $row['flightaware_id']; |
891 | 891 | } |
@@ -902,13 +902,13 @@ discard block |
||
902 | 902 | { |
903 | 903 | global $globalDBdriver, $globalTimezone; |
904 | 904 | if ($globalDBdriver == 'mysql') { |
905 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
905 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
906 | 906 | WHERE spotter_live.flightaware_id = :id |
907 | 907 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
908 | 908 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
909 | 909 | $query_data = array(':id' => $id); |
910 | 910 | } else { |
911 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
911 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
912 | 912 | WHERE spotter_live.flightaware_id = :id |
913 | 913 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
914 | 914 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -917,8 +917,8 @@ discard block |
||
917 | 917 | |
918 | 918 | $sth = $this->db->prepare($query); |
919 | 919 | $sth->execute($query_data); |
920 | - $ident_result=''; |
|
921 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
920 | + $ident_result = ''; |
|
921 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
922 | 922 | { |
923 | 923 | $ident_result = $row['flightaware_id']; |
924 | 924 | } |
@@ -935,13 +935,13 @@ discard block |
||
935 | 935 | { |
936 | 936 | global $globalDBdriver, $globalTimezone; |
937 | 937 | if ($globalDBdriver == 'mysql') { |
938 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
938 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
939 | 939 | WHERE spotter_live.ModeS = :modes |
940 | 940 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; |
941 | 941 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
942 | 942 | $query_data = array(':modes' => $modes); |
943 | 943 | } else { |
944 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
944 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
945 | 945 | WHERE spotter_live.ModeS = :modes |
946 | 946 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 MINUTE'"; |
947 | 947 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -950,8 +950,8 @@ discard block |
||
950 | 950 | |
951 | 951 | $sth = $this->db->prepare($query); |
952 | 952 | $sth->execute($query_data); |
953 | - $ident_result=''; |
|
954 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
953 | + $ident_result = ''; |
|
954 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
955 | 955 | { |
956 | 956 | //$ident_result = $row['spotter_live_id']; |
957 | 957 | $ident_result = $row['flightaware_id']; |
@@ -976,8 +976,8 @@ discard block |
||
976 | 976 | return array(); |
977 | 977 | } else { |
978 | 978 | $q_array = explode(" ", $q); |
979 | - foreach ($q_array as $q_item){ |
|
980 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
979 | + foreach ($q_array as $q_item) { |
|
980 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
981 | 981 | $additional_query .= " AND ("; |
982 | 982 | $additional_query .= "(spotter_live.aircraft_icao like '%".$q_item."%') OR "; |
983 | 983 | $additional_query .= "(spotter_live.aircraft_name like '%".$q_item."%') OR "; |
@@ -992,11 +992,11 @@ discard block |
||
992 | 992 | } |
993 | 993 | } |
994 | 994 | if ($globalDBdriver == 'mysql') { |
995 | - $query = "SELECT spotter_live.* FROM spotter_live |
|
995 | + $query = "SELECT spotter_live.* FROM spotter_live |
|
996 | 996 | WHERE spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
997 | 997 | AND spotter_live.date < UTC_TIMESTAMP()"; |
998 | 998 | } else { |
999 | - $query = "SELECT spotter_live.* FROM spotter_live |
|
999 | + $query = "SELECT spotter_live.* FROM spotter_live |
|
1000 | 1000 | WHERE spotter_live.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
1001 | 1001 | AND spotter_live.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
1002 | 1002 | } |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | * @return String success or false |
1017 | 1017 | * |
1018 | 1018 | */ |
1019 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
1019 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
1020 | 1020 | { |
1021 | 1021 | global $globalURL, $globalArchive, $globalDebug; |
1022 | 1022 | $Common = new Common(); |
@@ -1116,27 +1116,27 @@ discard block |
||
1116 | 1116 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
1117 | 1117 | |
1118 | 1118 | |
1119 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
1120 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1121 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
1122 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
1123 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
1124 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1125 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1126 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
1127 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1128 | - $altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1129 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
1130 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1131 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
1132 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
1133 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
1134 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
1135 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
1136 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
1137 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
1138 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
1139 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
1119 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
1120 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1121 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
1122 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
1123 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
1124 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1125 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1126 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
1127 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1128 | + $altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1129 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
1130 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1131 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
1132 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
1133 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
1134 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
1135 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
1136 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
1137 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
1138 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
1139 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
1140 | 1140 | |
1141 | 1141 | $airline_name = ''; |
1142 | 1142 | $airline_icao = ''; |
@@ -1158,10 +1158,10 @@ discard block |
||
1158 | 1158 | $arrival_airport_country = ''; |
1159 | 1159 | |
1160 | 1160 | |
1161 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1162 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1163 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1164 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1161 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
1162 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
1163 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
1164 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1165 | 1165 | |
1166 | 1166 | $query = ''; |
1167 | 1167 | if ($globalArchive) { |
@@ -1172,19 +1172,19 @@ discard block |
||
1172 | 1172 | $query .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) |
1173 | 1173 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)'; |
1174 | 1174 | |
1175 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real); |
|
1175 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real); |
|
1176 | 1176 | try { |
1177 | 1177 | |
1178 | 1178 | $sth = $this->db->prepare($query); |
1179 | 1179 | $sth->execute($query_values); |
1180 | 1180 | $sth->closeCursor(); |
1181 | - } catch(PDOException $e) { |
|
1181 | + } catch (PDOException $e) { |
|
1182 | 1182 | return "error : ".$e->getMessage(); |
1183 | 1183 | } |
1184 | 1184 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1185 | 1185 | if ($globalDebug) echo '(Add to SBS archive : '; |
1186 | 1186 | $SpotterArchive = new SpotterArchive($this->db); |
1187 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1187 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
1188 | 1188 | if ($globalDebug) echo $result.')'; |
1189 | 1189 | } elseif ($globalDebug && $putinarchive !== true) { |
1190 | 1190 | echo '(Not adding to archive)'; |
@@ -1197,7 +1197,7 @@ discard block |
||
1197 | 1197 | |
1198 | 1198 | public function getOrderBy() |
1199 | 1199 | { |
1200 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
1200 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
1201 | 1201 | return $orderby; |
1202 | 1202 | } |
1203 | 1203 |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
372 | - var tsk_geojson = Cesium.loadJson("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php print filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL); ?>"); |
|
372 | + var tsk_geojson = Cesium.loadJson("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php print filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL); ?>"); |
|
373 | 373 | tsk_geojson.then(function(geojsondata) { |
374 | 374 | tsk = new Cesium.CustomDataSource('tsk'); |
375 | 375 | for (var i =0;i < geojsondata.features.length; i++) { |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | <?php |
457 | 457 | if (isset($_COOKIE['lastcentercoord']) || (isset($globalCenterLatitude) && isset($globalCenterLongitude) && $globalCenterLatitude != '' && $globalCenterLongitude != '')) { |
458 | 458 | if (isset($_COOKIE['lastcentercoord'])) { |
459 | - $lastcentercoord = explode(',',$_COOKIE['lastcentercoord']); |
|
459 | + $lastcentercoord = explode(',', $_COOKIE['lastcentercoord']); |
|
460 | 460 | if (!isset($lastcentercoord[3])) $zoom = $lastcentercoord[2]*1000000.0; |
461 | 461 | else $zoom = $lastcentercoord[3]; |
462 | 462 | $viewcenterlatitude = $lastcentercoord[0]; |
@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | * @param String $date get data for a date |
29 | 29 | * @return Array Return Accidents data in array |
30 | 30 | */ |
31 | - public function getAccidentData($limit = '',$type = '',$date = '') { |
|
31 | + public function getAccidentData($limit = '', $type = '', $date = '') { |
|
32 | 32 | global $globalURL, $globalDBdriver; |
33 | 33 | $Image = new Image($this->db); |
34 | 34 | $Spotter = new Spotter($this->db); |
35 | 35 | $Translation = new Translation($this->db); |
36 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
36 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
37 | 37 | date_default_timezone_set('UTC'); |
38 | 38 | $result = array(); |
39 | 39 | $limit_query = ''; |
40 | 40 | if ($limit != "") |
41 | 41 | { |
42 | 42 | $limit_array = explode(",", $limit); |
43 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
44 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
43 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
44 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
45 | 45 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
46 | 46 | { |
47 | 47 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -50,29 +50,29 @@ discard block |
||
50 | 50 | |
51 | 51 | if ($type != '') { |
52 | 52 | if ($date != '') { |
53 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
53 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
54 | 54 | $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; |
55 | 55 | //$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; |
56 | - $query_values = array(':type' => $type,':date' => $date); |
|
57 | - } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) { |
|
56 | + $query_values = array(':type' => $type, ':date' => $date); |
|
57 | + } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) { |
|
58 | 58 | $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; |
59 | - $query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
60 | - } elseif (preg_match("/^[0-9]{4}$/",$date)) { |
|
59 | + $query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
60 | + } elseif (preg_match("/^[0-9]{4}$/", $date)) { |
|
61 | 61 | if ($globalDBdriver == 'mysql') { |
62 | 62 | $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; |
63 | 63 | } else { |
64 | 64 | $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; |
65 | 65 | } |
66 | - $query_values = array(':type' => $type,':date' => $date); |
|
66 | + $query_values = array(':type' => $type, ':date' => $date); |
|
67 | 67 | } else { |
68 | 68 | $date = $date.'%'; |
69 | 69 | if ($globalDBdriver == 'mysql') { |
70 | 70 | $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; |
71 | - $query_values = array(':type' => $type,':date' => $date); |
|
71 | + $query_values = array(':type' => $type, ':date' => $date); |
|
72 | 72 | } else { |
73 | 73 | $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; |
74 | 74 | //$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; |
75 | - $query_values = array(':type' => $type,':date' => $date); |
|
75 | + $query_values = array(':type' => $type, ':date' => $date); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | } else { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | } else { |
84 | 84 | if ($date != '') { |
85 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
85 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
86 | 86 | $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; |
87 | 87 | //$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; |
88 | 88 | } else { |
@@ -100,17 +100,17 @@ discard block |
||
100 | 100 | try { |
101 | 101 | $sth = $this->db->prepare($query); |
102 | 102 | $sth->execute($query_values); |
103 | - } catch(PDOException $e) { |
|
103 | + } catch (PDOException $e) { |
|
104 | 104 | echo "error : ".$e->getMessage(); |
105 | 105 | } |
106 | 106 | $i = 0; |
107 | 107 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
108 | - if (preg_match('/^[\w\-]+$/',$row['registration'])) { |
|
108 | + if (preg_match('/^[\w\-]+$/', $row['registration'])) { |
|
109 | 109 | $data = array(); |
110 | 110 | if ($row['registration'] != '') { |
111 | 111 | $image_array = $Image->getSpotterImage($row['registration']); |
112 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
113 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
112 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
113 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
114 | 114 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
115 | 115 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
116 | 116 | if (!empty($aircraft_info)) { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $data['aircraft_name'] = $aircraft_info[0]['type']; |
119 | 119 | $data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; |
120 | 120 | } else { |
121 | - $data = array_merge($data,array('aircraft_type' => 'NA')); |
|
121 | + $data = array_merge($data, array('aircraft_type' => 'NA')); |
|
122 | 122 | } |
123 | 123 | $owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); |
124 | 124 | if (!empty($owner_data)) { |
@@ -126,18 +126,18 @@ discard block |
||
126 | 126 | $data['aircraft_base'] = $owner_data['base']; |
127 | 127 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
128 | 128 | } |
129 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
129 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
130 | 130 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
131 | 131 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
132 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
|
132 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); |
|
133 | 133 | if (isset($identicao[0])) { |
134 | - if (substr($row['ident'],0,2) == 'AF') { |
|
135 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
136 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
137 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
138 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
134 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
135 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
136 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
137 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
138 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
139 | 139 | } else $icao = $row['ident']; |
140 | - $icao = $Translation->checkTranslation($icao,false); |
|
140 | + $icao = $Translation->checkTranslation($icao, false); |
|
141 | 141 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
142 | 142 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
143 | 143 | //echo 'Check airline info... for '.$row['airline_name'].' '; |
@@ -146,16 +146,16 @@ discard block |
||
146 | 146 | if (!empty($airline_info)) { |
147 | 147 | //echo 'data found !'."\n"; |
148 | 148 | //print_r($airline_info); |
149 | - $data = array_merge($data,$airline_info); |
|
149 | + $data = array_merge($data, $airline_info); |
|
150 | 150 | } |
151 | 151 | //else echo 'No data...'."\n"; |
152 | 152 | } |
153 | - $data = array_merge($row,$data); |
|
153 | + $data = array_merge($row, $data); |
|
154 | 154 | if ($data['ident'] == null) $data['ident'] = $icao; |
155 | 155 | if ($data['title'] == null) { |
156 | 156 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
157 | 157 | } else $data['message'] = strtolower($data['title']); |
158 | - $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
|
158 | + $ids = $Spotter->getAllIDByRegistration($data['registration'], true); |
|
159 | 159 | $date = $data['date']; |
160 | 160 | if (isset($ids[$date])) { |
161 | 161 | $data['spotted'] = TRUE; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | try { |
188 | 188 | $sth = $this->db->prepare($query); |
189 | 189 | $sth->execute(); |
190 | - } catch(PDOException $e) { |
|
190 | + } catch (PDOException $e) { |
|
191 | 191 | echo "Error : ".$e->getMessage(); |
192 | 192 | } |
193 | 193 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | try { |
208 | 208 | $sth = $this->db->prepare($query); |
209 | 209 | $sth->execute(); |
210 | - } catch(PDOException $e) { |
|
210 | + } catch (PDOException $e) { |
|
211 | 211 | echo "Error : ".$e->getMessage(); |
212 | 212 | } |
213 | 213 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -222,15 +222,15 @@ discard block |
||
222 | 222 | if ($globalDebug) echo 'Import '.$file."\n"; |
223 | 223 | $result = array(); |
224 | 224 | if (file_exists($file)) { |
225 | - if (($handle = fopen($file,'r')) !== FALSE) { |
|
226 | - while (($data = fgetcsv($handle,2000,",")) !== FALSE) { |
|
225 | + if (($handle = fopen($file, 'r')) !== FALSE) { |
|
226 | + while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { |
|
227 | 227 | if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { |
228 | - $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'); |
|
228 | + $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'); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | fclose($handle); |
232 | 232 | } |
233 | - if (!empty($result)) $this->add($result,true); |
|
233 | + if (!empty($result)) $this->add($result, true); |
|
234 | 234 | elseif ($globalDebug) echo 'Nothing to import'; |
235 | 235 | } |
236 | 236 | } |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | $all_md5_new = array(); |
247 | 247 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
248 | 248 | if ($this->check_accidents_nb() > 0) { |
249 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
250 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
249 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
250 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
251 | 251 | if (isset($data[1])) { |
252 | 252 | $year = $data[0]; |
253 | 253 | $all_md5[$year] = $data[1]; |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | } |
258 | 258 | } |
259 | 259 | } |
260 | - $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
260 | + $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
261 | 261 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
262 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
263 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
262 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
263 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
264 | 264 | if (isset($data[1])) { |
265 | 265 | $year = $data[0]; |
266 | 266 | $all_md5_new[$year] = $data[1]; |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | fclose($handle); |
270 | 270 | } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
271 | 271 | } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
272 | - $result = $Common->arr_diff($all_md5_new,$all_md5); |
|
272 | + $result = $Common->arr_diff($all_md5_new, $all_md5); |
|
273 | 273 | if (empty($result) && $globalDebug) echo 'Nothing to update'; |
274 | 274 | foreach ($result as $file => $md5) { |
275 | - $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
|
275 | + $Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); |
|
276 | 276 | if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
277 | 277 | elseif ($globalDebug) echo 'Download '.$file.' failed'; |
278 | 278 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * Add data to DB |
283 | 283 | * @param Array $crash An array with accidents/incidents data |
284 | 284 | */ |
285 | - public function add($crash,$new = false) { |
|
285 | + public function add($crash, $new = false) { |
|
286 | 286 | global $globalTransaction, $globalDebug; |
287 | 287 | require_once('class.Connection.php'); |
288 | 288 | require_once('class.Image.php'); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | $sthd->execute(array(':source' => $crash[0]['source'])); |
299 | 299 | } |
300 | 300 | if ($globalTransaction) $Connection->db->beginTransaction(); |
301 | - $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); |
|
301 | + $initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null); |
|
302 | 302 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
303 | 303 | $sth_check = $Connection->db->prepare($query_check); |
304 | 304 | $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)'; |
@@ -311,15 +311,15 @@ discard block |
||
311 | 311 | $cr = array_map(function($value) { |
312 | 312 | return $value === "" ? NULL : $value; |
313 | 313 | }, $cr); |
314 | - if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
|
315 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
316 | - $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
|
314 | + if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) { |
|
315 | + if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
316 | + $query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); |
|
317 | 317 | $sth_check->execute($query_check_values); |
318 | 318 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
319 | 319 | if ($result_check['nb'] == 0) { |
320 | - $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']); |
|
320 | + $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']); |
|
321 | 321 | $sth->execute($query_values); |
322 | - if ($cr['date'] > time()-(30*86400)) { |
|
322 | + if ($cr['date'] > time() - (30*86400)) { |
|
323 | 323 | $imgchk = $Image->getSpotterImage($cr['registration']); |
324 | 324 | if (empty($imgchk)) { |
325 | 325 | if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
@@ -329,16 +329,16 @@ discard block |
||
329 | 329 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
330 | 330 | } |
331 | 331 | if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
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 | } |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | * @param Array $headers header to submit with the form |
15 | 15 | * @return String the result |
16 | 16 | */ |
17 | - public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false) { |
|
17 | + public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '', $sizelimit = false, $async = false) { |
|
18 | 18 | global $globalProxy, $globalForceIPv4; |
19 | 19 | $ch = curl_init(); |
20 | 20 | curl_setopt($ch, CURLOPT_URL, $url); |
21 | 21 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
22 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
22 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
23 | 23 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
24 | 24 | } |
25 | 25 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
30 | 30 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
31 | 31 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
32 | - curl_setopt($ch,CURLOPT_ENCODING , "gzip"); |
|
32 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
33 | 33 | //curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
34 | 34 | // curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0'); |
35 | 35 | if ($useragent == '') { |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | } |
40 | 40 | if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
41 | 41 | else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
42 | - curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
|
42 | + curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback")); |
|
43 | 43 | if ($type == 'post') { |
44 | 44 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
45 | 45 | if (is_array($data)) { |
46 | 46 | curl_setopt($ch, CURLOPT_POST, count($data)); |
47 | 47 | $data_string = ''; |
48 | - foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
48 | + foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
49 | 49 | rtrim($data_string, '&'); |
50 | 50 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); |
51 | 51 | } else { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | if ($cookie != '') { |
59 | 59 | if (is_array($cookie)) { |
60 | - curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';')); |
|
60 | + curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';')); |
|
61 | 61 | } else { |
62 | 62 | curl_setopt($ch, CURLOPT_COOKIE, $cookie); |
63 | 63 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | if ($sizelimit === true) { |
69 | 69 | curl_setopt($ch, CURLOPT_BUFFERSIZE, 128); |
70 | 70 | curl_setopt($ch, CURLOPT_NOPROGRESS, false); |
71 | - curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr,$downloadsize, $downloaded, $uploadsize, $uploaded){ |
|
71 | + curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr, $downloadsize, $downloaded, $uploadsize, $uploaded) { |
|
72 | 72 | return ($downloaded > (3*1024)) ? 1 : 0; |
73 | 73 | }); |
74 | 74 | } |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | $result = curl_exec($ch); |
80 | 80 | $info = curl_getinfo($ch); |
81 | 81 | curl_close($ch); |
82 | - if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) { |
|
82 | + if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) { |
|
83 | 83 | echo "Cloudflare Detected\n"; |
84 | 84 | require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php'); |
85 | 85 | $useragent = UAgent::random(); |
86 | 86 | cloudflare::useUserAgent($useragent); |
87 | 87 | if ($clearanceCookie = cloudflare::bypass($url)) { |
88 | - return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent); |
|
88 | + return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent); |
|
89 | 89 | } |
90 | 90 | } else { |
91 | 91 | return $result; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
110 | 110 | if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
111 | 111 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
112 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
112 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
113 | 113 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
114 | 114 | } |
115 | 115 | } |
@@ -124,20 +124,20 @@ discard block |
||
124 | 124 | fclose($fp); |
125 | 125 | } |
126 | 126 | |
127 | - public static function gunzip($in_file,$out_file_name = '') { |
|
127 | + public static function gunzip($in_file, $out_file_name = '') { |
|
128 | 128 | //echo $in_file.' -> '.$out_file_name."\n"; |
129 | 129 | $buffer_size = 4096; // read 4kb at a time |
130 | 130 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
131 | 131 | if ($in_file != '' && file_exists($in_file)) { |
132 | 132 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
133 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
134 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
133 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
134 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
135 | 135 | else { |
136 | 136 | echo 'gzopen not available'; |
137 | 137 | die; |
138 | 138 | } |
139 | 139 | $out_file = fopen($out_file_name, 'wb'); |
140 | - while(!gzeof($file)) { |
|
140 | + while (!gzeof($file)) { |
|
141 | 141 | fwrite($out_file, gzread($file, $buffer_size)); |
142 | 142 | } |
143 | 143 | fclose($out_file); |
@@ -145,19 +145,19 @@ discard block |
||
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | - public static function bunzip2($in_file,$out_file_name = '') { |
|
148 | + public static function bunzip2($in_file, $out_file_name = '') { |
|
149 | 149 | //echo $in_file.' -> '.$out_file_name."\n"; |
150 | 150 | $buffer_size = 4096; // read 4kb at a time |
151 | 151 | if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
152 | 152 | if ($in_file != '' && file_exists($in_file)) { |
153 | 153 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
154 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
154 | + if (function_exists('bzopen')) $file = bzopen($in_file, 'rb'); |
|
155 | 155 | else { |
156 | 156 | echo 'bzopen not available'; |
157 | 157 | die; |
158 | 158 | } |
159 | 159 | $out_file = fopen($out_file_name, 'wb'); |
160 | - while(!feof($file)) { |
|
160 | + while (!feof($file)) { |
|
161 | 161 | fwrite($out_file, bzread($file, $buffer_size)); |
162 | 162 | } |
163 | 163 | fclose($out_file); |
@@ -175,27 +175,27 @@ discard block |
||
175 | 175 | if ($data == '') return array(); |
176 | 176 | $html = str_get_html($data); |
177 | 177 | if ($html === false) return array(); |
178 | - $tabledata=array(); |
|
179 | - foreach($html->find('tr') as $element) |
|
178 | + $tabledata = array(); |
|
179 | + foreach ($html->find('tr') as $element) |
|
180 | 180 | { |
181 | 181 | $td = array(); |
182 | - foreach( $element->find('th') as $row) |
|
182 | + foreach ($element->find('th') as $row) |
|
183 | 183 | { |
184 | 184 | $td [] = trim($row->plaintext); |
185 | 185 | } |
186 | - $td=array_filter($td); |
|
186 | + $td = array_filter($td); |
|
187 | 187 | $tabledata[] = $td; |
188 | 188 | |
189 | 189 | $td = array(); |
190 | 190 | $tdi = array(); |
191 | - foreach( $element->find('td') as $row) |
|
191 | + foreach ($element->find('td') as $row) |
|
192 | 192 | { |
193 | 193 | $td [] = trim($row->plaintext); |
194 | 194 | $tdi [] = trim($row->innertext); |
195 | 195 | } |
196 | - $td=array_filter($td); |
|
197 | - $tdi=array_filter($tdi); |
|
198 | - $tabledata[]=array_merge($td,$tdi); |
|
196 | + $td = array_filter($td); |
|
197 | + $tdi = array_filter($tdi); |
|
198 | + $tabledata[] = array_merge($td, $tdi); |
|
199 | 199 | } |
200 | 200 | $html->clear(); |
201 | 201 | unset($html); |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | public function text2array($data) { |
211 | 211 | $html = str_get_html($data); |
212 | 212 | if ($html === false) return array(); |
213 | - $tabledata=array(); |
|
214 | - foreach($html->find('p') as $element) |
|
213 | + $tabledata = array(); |
|
214 | + foreach ($html->find('p') as $element) |
|
215 | 215 | { |
216 | 216 | $tabledata [] = trim($element->plaintext); |
217 | 217 | } |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
233 | 233 | if ($lat == $latc && $lon == $lonc) return 0; |
234 | - $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
|
234 | + $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515; |
|
235 | 235 | if ($unit == "km") { |
236 | - return round($dist * 1.609344); |
|
236 | + return round($dist*1.609344); |
|
237 | 237 | } elseif ($unit == "m") { |
238 | - return round($dist * 1.609344 * 1000); |
|
238 | + return round($dist*1.609344*1000); |
|
239 | 239 | } elseif ($unit == "mile" || $unit == "mi") { |
240 | 240 | return round($dist); |
241 | 241 | } elseif ($unit == "nm") { |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @param String $distance distance between two points in m |
253 | 253 | * @return Float plunge |
254 | 254 | */ |
255 | - public function plunge($initial_altitude,$final_altitude,$distance) { |
|
256 | - $plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance)); |
|
255 | + public function plunge($initial_altitude, $final_altitude, $distance) { |
|
256 | + $plunge = rad2deg(asin(($final_altitude - $initial_altitude)/$distance)); |
|
257 | 257 | return $plunge; |
258 | 258 | } |
259 | 259 | |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | public function azimuth($lat, $lon, $latc, $lonc) { |
269 | 269 | $dX = $latc - $lat; |
270 | 270 | $dY = $lonc - $lon; |
271 | - $azimuth = rad2deg(atan2($dY,$dX)); |
|
272 | - if ($azimuth < 0) return $azimuth+360; |
|
271 | + $azimuth = rad2deg(atan2($dY, $dX)); |
|
272 | + if ($azimuth < 0) return $azimuth + 360; |
|
273 | 273 | return $azimuth; |
274 | 274 | } |
275 | 275 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @param float $distance distance covered |
281 | 281 | * @return whether distance is realistic |
282 | 282 | */ |
283 | - public function withinThreshold ($timeDifference, $distance) { |
|
283 | + public function withinThreshold($timeDifference, $distance) { |
|
284 | 284 | $x = abs($timeDifference); |
285 | 285 | $d = abs($distance); |
286 | 286 | if ($x == 0 || $d == 0) return true; |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | return ($array !== array_values($array)); |
297 | 297 | } |
298 | 298 | |
299 | - public function isInteger($input){ |
|
299 | + public function isInteger($input) { |
|
300 | 300 | return(ctype_digit(strval($input))); |
301 | 301 | } |
302 | 302 | |
303 | 303 | |
304 | - public function convertDec($dms,$latlong) { |
|
304 | + public function convertDec($dms, $latlong) { |
|
305 | 305 | if ($latlong == 'latitude') { |
306 | 306 | $deg = substr($dms, 0, 2); |
307 | 307 | $min = substr($dms, 2, 4); |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | $deg = substr($dms, 0, 3); |
310 | 310 | $min = substr($dms, 3, 5); |
311 | 311 | } |
312 | - return $deg+(($min*60)/3600); |
|
312 | + return $deg + (($min*60)/3600); |
|
313 | 313 | } |
314 | 314 | |
315 | - public function convertDM($coord,$latlong) { |
|
315 | + public function convertDM($coord, $latlong) { |
|
316 | 316 | if ($latlong == 'latitude') { |
317 | 317 | if ($coord < 0) $NSEW = 'S'; |
318 | 318 | else $NSEW = 'N'; |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | } |
323 | 323 | $coord = abs($coord); |
324 | 324 | $deg = floor($coord); |
325 | - $coord = ($coord-$deg)*60; |
|
325 | + $coord = ($coord - $deg)*60; |
|
326 | 326 | $min = $coord; |
327 | - return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW); |
|
327 | + return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | public function xcopy($source, $dest) |
337 | 337 | { |
338 | 338 | $files = glob($source.'*.*'); |
339 | - foreach($files as $file){ |
|
340 | - $file_to_go = str_replace($source,$dest,$file); |
|
339 | + foreach ($files as $file) { |
|
340 | + $file_to_go = str_replace($source, $dest, $file); |
|
341 | 341 | copy($file, $file_to_go); |
342 | 342 | } |
343 | 343 | return true; |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | * @param String $url url to check |
349 | 349 | * @return bool Return true on succes false on failure |
350 | 350 | */ |
351 | - public function urlexist($url){ |
|
352 | - $headers=get_headers($url); |
|
353 | - return stripos($headers[0],"200 OK")?true:false; |
|
351 | + public function urlexist($url) { |
|
352 | + $headers = get_headers($url); |
|
353 | + return stripos($headers[0], "200 OK") ?true:false; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | public function hex2str($hex) { |
362 | 362 | $str = ''; |
363 | 363 | $hexln = strlen($hex); |
364 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
364 | + for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2))); |
|
365 | 365 | return $str; |
366 | 366 | } |
367 | 367 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @return String Return result |
372 | 372 | */ |
373 | 373 | public function hex2rgb($hex) { |
374 | - $hex = str_replace('#','',$hex); |
|
374 | + $hex = str_replace('#', '', $hex); |
|
375 | 375 | return sscanf($hex, "%02x%02x%02x"); |
376 | 376 | } |
377 | 377 | |
@@ -379,33 +379,33 @@ discard block |
||
379 | 379 | //difference in longitudinal coordinates |
380 | 380 | $dLon = deg2rad($lon2) - deg2rad($lon1); |
381 | 381 | //difference in the phi of latitudinal coordinates |
382 | - $dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4)); |
|
382 | + $dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4)); |
|
383 | 383 | //we need to recalculate $dLon if it is greater than pi |
384 | - if(abs($dLon) > pi()) { |
|
385 | - if($dLon > 0) { |
|
386 | - $dLon = (2 * pi() - $dLon) * -1; |
|
384 | + if (abs($dLon) > pi()) { |
|
385 | + if ($dLon > 0) { |
|
386 | + $dLon = (2*pi() - $dLon)*-1; |
|
387 | 387 | } else { |
388 | - $dLon = 2 * pi() + $dLon; |
|
388 | + $dLon = 2*pi() + $dLon; |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | //return the angle, normalized |
392 | - return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360; |
|
392 | + return (rad2deg(atan2($dLon, $dPhi)) + 360)%360; |
|
393 | 393 | } |
394 | 394 | |
395 | - public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) { |
|
395 | + public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) { |
|
396 | 396 | //$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1); |
397 | - $a = -($lon2-$lon1); |
|
397 | + $a = -($lon2 - $lon1); |
|
398 | 398 | $b = $lat2 - $lat1; |
399 | - $c = -($a*$lat1+$b*$lon1); |
|
400 | - $d = $a*$lat3+$b*$lon3+$c; |
|
399 | + $c = -($a*$lat1 + $b*$lon1); |
|
400 | + $d = $a*$lat3 + $b*$lon3 + $c; |
|
401 | 401 | if ($d > -$approx && $d < $approx) return true; |
402 | 402 | else return false; |
403 | 403 | } |
404 | 404 | |
405 | 405 | public function array_merge_noappend() { |
406 | 406 | $output = array(); |
407 | - foreach(func_get_args() as $array) { |
|
408 | - foreach($array as $key => $value) { |
|
407 | + foreach (func_get_args() as $array) { |
|
408 | + foreach ($array as $key => $value) { |
|
409 | 409 | $output[$key] = isset($output[$key]) ? |
410 | 410 | array_merge($output[$key], $value) : $value; |
411 | 411 | } |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | return $result; |
470 | 470 | } |
471 | 471 | |
472 | - public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){ |
|
472 | + public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') { |
|
473 | 473 | global $globalMapRefresh; |
474 | 474 | if ($seconds == '') { |
475 | 475 | $distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000; |
@@ -480,27 +480,27 @@ discard block |
||
480 | 480 | $latitude = deg2rad($latitude); |
481 | 481 | $longitude = deg2rad($longitude); |
482 | 482 | $bearing = deg2rad($heading); |
483 | - $latitude2 = asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) ); |
|
484 | - $longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) ); |
|
485 | - return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.','')); |
|
483 | + $latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing))); |
|
484 | + $longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2))); |
|
485 | + return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', '')); |
|
486 | 486 | } |
487 | 487 | |
488 | - public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) { |
|
488 | + public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) { |
|
489 | 489 | // distance in meter |
490 | 490 | $R = 6378.14; |
491 | - $latitude1 = $latitude * (M_PI/180); |
|
492 | - $longitude1 = $longitude * (M_PI/180); |
|
493 | - $brng = $bearing * (M_PI/180); |
|
491 | + $latitude1 = $latitude*(M_PI/180); |
|
492 | + $longitude1 = $longitude*(M_PI/180); |
|
493 | + $brng = $bearing*(M_PI/180); |
|
494 | 494 | $d = $distance; |
495 | 495 | |
496 | 496 | $latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng)); |
497 | - $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2)); |
|
497 | + $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2)); |
|
498 | 498 | |
499 | - $latitude2 = $latitude2 * (180/M_PI); |
|
500 | - $longitude2 = $longitude2 * (180/M_PI); |
|
499 | + $latitude2 = $latitude2*(180/M_PI); |
|
500 | + $longitude2 = $longitude2*(180/M_PI); |
|
501 | 501 | |
502 | - $flat = round ($latitude2,6); |
|
503 | - $flong = round ($longitude2,6); |
|
502 | + $flat = round($latitude2, 6); |
|
503 | + $flong = round($longitude2, 6); |
|
504 | 504 | /* |
505 | 505 | $dx = $distance*cos($bearing); |
506 | 506 | $dy = $distance*sin($bearing); |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | $flong = $longitude + $dlong; |
510 | 510 | $flat = $latitude + $dlat; |
511 | 511 | */ |
512 | - return array('latitude' => $flat,'longitude' => $flong); |
|
512 | + return array('latitude' => $flat, 'longitude' => $flong); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | /** |
@@ -523,14 +523,14 @@ discard block |
||
523 | 523 | * @param integer $level GZIP compression level (default: 9) |
524 | 524 | * @return string New filename (with .gz appended) if success, or false if operation fails |
525 | 525 | */ |
526 | - public function gzCompressFile($source, $level = 9){ |
|
527 | - $dest = $source . '.gz'; |
|
528 | - $mode = 'wb' . $level; |
|
526 | + public function gzCompressFile($source, $level = 9) { |
|
527 | + $dest = $source.'.gz'; |
|
528 | + $mode = 'wb'.$level; |
|
529 | 529 | $error = false; |
530 | 530 | if ($fp_out = gzopen($dest, $mode)) { |
531 | - if ($fp_in = fopen($source,'rb')) { |
|
531 | + if ($fp_in = fopen($source, 'rb')) { |
|
532 | 532 | while (!feof($fp_in)) |
533 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
533 | + gzwrite($fp_out, fread($fp_in, 1024*512)); |
|
534 | 534 | fclose($fp_in); |
535 | 535 | } else { |
536 | 536 | $error = true; |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | } |
547 | 547 | |
548 | 548 | public function remove_accents($string) { |
549 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
549 | + if (!preg_match('/[\x80-\xff]/', $string)) return $string; |
|
550 | 550 | $chars = array( |
551 | 551 | // Decompositions for Latin-1 Supplement |
552 | 552 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
604 | 604 | chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
605 | 605 | chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
606 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
606 | + chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij', |
|
607 | 607 | chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
608 | 608 | chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
609 | 609 | chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
@@ -619,13 +619,13 @@ discard block |
||
619 | 619 | chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
620 | 620 | chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
621 | 621 | chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
622 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
623 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
624 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
625 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
626 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
627 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
628 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
622 | + chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', |
|
623 | + chr(197).chr(148) => 'R', chr(197).chr(149) => 'r', |
|
624 | + chr(197).chr(150) => 'R', chr(197).chr(151) => 'r', |
|
625 | + chr(197).chr(152) => 'R', chr(197).chr(153) => 'r', |
|
626 | + chr(197).chr(154) => 'S', chr(197).chr(155) => 's', |
|
627 | + chr(197).chr(156) => 'S', chr(197).chr(157) => 's', |
|
628 | + chr(197).chr(158) => 'S', chr(197).chr(159) => 's', |
|
629 | 629 | chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
630 | 630 | chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
631 | 631 | chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) { |
660 | 660 | if (is_numeric($string[$i]) && $concat_flag) { |
661 | 661 | $int .= $string[$i]; |
662 | - } elseif(!$concat && $concat_flag && strlen($int) > 0) { |
|
662 | + } elseif (!$concat && $concat_flag && strlen($int) > 0) { |
|
663 | 663 | $concat_flag = false; |
664 | 664 | } |
665 | 665 | } |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | $slice = array_slice($arr, $offset + 1, $length); |
706 | 706 | return implode("", $slice); |
707 | 707 | } else { |
708 | - return mb_substr($string,$offset,$length,'UTF-8'); |
|
708 | + return mb_substr($string, $offset, $length, 'UTF-8'); |
|
709 | 709 | } |
710 | 710 | } |
711 | 711 | |
@@ -715,14 +715,14 @@ discard block |
||
715 | 715 | //NOTE: use a trailing slash for folders!!! |
716 | 716 | //see http://bugs.php.net/bug.php?id=27609 |
717 | 717 | //see http://bugs.php.net/bug.php?id=30931 |
718 | - if ($path{strlen($path)-1}=='/') // recursively return a temporary file path |
|
718 | + if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path |
|
719 | 719 | return $this->is__writable($path.uniqid(mt_rand()).'.tmp'); |
720 | 720 | else if (is_dir($path)) |
721 | 721 | return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
722 | 722 | // check tmp file for read/write capabilities |
723 | 723 | $rm = file_exists($path); |
724 | 724 | $f = @fopen($path, 'a'); |
725 | - if ($f===false) |
|
725 | + if ($f === false) |
|
726 | 726 | return false; |
727 | 727 | fclose($f); |
728 | 728 | if (!$rm) |