@@ -55,23 +55,23 @@ discard block |
||
55 | 55 | $min = true; |
56 | 56 | $allhistory = false; |
57 | 57 | $filter['source'] = array(); |
58 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
59 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
60 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
61 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
62 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
63 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
64 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
58 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
59 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
60 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
61 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
62 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
63 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
64 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
65 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
66 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
67 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
68 | 68 | |
69 | 69 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
70 | 70 | $min = true; |
71 | 71 | } else $min = false; |
72 | 72 | |
73 | 73 | if (isset($_GET['ident'])) { |
74 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
74 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
75 | 75 | if ($tracker) { |
76 | 76 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident); |
77 | 77 | } elseif ($marine) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | $allhistory = true; |
87 | 87 | } elseif (isset($_GET['flightaware_id'])) { |
88 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
88 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
89 | 89 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
90 | 90 | if (empty($spotter_array)) { |
91 | 91 | $from_archive = true; |
@@ -93,44 +93,44 @@ discard block |
||
93 | 93 | } |
94 | 94 | $allhistory = true; |
95 | 95 | } elseif (isset($_GET['famtrack_id'])) { |
96 | - $famtrack_id = filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING); |
|
96 | + $famtrack_id = filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING); |
|
97 | 97 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id); |
98 | 98 | $allhistory = true; |
99 | 99 | } elseif (isset($_GET['fammarine_id'])) { |
100 | - $fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING); |
|
100 | + $fammarine_id = filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING); |
|
101 | 101 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id); |
102 | 102 | $allhistory = true; |
103 | 103 | } elseif (isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) { |
104 | 104 | //} elseif (isset($_GET['coord'])) { |
105 | 105 | $usecoord = true; |
106 | - $coord = explode(',',$_GET['coord']); |
|
106 | + $coord = explode(',', $_GET['coord']); |
|
107 | 107 | if ($tracker) { |
108 | - $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter); |
|
108 | + $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord, $filter); |
|
109 | 109 | } elseif ($marine) { |
110 | - $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter); |
|
110 | + $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord, $filter); |
|
111 | 111 | } else { |
112 | - $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter); |
|
112 | + $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter); |
|
113 | 113 | } |
114 | 114 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) { |
115 | 115 | $usecoord = true; |
116 | - $coord = explode(',',$_GET['coord']); |
|
116 | + $coord = explode(',', $_GET['coord']); |
|
117 | 117 | if ($tracker) { |
118 | - $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
|
118 | + $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter); |
|
119 | 119 | } elseif ($marine) { |
120 | - $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter); |
|
120 | + $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter); |
|
121 | 121 | } else { |
122 | - $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter); |
|
122 | + $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter); |
|
123 | 123 | } |
124 | 124 | } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) { |
125 | 125 | $from_archive = true; |
126 | 126 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
127 | 127 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
128 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
129 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
130 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
131 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
132 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
133 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
128 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
129 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
130 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
131 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
132 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
133 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
134 | 134 | } elseif ($min) { |
135 | 135 | if ($tracker) { |
136 | 136 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter); |
@@ -142,18 +142,18 @@ discard block |
||
142 | 142 | # $min = true; |
143 | 143 | } else { |
144 | 144 | if ($tracker) { |
145 | - $spotter_array = $TrackerLive->getLiveTrackerData('','',$filter); |
|
145 | + $spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter); |
|
146 | 146 | } elseif ($marine) { |
147 | - $spotter_array = $marineLive->getLiveMarineData('','',$filter); |
|
147 | + $spotter_array = $marineLive->getLiveMarineData('', '', $filter); |
|
148 | 148 | } else { |
149 | - $spotter_array = $SpotterLive->getLiveSpotterData('','',$filter); |
|
149 | + $spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | if (!empty($spotter_array) || $usecoord) { |
154 | 154 | if ($usecoord) { |
155 | 155 | if (isset($_GET['archive'])) { |
156 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
156 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
157 | 157 | } else { |
158 | 158 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
159 | 159 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | if ($flightcnt == '') $flightcnt = 0; |
162 | 162 | } else $flightcnt = 0; |
163 | 163 | |
164 | -$sqltime = round(microtime(true)-$begintime,2); |
|
164 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
165 | 165 | |
166 | 166 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
167 | 167 | else $usenextlatlon = true; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | if (!empty($spotter_array) && is_array($spotter_array)) |
179 | 179 | { |
180 | 180 | $output .= '"features": ['; |
181 | - foreach($spotter_array as $spotter_item) |
|
181 | + foreach ($spotter_array as $spotter_item) |
|
182 | 182 | { |
183 | 183 | $j++; |
184 | 184 | date_default_timezone_set('UTC'); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
244 | 244 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
245 | 245 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
246 | - $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
|
246 | + $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",'; |
|
247 | 247 | } elseif (isset($spotter_item['aircraft_type'])) { |
248 | 248 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
249 | 249 | } elseif (!$min) { |
@@ -383,16 +383,16 @@ discard block |
||
383 | 383 | else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
384 | 384 | |
385 | 385 | if (isset($archivespeed)) { |
386 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
386 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed); |
|
387 | 387 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
388 | 388 | } elseif ($usenextlatlon) { |
389 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
389 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']); |
|
390 | 390 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
391 | 391 | } |
392 | 392 | |
393 | 393 | if (!$min) $output .= '"image": "'.$image.'",'; |
394 | 394 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
395 | - $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
|
395 | + $output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; |
|
396 | 396 | } |
397 | 397 | if (isset($spotter_item['image_source_website'])) { |
398 | 398 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
415 | 415 | } |
416 | 416 | if (isset($spotter_item['acars'])) { |
417 | - $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
|
417 | + $output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; |
|
418 | 418 | } |
419 | 419 | // type when not aircraft ? |
420 | 420 | if (isset($spotter_item['type'])) { |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | |
493 | 493 | } |
494 | 494 | */ |
495 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
|
495 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING); |
|
496 | 496 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
497 | 497 | |
498 | 498 | if ( |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
501 | 501 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
502 | 502 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
503 | - || (isset($history) && $history != '' && $history != 'NA' && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
503 | + || (isset($history) && $history != '' && $history != 'NA' && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
504 | 504 | || (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
505 | 505 | ) { |
506 | 506 | if ($tracker) { |
@@ -529,9 +529,9 @@ discard block |
||
529 | 529 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
530 | 530 | } |
531 | 531 | $output_history .= '['; |
532 | - $output_history .= $spotter_history['longitude'].', '; |
|
533 | - $output_history .= $spotter_history['latitude'].', '; |
|
534 | - $output_history .= $spotter_history['altitude']*30.48; |
|
532 | + $output_history .= $spotter_history['longitude'].', '; |
|
533 | + $output_history .= $spotter_history['latitude'].', '; |
|
534 | + $output_history .= $spotter_history['altitude']*30.48; |
|
535 | 535 | $output_history .= '],'; |
536 | 536 | $prev_alt = $alt; |
537 | 537 | } else { |
@@ -540,8 +540,8 @@ discard block |
||
540 | 540 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
541 | 541 | } else $d = true; |
542 | 542 | $output_history .= '['; |
543 | - $output_history .= $spotter_history['longitude'].', '; |
|
544 | - $output_history .= $spotter_history['latitude']; |
|
543 | + $output_history .= $spotter_history['longitude'].', '; |
|
544 | + $output_history .= $spotter_history['latitude']; |
|
545 | 545 | $output_history .= '],'; |
546 | 546 | } |
547 | 547 | } |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | $output = substr($output, 0, -1); |
581 | 581 | $output .= ']'; |
582 | 582 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
583 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
|
583 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",'; |
|
584 | 584 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
585 | 585 | $output .= '"fc": "'.$j.'"'; |
586 | 586 | } else { |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | $s3 = sin($bank/2); |
44 | 44 | $c1c2 = $c1*$c2; |
45 | 45 | $s1s2 = $s1*$s2; |
46 | - $w =$c1c2*$c3 - $s1s2*$s3; |
|
47 | - $x =$c1c2*$s3 + $s1s2*$c3; |
|
48 | - $y =$s1*$c2*$c3 + $c1*$s2*$s3; |
|
49 | - $z =$c1*$s2*$c3 - $s1*$c2*$s3; |
|
50 | - return array('x' => $x,'y' => $y,'z' => $z,'w' => $w); |
|
46 | + $w = $c1c2*$c3 - $s1s2*$s3; |
|
47 | + $x = $c1c2*$s3 + $s1s2*$c3; |
|
48 | + $y = $s1*$c2*$c3 + $c1*$s2*$s3; |
|
49 | + $z = $c1*$s2*$c3 - $s1*$c2*$s3; |
|
50 | + return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w); |
|
51 | 51 | // return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365'); |
52 | 52 | |
53 | 53 | } |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | $min = false; |
69 | 69 | $allhistory = false; |
70 | 70 | $filter['source'] = array(); |
71 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
72 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
73 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
74 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
75 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
76 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
77 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
78 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
79 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
80 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
71 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
72 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
73 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
74 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
75 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
76 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
77 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
78 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
79 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
80 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
81 | 81 | /* |
82 | 82 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
83 | 83 | $min = true; |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | $from_archive = true; |
125 | 125 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
126 | 126 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
127 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
128 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
129 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
130 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
131 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
132 | - $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter); |
|
127 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
128 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
129 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
130 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
131 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
132 | + $spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter); |
|
133 | 133 | } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) { |
134 | 134 | $from_archive = true; |
135 | 135 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | $begindate = $_COOKIE['archive_begin']; |
140 | 140 | $enddate = $_COOKIE['archive_end']; |
141 | 141 | |
142 | - $archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT); |
|
143 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
144 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
142 | + $archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT); |
|
143 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
144 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
145 | 145 | // echo 'Begin : '.$begindate.' - End : '.$enddate."\n"; |
146 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
146 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
147 | 147 | } elseif ($tracker) { |
148 | 148 | $spotter_array = $TrackerLive->getMinLastLiveTrackerData($filter); |
149 | 149 | } elseif ($marine) { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | if (!empty($spotter_array)) { |
156 | 156 | if (isset($_GET['archive'])) { |
157 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
157 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
158 | 158 | } elseif ($tracker) { |
159 | 159 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
160 | 160 | } elseif ($marine) { |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | if ($flightcnt == '') $flightcnt = 0; |
166 | 166 | } else $flightcnt = 0; |
167 | 167 | |
168 | -$sqltime = round(microtime(true)-$begintime,2); |
|
168 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
169 | 169 | $minitime = time(); |
170 | 170 | $maxitime = 0; |
171 | 171 | |
172 | 172 | |
173 | 173 | $modelsdb = array(); |
174 | 174 | if (file_exists('models/modelsdb')) { |
175 | - if (($handle = fopen('models/modelsdb','r')) !== FALSE) { |
|
176 | - while (($row = fgetcsv($handle,1000)) !== FALSE) { |
|
177 | - if (isset($row[1]) ){ |
|
175 | + if (($handle = fopen('models/modelsdb', 'r')) !== FALSE) { |
|
176 | + while (($row = fgetcsv($handle, 1000)) !== FALSE) { |
|
177 | + if (isset($row[1])) { |
|
178 | 178 | $model = $row[0]; |
179 | 179 | $modelsdb[$model] = $row[1]; |
180 | 180 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $output .= '},'; |
210 | 210 | if (!empty($spotter_array) && is_array($spotter_array)) |
211 | 211 | { |
212 | - foreach($spotter_array as $spotter_item) |
|
212 | + foreach ($spotter_array as $spotter_item) |
|
213 | 213 | { |
214 | 214 | $j++; |
215 | 215 | date_default_timezone_set('UTC'); |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | $output .= '"cartographicDegrees": ['; |
498 | 498 | if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
499 | 499 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
500 | - $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
500 | + $output .= '"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
501 | 501 | $output .= $spotter_item['longitude'].', '; |
502 | 502 | $output .= $spotter_item['latitude']; |
503 | 503 | $prevlong = $spotter_item['longitude']; |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
512 | 512 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
513 | 513 | } else { |
514 | - $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
|
514 | + $output .= ',"'.date("c", strtotime($spotter_item['date'])).'", '; |
|
515 | 515 | if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
516 | 516 | if ($spotter_item['ground_speed'] == 0) { |
517 | 517 | $output .= $prevlong.', '; |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | $output = substr($output, 0, -1); |
544 | 544 | } |
545 | 545 | $output .= ']'; |
546 | -$output = str_replace('%minitime%',date("c",$minitime),$output); |
|
547 | -$output = str_replace('%maxitime%',date("c",$maxitime),$output); |
|
546 | +$output = str_replace('%minitime%', date("c", $minitime), $output); |
|
547 | +$output = str_replace('%maxitime%', date("c", $maxitime), $output); |
|
548 | 548 | print $output; |
549 | 549 | ?> |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | $currentdate = date('Y-m-d'); |
34 | 34 | $sourcestat = $Stats->getStatsSource($currentdate); |
35 | 35 | if (!empty($sourcestat)) { |
36 | - foreach($sourcestat as $srcst) { |
|
36 | + foreach ($sourcestat as $srcst) { |
|
37 | 37 | $type = $srcst['stats_type']; |
38 | 38 | if ($type == 'polar' || $type == 'hist') { |
39 | 39 | $source = $srcst['source_name']; |
40 | 40 | $data = $srcst['source_data']; |
41 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
41 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | } |
52 | 52 | |
53 | - public function get_Schedule($id,$ident) { |
|
53 | + public function get_Schedule($id, $ident) { |
|
54 | 54 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
55 | 55 | // Get schedule here, so it's done only one time |
56 | 56 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | $schedule = $Schedule->fetchSchedule($operator); |
76 | 76 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
77 | 77 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
78 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
79 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
78 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
79 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
80 | 80 | // Should also check if route schedule = route from DB |
81 | 81 | if ($schedule['DepartureAirportIATA'] != '') { |
82 | 82 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
99 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
99 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
100 | 100 | } |
101 | 101 | } else $scheduleexist = true; |
102 | 102 | } else $scheduleexist = true; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | if ($scheduleexist) { |
105 | 105 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
106 | 106 | $sch = $Schedule->getSchedule($operator); |
107 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
107 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
108 | 108 | } |
109 | 109 | $Spotter->db = null; |
110 | 110 | $Schedule->db = null; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
132 | 132 | $Spotter = new Spotter($this->db); |
133 | 133 | $real_arrival = $this->arrival($key); |
134 | - if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
134 | + if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $airport_time = ''; |
146 | 146 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
147 | 147 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
148 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
148 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
149 | 149 | if (isset($closestAirports[0])) { |
150 | 150 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
151 | 151 | $airport_icao = $closestAirports[0]['icao']; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | break; |
161 | 161 | } |
162 | 162 | } |
163 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
163 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
164 | 164 | $airport_icao = $closestAirports[0]['icao']; |
165 | 165 | $airport_time = $this->all_flights[$key]['datetime']; |
166 | 166 | } else { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } else { |
174 | 174 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
175 | 175 | } |
176 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
176 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
185 | 185 | foreach ($this->all_flights as $key => $flight) { |
186 | 186 | if (isset($flight['lastupdate'])) { |
187 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
187 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
188 | 188 | if (isset($this->all_flights[$key]['id'])) { |
189 | 189 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
190 | 190 | /* |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $real_arrival = $this->arrival($key); |
197 | 197 | $Spotter = new Spotter($this->db); |
198 | 198 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
199 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
199 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
200 | 200 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
201 | 201 | } |
202 | 202 | // Put in archive |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $send = false; |
234 | 234 | |
235 | 235 | // SBS format is CSV format |
236 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
236 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
237 | 237 | //print_r($line); |
238 | 238 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
239 | 239 | |
@@ -266,25 +266,25 @@ discard block |
||
266 | 266 | |
267 | 267 | if (!isset($this->all_flights[$id])) { |
268 | 268 | $this->all_flights[$id] = array(); |
269 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
270 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
271 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
269 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
270 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '')); |
|
271 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
272 | 272 | if (!isset($line['id'])) { |
273 | 273 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
274 | 274 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
275 | 275 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
276 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
276 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
277 | 277 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
278 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
278 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
279 | 279 | if ($globalAllFlights !== FALSE) $dataFound = true; |
280 | 280 | } |
281 | 281 | if (isset($line['source_type']) && $line['source_type'] != '') { |
282 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
282 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | //print_r($this->all_flights); |
286 | 286 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
287 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
287 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
288 | 288 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
289 | 289 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
290 | 290 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -293,13 +293,13 @@ discard block |
||
293 | 293 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
294 | 294 | $Spotter = new Spotter($this->db); |
295 | 295 | if (isset($this->all_flights[$id]['source_type'])) { |
296 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
296 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
297 | 297 | } else { |
298 | 298 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
299 | 299 | } |
300 | 300 | $Spotter->db = null; |
301 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
302 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
301 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
302 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | if ($globalAllFlights !== FALSE) $dataFound = true; |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $Spotter = new Spotter($this->db); |
311 | 311 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
312 | 312 | $Spotter->db = null; |
313 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
313 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
314 | 314 | } |
315 | 315 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
316 | 316 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | $Spotter = new Spotter($this->db); |
319 | 319 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
320 | 320 | $Spotter->db = null; |
321 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
321 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -326,15 +326,15 @@ discard block |
||
326 | 326 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
327 | 327 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
328 | 328 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
329 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
329 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
330 | 330 | } |
331 | 331 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
332 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
332 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
333 | 333 | } |
334 | 334 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
335 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
335 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
336 | 336 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
337 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
337 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
338 | 338 | } else { |
339 | 339 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
340 | 340 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -347,24 +347,24 @@ discard block |
||
347 | 347 | } |
348 | 348 | } else { |
349 | 349 | date_default_timezone_set('UTC'); |
350 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
350 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
354 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
354 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
355 | 355 | } |
356 | 356 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
357 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
357 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
358 | 358 | } |
359 | 359 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
360 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
360 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id'])); |
|
361 | 361 | } |
362 | 362 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
363 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
363 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name'])); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
367 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
367 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
368 | 368 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
369 | 369 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
370 | 370 | $timeelapsed = microtime(true); |
@@ -375,10 +375,10 @@ discard block |
||
375 | 375 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
376 | 376 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
377 | 377 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
378 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
378 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
379 | 379 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
380 | 380 | $Spotter->db = null; |
381 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
381 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
382 | 382 | } |
383 | 383 | } |
384 | 384 | |
@@ -390,25 +390,25 @@ discard block |
||
390 | 390 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
391 | 391 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
392 | 392 | */ |
393 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
393 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
394 | 394 | |
395 | 395 | //$putinarchive = true; |
396 | 396 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
397 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
397 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
398 | 398 | } |
399 | 399 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
400 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
400 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
401 | 401 | } |
402 | 402 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
403 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
403 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
404 | 404 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
405 | 405 | $timeelapsed = microtime(true); |
406 | 406 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
407 | 407 | $Spotter = new Spotter($this->db); |
408 | 408 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
409 | 409 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
410 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
411 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
410 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
411 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
412 | 412 | } |
413 | 413 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
414 | 414 | $timeelapsed = microtime(true); |
@@ -422,34 +422,34 @@ discard block |
||
422 | 422 | $Translation->db = null; |
423 | 423 | } |
424 | 424 | $Spotter->db = null; |
425 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
425 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
426 | 426 | } |
427 | 427 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
428 | 428 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
429 | 429 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
430 | 430 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
431 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
431 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | if (!isset($globalFork)) $globalFork = TRUE; |
435 | 435 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
436 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
436 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | } |
440 | 440 | |
441 | 441 | if (isset($line['speed']) && $line['speed'] != '') { |
442 | 442 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
443 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
444 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
443 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
444 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
445 | 445 | //$dataFound = true; |
446 | 446 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
447 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
447 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
448 | 448 | if ($distance > 1000 && $distance < 10000) { |
449 | 449 | // use datetime |
450 | 450 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
451 | 451 | $speed = $speed*3.6; |
452 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
452 | + if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
453 | 453 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
454 | 454 | } |
455 | 455 | } |
@@ -457,11 +457,11 @@ discard block |
||
457 | 457 | |
458 | 458 | |
459 | 459 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
460 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
460 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
461 | 461 | else unset($timediff); |
462 | - if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
462 | + if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) { |
|
463 | 463 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
464 | - if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
464 | + if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
465 | 465 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
466 | 466 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
467 | 467 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -471,10 +471,10 @@ discard block |
||
471 | 471 | $timeelapsed = microtime(true); |
472 | 472 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
473 | 473 | $Spotter = new Spotter($this->db); |
474 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
474 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
475 | 475 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
476 | 476 | $Spotter->db = null; |
477 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
477 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
478 | 478 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
479 | 479 | } |
480 | 480 | } |
@@ -484,13 +484,13 @@ discard block |
||
484 | 484 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
485 | 485 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
486 | 486 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
487 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
487 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
488 | 488 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
489 | 489 | $dataFound = true; |
490 | 490 | $this->all_flights[$id]['time_last_coord'] = time(); |
491 | 491 | } |
492 | 492 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
493 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
493 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
494 | 494 | /* |
495 | 495 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
496 | 496 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -508,13 +508,13 @@ discard block |
||
508 | 508 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
509 | 509 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
510 | 510 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
511 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
511 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
512 | 512 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
513 | 513 | $dataFound = true; |
514 | 514 | $this->all_flights[$id]['time_last_coord'] = time(); |
515 | 515 | } |
516 | 516 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
517 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
517 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
518 | 518 | /* |
519 | 519 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
520 | 520 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -532,46 +532,46 @@ discard block |
||
532 | 532 | } else if ($globalDebug && $timediff > 30) { |
533 | 533 | $this->tmd = $this->tmd + 1; |
534 | 534 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
535 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
536 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
535 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
536 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
537 | 537 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
538 | 538 | } |
539 | 539 | } |
540 | 540 | if (isset($line['last_update']) && $line['last_update'] != '') { |
541 | 541 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
542 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
542 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
543 | 543 | } |
544 | 544 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
545 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
545 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
546 | 546 | //$dataFound = true; |
547 | 547 | } |
548 | 548 | if (isset($line['format_source']) && $line['format_source'] != '') { |
549 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
549 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
550 | 550 | } |
551 | 551 | if (isset($line['source_name']) && $line['source_name'] != '') { |
552 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
552 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
553 | 553 | } |
554 | 554 | if (isset($line['emergency']) && $line['emergency'] != '') { |
555 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
555 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
556 | 556 | //$dataFound = true; |
557 | 557 | } |
558 | 558 | if (isset($line['ground']) && $line['ground'] != '') { |
559 | 559 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
560 | 560 | // Here we force archive of flight because after ground it's a new one (or should be) |
561 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
562 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
563 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
564 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
565 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
561 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
562 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
563 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
564 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
565 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
566 | 566 | } |
567 | 567 | if ($line['ground'] != 1) $line['ground'] = 0; |
568 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
568 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
569 | 569 | //$dataFound = true; |
570 | 570 | } |
571 | 571 | if (isset($line['squawk']) && $line['squawk'] != '') { |
572 | 572 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
573 | 573 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
574 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
574 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
575 | 575 | $highlight = ''; |
576 | 576 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
577 | 577 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -580,47 +580,47 @@ discard block |
||
580 | 580 | $timeelapsed = microtime(true); |
581 | 581 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
582 | 582 | $Spotter = new Spotter($this->db); |
583 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
583 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
584 | 584 | $Spotter->db = null; |
585 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
585 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
586 | 586 | } |
587 | 587 | //$putinarchive = true; |
588 | 588 | //$highlight = ''; |
589 | 589 | } |
590 | 590 | |
591 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
591 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
592 | 592 | //$dataFound = true; |
593 | 593 | } |
594 | 594 | |
595 | 595 | if (isset($line['altitude']) && $line['altitude'] != '') { |
596 | 596 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
597 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
598 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
599 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
597 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
598 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
599 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
600 | 600 | //$dataFound = true; |
601 | 601 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
602 | 602 | } |
603 | 603 | |
604 | 604 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
605 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
605 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | if (isset($line['heading']) && $line['heading'] != '') { |
609 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
610 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
611 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
609 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
610 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
611 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
612 | 612 | //$dataFound = true; |
613 | 613 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
614 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
615 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
616 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
614 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
615 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
616 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
617 | 617 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
618 | 618 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
619 | 619 | // If not enough messages and ACARS set heading to 0 |
620 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
620 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
621 | 621 | } |
622 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
623 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
622 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
623 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
624 | 624 | |
625 | 625 | // print_r($this->all_flights[$id]); |
626 | 626 | //gets the callsign from the last hour |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
631 | 631 | $this->all_flights[$id]['lastupdate'] = time(); |
632 | 632 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
633 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
633 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
634 | 634 | //print_r($this->all_flights); |
635 | 635 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
636 | 636 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -641,61 +641,61 @@ discard block |
||
641 | 641 | $SpotterLive = new SpotterLive($this->db); |
642 | 642 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
643 | 643 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
644 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
644 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
645 | 645 | } elseif (isset($line['id'])) { |
646 | 646 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
647 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
647 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
648 | 648 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
649 | 649 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
650 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
650 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
651 | 651 | } else $recent_ident = ''; |
652 | - $SpotterLive->db=null; |
|
652 | + $SpotterLive->db = null; |
|
653 | 653 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
654 | 654 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
655 | 655 | } else $recent_ident = ''; |
656 | 656 | } else { |
657 | 657 | $recent_ident = ''; |
658 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
658 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
659 | 659 | } |
660 | 660 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
661 | - if($recent_ident == "") |
|
661 | + if ($recent_ident == "") |
|
662 | 662 | { |
663 | 663 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
664 | 664 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
665 | 665 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
666 | 666 | //adds the spotter data for the archive |
667 | 667 | $ignoreImport = false; |
668 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
668 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
669 | 669 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
670 | 670 | $ignoreImport = true; |
671 | 671 | } |
672 | 672 | } |
673 | 673 | if (count($globalAirportAccept) > 0) { |
674 | 674 | $ignoreImport = true; |
675 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
675 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
676 | 676 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
677 | 677 | $ignoreImport = false; |
678 | 678 | } |
679 | 679 | } |
680 | 680 | } |
681 | 681 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
682 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
683 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
682 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
683 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
684 | 684 | $ignoreImport = true; |
685 | 685 | } |
686 | 686 | } |
687 | 687 | } |
688 | 688 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
689 | 689 | $ignoreImport = true; |
690 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
691 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
690 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
691 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
692 | 692 | $ignoreImport = false; |
693 | 693 | } |
694 | 694 | } |
695 | 695 | } |
696 | 696 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
697 | 697 | $ignoreImport = true; |
698 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
698 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
699 | 699 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
700 | 700 | $ignoreImport = false; |
701 | 701 | } |
@@ -707,32 +707,32 @@ discard block |
||
707 | 707 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
708 | 708 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
709 | 709 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
710 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
710 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
711 | 711 | $timeelapsed = microtime(true); |
712 | 712 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
713 | 713 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
714 | 714 | $Spotter = new Spotter($this->db); |
715 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
715 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
716 | 716 | $Spotter->db = null; |
717 | 717 | if ($globalDebug && isset($result)) echo $result."\n"; |
718 | 718 | } |
719 | 719 | } |
720 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
720 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
721 | 721 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
722 | 722 | |
723 | 723 | // Add source stat in DB |
724 | 724 | $Stats = new Stats($this->db); |
725 | 725 | if (!empty($this->stats)) { |
726 | 726 | if ($globalDebug) echo 'Add source stats : '; |
727 | - foreach($this->stats as $date => $data) { |
|
728 | - foreach($data as $source => $sourced) { |
|
727 | + foreach ($this->stats as $date => $data) { |
|
728 | + foreach ($data as $source => $sourced) { |
|
729 | 729 | //print_r($sourced); |
730 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
731 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
730 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
731 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
732 | 732 | if (isset($sourced['msg'])) { |
733 | 733 | if (time() - $sourced['msg']['date'] > 10) { |
734 | 734 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
735 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
735 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
736 | 736 | unset($this->stats[$date][$source]['msg']); |
737 | 737 | } |
738 | 738 | } |
@@ -770,14 +770,14 @@ discard block |
||
770 | 770 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
771 | 771 | $SpotterLive = new SpotterLive($this->db); |
772 | 772 | $SpotterLive->deleteLiveSpotterData(); |
773 | - $SpotterLive->db=null; |
|
773 | + $SpotterLive->db = null; |
|
774 | 774 | } |
775 | 775 | } |
776 | 776 | if ($globalDebug) echo " Done\n"; |
777 | 777 | $this->last_delete = time(); |
778 | 778 | } |
779 | 779 | } else { |
780 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) { |
|
780 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) { |
|
781 | 781 | $this->all_flights[$id]['id'] = $recent_ident; |
782 | 782 | $this->all_flights[$id]['addedSpotter'] = 1; |
783 | 783 | } |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
786 | 786 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
787 | 787 | $Spotter = new Spotter($this->db); |
788 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
788 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
789 | 789 | $Spotter->db = null; |
790 | 790 | } |
791 | 791 | } |
@@ -811,37 +811,37 @@ discard block |
||
811 | 811 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
812 | 812 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
813 | 813 | |
814 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
814 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
815 | 815 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
816 | 816 | $ignoreImport = true; |
817 | 817 | } |
818 | 818 | } |
819 | 819 | if (count($globalAirportAccept) > 0) { |
820 | 820 | $ignoreImport = true; |
821 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
821 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
822 | 822 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
823 | 823 | $ignoreImport = false; |
824 | 824 | } |
825 | 825 | } |
826 | 826 | } |
827 | 827 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
828 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
829 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
828 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
829 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
830 | 830 | $ignoreImport = true; |
831 | 831 | } |
832 | 832 | } |
833 | 833 | } |
834 | 834 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
835 | 835 | $ignoreImport = true; |
836 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
837 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
836 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
837 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
838 | 838 | $ignoreImport = false; |
839 | 839 | } |
840 | 840 | } |
841 | 841 | } |
842 | 842 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
843 | 843 | $ignoreImport = true; |
844 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
844 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
845 | 845 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
846 | 846 | $ignoreImport = false; |
847 | 847 | } |
@@ -849,23 +849,23 @@ discard block |
||
849 | 849 | } |
850 | 850 | |
851 | 851 | if (!$ignoreImport) { |
852 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
853 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
852 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
853 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
854 | 854 | $timeelapsed = microtime(true); |
855 | 855 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
856 | 856 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
857 | 857 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
858 | 858 | $SpotterLive = new SpotterLive($this->db); |
859 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
859 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
860 | 860 | $SpotterLive->db = null; |
861 | 861 | if ($globalDebug) echo $result."\n"; |
862 | 862 | } |
863 | 863 | } |
864 | 864 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
865 | - $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
865 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
866 | 866 | } |
867 | 867 | $this->all_flights[$id]['putinarchive'] = false; |
868 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
868 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
869 | 869 | |
870 | 870 | // Put statistics in $this->stats variable |
871 | 871 | //if ($line['format_source'] != 'aprs') { |
@@ -884,19 +884,19 @@ discard block |
||
884 | 884 | $latitude = $globalCenterLatitude; |
885 | 885 | $longitude = $globalCenterLongitude; |
886 | 886 | } |
887 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
887 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
888 | 888 | } else { |
889 | 889 | $latitude = $this->source_location[$source]['latitude']; |
890 | 890 | $longitude = $this->source_location[$source]['longitude']; |
891 | 891 | } |
892 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
892 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
893 | 893 | //$stats_heading = $stats_heading%22.5; |
894 | 894 | $stats_heading = round($stats_heading/22.5); |
895 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
895 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
896 | 896 | $current_date = date('Y-m-d'); |
897 | 897 | if ($stats_heading == 16) $stats_heading = 0; |
898 | 898 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
899 | - for ($i=0;$i<=15;$i++) { |
|
899 | + for ($i = 0; $i <= 15; $i++) { |
|
900 | 900 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
901 | 901 | } |
902 | 902 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -911,9 +911,9 @@ discard block |
||
911 | 911 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
912 | 912 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
913 | 913 | end($this->stats[$current_date][$source]['hist']); |
914 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
914 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
915 | 915 | } else $mini = 0; |
916 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
916 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
917 | 917 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
918 | 918 | } |
919 | 919 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | $this->all_flights[$id]['lastupdate'] = time(); |
927 | 927 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
928 | 928 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
929 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
929 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
930 | 930 | //$this->del(); |
931 | 931 | |
932 | 932 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -13,62 +13,62 @@ discard block |
||
13 | 13 | * @param Array $filter the filter |
14 | 14 | * @return Array the SQL part |
15 | 15 | */ |
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
16 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
18 | 18 | $filters = array(); |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
20 | 20 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
21 | 21 | $filters = $globalStatsFilters[$globalFilterName]; |
22 | 22 | } else { |
23 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
23 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | if (isset($filter[0]['source'])) { |
27 | - $filters = array_merge($filters,$filter); |
|
27 | + $filters = array_merge($filters, $filter); |
|
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | - foreach($filters as $flt) { |
|
32 | + foreach ($filters as $flt) { |
|
33 | 33 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
34 | 34 | if ($flt['airlines'][0] != '') { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
36 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
37 | 37 | } else { |
38 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
43 | 43 | if (isset($flt['source'])) { |
44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
45 | 45 | } else { |
46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
50 | 50 | if (isset($flt['source'])) { |
51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
52 | 52 | } else { |
53 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
53 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
57 | 57 | if (isset($flt['source'])) { |
58 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
58 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
59 | 59 | } else { |
60 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
60 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
64 | 64 | if (isset($flt['source'])) { |
65 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
65 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
69 | 69 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
70 | 70 | if ($filter['airlines'][0] != '') { |
71 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
71 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -76,16 +76,16 @@ discard block |
||
76 | 76 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
77 | 77 | } |
78 | 78 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
79 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
79 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
80 | 80 | } |
81 | 81 | if (isset($filter['source']) && !empty($filter['source'])) { |
82 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
82 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
83 | 83 | } |
84 | 84 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
85 | 85 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
86 | 86 | } |
87 | 87 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
88 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
88 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
89 | 89 | } |
90 | 90 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
91 | 91 | $filter_query_date = ''; |
@@ -111,40 +111,40 @@ discard block |
||
111 | 111 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
112 | 112 | } |
113 | 113 | } |
114 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
114 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
115 | 115 | } |
116 | 116 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
117 | 117 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
118 | 118 | if ($filter_query_where != '') { |
119 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
119 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
120 | 120 | } |
121 | 121 | $filter_query = $filter_query_join.$filter_query_where; |
122 | 122 | return $filter_query; |
123 | 123 | } |
124 | 124 | |
125 | 125 | // Spotter_archive |
126 | - public function 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 = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
126 | + public function 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 = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
127 | 127 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
128 | 128 | if ($over_country == '') { |
129 | 129 | $Spotter = new Spotter($this->db); |
130 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
130 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
131 | 131 | if (!empty($data_country)) $country = $data_country['iso2']; |
132 | 132 | else $country = ''; |
133 | 133 | } else $country = $over_country; |
134 | - if ($airline_type === NULL) $airline_type =''; |
|
134 | + if ($airline_type === NULL) $airline_type = ''; |
|
135 | 135 | |
136 | 136 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
137 | 137 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
138 | 138 | |
139 | 139 | // Route is not added in spotter_archive |
140 | - $query = "INSERT INTO spotter_archive (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, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
140 | + $query = "INSERT INTO spotter_archive (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, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
141 | 141 | VALUES (: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, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)"; |
142 | 142 | |
143 | - $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_name' => $aircraft_name, ':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, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
143 | + $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_name' => $aircraft_name, ':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, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
144 | 144 | try { |
145 | 145 | $sth = $this->db->prepare($query); |
146 | 146 | $sth->execute($query_values); |
147 | - } catch(PDOException $e) { |
|
147 | + } catch (PDOException $e) { |
|
148 | 148 | return "error : ".$e->getMessage(); |
149 | 149 | } |
150 | 150 | return "success"; |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | |
165 | 165 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
166 | 166 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
167 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
167 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
168 | 168 | |
169 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
169 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
170 | 170 | |
171 | 171 | return $spotter_array; |
172 | 172 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
186 | 186 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
187 | 187 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
188 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
188 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
189 | 189 | |
190 | 190 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
191 | 191 | /* |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | } |
199 | 199 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
200 | 200 | */ |
201 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
201 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
202 | 202 | |
203 | 203 | return $spotter_array; |
204 | 204 | } |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | { |
214 | 214 | date_default_timezone_set('UTC'); |
215 | 215 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
216 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
216 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
217 | 217 | |
218 | 218 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
219 | 219 | |
220 | 220 | try { |
221 | 221 | $sth = $this->db->prepare($query); |
222 | 222 | $sth->execute(array(':id' => $id)); |
223 | - } catch(PDOException $e) { |
|
223 | + } catch (PDOException $e) { |
|
224 | 224 | echo $e->getMessage(); |
225 | 225 | die; |
226 | 226 | } |
@@ -239,14 +239,14 @@ discard block |
||
239 | 239 | { |
240 | 240 | date_default_timezone_set('UTC'); |
241 | 241 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
242 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
242 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
243 | 243 | |
244 | 244 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
245 | 245 | |
246 | 246 | try { |
247 | 247 | $sth = $this->db->prepare($query); |
248 | 248 | $sth->execute(array(':id' => $id)); |
249 | - } catch(PDOException $e) { |
|
249 | + } catch (PDOException $e) { |
|
250 | 250 | echo $e->getMessage(); |
251 | 251 | die; |
252 | 252 | } |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | date_default_timezone_set('UTC'); |
269 | 269 | |
270 | 270 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
271 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
271 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
272 | 272 | |
273 | 273 | try { |
274 | 274 | $sth = $this->db->prepare($query); |
275 | 275 | $sth->execute(array(':ident' => $ident)); |
276 | - } catch(PDOException $e) { |
|
276 | + } catch (PDOException $e) { |
|
277 | 277 | echo $e->getMessage(); |
278 | 278 | die; |
279 | 279 | } |
@@ -294,12 +294,12 @@ discard block |
||
294 | 294 | date_default_timezone_set('UTC'); |
295 | 295 | |
296 | 296 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
297 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
297 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
298 | 298 | |
299 | 299 | try { |
300 | 300 | $sth = $this->db->prepare($query); |
301 | 301 | $sth->execute(array(':id' => $id)); |
302 | - } catch(PDOException $e) { |
|
302 | + } catch (PDOException $e) { |
|
303 | 303 | echo $e->getMessage(); |
304 | 304 | die; |
305 | 305 | } |
@@ -320,12 +320,12 @@ discard block |
||
320 | 320 | date_default_timezone_set('UTC'); |
321 | 321 | |
322 | 322 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
323 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
323 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
324 | 324 | |
325 | 325 | try { |
326 | 326 | $sth = $this->db->prepare($query); |
327 | 327 | $sth->execute(array(':id' => $id)); |
328 | - } catch(PDOException $e) { |
|
328 | + } catch (PDOException $e) { |
|
329 | 329 | echo $e->getMessage(); |
330 | 330 | die; |
331 | 331 | } |
@@ -347,13 +347,13 @@ discard block |
||
347 | 347 | date_default_timezone_set('UTC'); |
348 | 348 | |
349 | 349 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
350 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
350 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
351 | 351 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
352 | 352 | |
353 | 353 | try { |
354 | 354 | $sth = $this->db->prepare($query); |
355 | 355 | $sth->execute(array(':ident' => $ident)); |
356 | - } catch(PDOException $e) { |
|
356 | + } catch (PDOException $e) { |
|
357 | 357 | echo $e->getMessage(); |
358 | 358 | die; |
359 | 359 | } |
@@ -370,13 +370,13 @@ discard block |
||
370 | 370 | * @return Array the spotter information |
371 | 371 | * |
372 | 372 | */ |
373 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
373 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
374 | 374 | { |
375 | 375 | $Spotter = new Spotter($this->db); |
376 | 376 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
377 | - $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.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
377 | + $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.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
378 | 378 | |
379 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
379 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
380 | 380 | |
381 | 381 | return $spotter_array; |
382 | 382 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | try { |
390 | 390 | $sth = $this->db->prepare($query); |
391 | 391 | $sth->execute(); |
392 | - } catch(PDOException $e) { |
|
392 | + } catch (PDOException $e) { |
|
393 | 393 | echo $e->getMessage(); |
394 | 394 | die; |
395 | 395 | } |
@@ -401,24 +401,24 @@ discard block |
||
401 | 401 | * @return Array the spotter information |
402 | 402 | * |
403 | 403 | */ |
404 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
404 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
405 | 405 | { |
406 | 406 | global $globalDBdriver, $globalLiveInterval; |
407 | 407 | date_default_timezone_set('UTC'); |
408 | 408 | |
409 | 409 | $filter_query = ''; |
410 | 410 | if (isset($filter['source']) && !empty($filter['source'])) { |
411 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
411 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
412 | 412 | } |
413 | 413 | // Use spotter_output also ? |
414 | 414 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
415 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
415 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
416 | 416 | } |
417 | 417 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
418 | 418 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
419 | 419 | } |
420 | 420 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
421 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
421 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -437,14 +437,14 @@ discard block |
||
437 | 437 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
438 | 438 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
439 | 439 | */ |
440 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
440 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
441 | 441 | FROM spotter_archive |
442 | 442 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
443 | 443 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
444 | 444 | '.$filter_query.' ORDER BY flightaware_id'; |
445 | 445 | } else { |
446 | 446 | //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
447 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
447 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
448 | 448 | FROM spotter_archive |
449 | 449 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
450 | 450 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | try { |
455 | 455 | $sth = $this->db->prepare($query); |
456 | 456 | $sth->execute(); |
457 | - } catch(PDOException $e) { |
|
457 | + } catch (PDOException $e) { |
|
458 | 458 | echo $e->getMessage(); |
459 | 459 | die; |
460 | 460 | } |
@@ -469,24 +469,24 @@ discard block |
||
469 | 469 | * @return Array the spotter information |
470 | 470 | * |
471 | 471 | */ |
472 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
472 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
473 | 473 | { |
474 | 474 | global $globalDBdriver, $globalLiveInterval; |
475 | 475 | date_default_timezone_set('UTC'); |
476 | 476 | |
477 | 477 | $filter_query = ''; |
478 | 478 | if (isset($filter['source']) && !empty($filter['source'])) { |
479 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
479 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
480 | 480 | } |
481 | 481 | // Should use spotter_output also ? |
482 | 482 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
483 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
483 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
484 | 484 | } |
485 | 485 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
486 | 486 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
487 | 487 | } |
488 | 488 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
489 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
489 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | FROM spotter_archive |
497 | 497 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
498 | 498 | */ |
499 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
499 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
500 | 500 | FROM spotter_archive_output |
501 | 501 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
502 | 502 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
512 | 512 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
513 | 513 | */ |
514 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
514 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
515 | 515 | FROM spotter_archive_output |
516 | 516 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
517 | 517 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | try { |
524 | 524 | $sth = $this->db->prepare($query); |
525 | 525 | $sth->execute(); |
526 | - } catch(PDOException $e) { |
|
526 | + } catch (PDOException $e) { |
|
527 | 527 | echo $e->getMessage(); |
528 | 528 | die; |
529 | 529 | } |
@@ -538,23 +538,23 @@ discard block |
||
538 | 538 | * @return Array the spotter information |
539 | 539 | * |
540 | 540 | */ |
541 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
541 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
542 | 542 | { |
543 | 543 | global $globalDBdriver, $globalLiveInterval; |
544 | 544 | date_default_timezone_set('UTC'); |
545 | 545 | |
546 | 546 | $filter_query = ''; |
547 | 547 | if (isset($filter['source']) && !empty($filter['source'])) { |
548 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
548 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
549 | 549 | } |
550 | 550 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
551 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
551 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
552 | 552 | } |
553 | 553 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
554 | 554 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
555 | 555 | } |
556 | 556 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
557 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
557 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | try { |
570 | 570 | $sth = $this->db->prepare($query); |
571 | 571 | $sth->execute(); |
572 | - } catch(PDOException $e) { |
|
572 | + } catch (PDOException $e) { |
|
573 | 573 | echo $e->getMessage(); |
574 | 574 | die; |
575 | 575 | } |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | * @return Array the spotter information |
590 | 590 | * |
591 | 591 | */ |
592 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
592 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
593 | 593 | { |
594 | 594 | global $globalTimezone, $globalDBdriver; |
595 | 595 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | |
612 | 612 | $q_array = explode(" ", $q); |
613 | 613 | |
614 | - foreach ($q_array as $q_item){ |
|
614 | + foreach ($q_array as $q_item) { |
|
615 | 615 | $additional_query .= " AND ("; |
616 | 616 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
617 | 617 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | |
644 | 644 | if ($registration != "") |
645 | 645 | { |
646 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
646 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
647 | 647 | if (!is_string($registration)) |
648 | 648 | { |
649 | 649 | return false; |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | |
655 | 655 | if ($aircraft_icao != "") |
656 | 656 | { |
657 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
657 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
658 | 658 | if (!is_string($aircraft_icao)) |
659 | 659 | { |
660 | 660 | return false; |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | |
666 | 666 | if ($aircraft_manufacturer != "") |
667 | 667 | { |
668 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
668 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
669 | 669 | if (!is_string($aircraft_manufacturer)) |
670 | 670 | { |
671 | 671 | return false; |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | |
687 | 687 | if ($airline_icao != "") |
688 | 688 | { |
689 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
689 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
690 | 690 | if (!is_string($airline_icao)) |
691 | 691 | { |
692 | 692 | return false; |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | |
698 | 698 | if ($airline_country != "") |
699 | 699 | { |
700 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
700 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
701 | 701 | if (!is_string($airline_country)) |
702 | 702 | { |
703 | 703 | return false; |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | if ($airline_type != "") |
710 | 710 | { |
711 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
711 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
712 | 712 | if (!is_string($airline_type)) |
713 | 713 | { |
714 | 714 | return false; |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | |
731 | 731 | if ($airport != "") |
732 | 732 | { |
733 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
733 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
734 | 734 | if (!is_string($airport)) |
735 | 735 | { |
736 | 736 | return false; |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | |
742 | 742 | if ($airport_country != "") |
743 | 743 | { |
744 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
744 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
745 | 745 | if (!is_string($airport_country)) |
746 | 746 | { |
747 | 747 | return false; |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | |
753 | 753 | if ($callsign != "") |
754 | 754 | { |
755 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
755 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
756 | 756 | if (!is_string($callsign)) |
757 | 757 | { |
758 | 758 | return false; |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | $translate = $Translation->ident2icao($callsign); |
761 | 761 | if ($translate != $callsign) { |
762 | 762 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
763 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
763 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
764 | 764 | } else { |
765 | 765 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
766 | 766 | } |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | |
770 | 770 | if ($owner != "") |
771 | 771 | { |
772 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
772 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
773 | 773 | if (!is_string($owner)) |
774 | 774 | { |
775 | 775 | return false; |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | |
781 | 781 | if ($pilot_name != "") |
782 | 782 | { |
783 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
783 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
784 | 784 | if (!is_string($pilot_name)) |
785 | 785 | { |
786 | 786 | return false; |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | |
792 | 792 | if ($pilot_id != "") |
793 | 793 | { |
794 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
794 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
795 | 795 | if (!is_string($pilot_id)) |
796 | 796 | { |
797 | 797 | return false; |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | |
803 | 803 | if ($departure_airport_route != "") |
804 | 804 | { |
805 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
805 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
806 | 806 | if (!is_string($departure_airport_route)) |
807 | 807 | { |
808 | 808 | return false; |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | |
814 | 814 | if ($arrival_airport_route != "") |
815 | 815 | { |
816 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
816 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
817 | 817 | if (!is_string($arrival_airport_route)) |
818 | 818 | { |
819 | 819 | return false; |
@@ -826,8 +826,8 @@ discard block |
||
826 | 826 | { |
827 | 827 | $altitude_array = explode(",", $altitude); |
828 | 828 | |
829 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
830 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
829 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
830 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
831 | 831 | |
832 | 832 | |
833 | 833 | if ($altitude_array[1] != "") |
@@ -845,8 +845,8 @@ discard block |
||
845 | 845 | { |
846 | 846 | $date_array = explode(",", $date_posted); |
847 | 847 | |
848 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
849 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
848 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
849 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
850 | 850 | |
851 | 851 | if ($globalTimezone != '') { |
852 | 852 | date_default_timezone_set($globalTimezone); |
@@ -878,8 +878,8 @@ discard block |
||
878 | 878 | { |
879 | 879 | $limit_array = explode(",", $limit); |
880 | 880 | |
881 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
882 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
881 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
882 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
883 | 883 | |
884 | 884 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
885 | 885 | { |
@@ -890,8 +890,8 @@ discard block |
||
890 | 890 | |
891 | 891 | |
892 | 892 | if ($origLat != "" && $origLon != "" && $dist != "") { |
893 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
894 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
893 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
894 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
895 | 895 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
896 | 896 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
897 | 897 | } else { |
@@ -908,12 +908,12 @@ discard block |
||
908 | 908 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
909 | 909 | } |
910 | 910 | |
911 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
911 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
912 | 912 | WHERE spotter_archive_output.ident <> '' |
913 | 913 | ".$additional_query." |
914 | 914 | ".$filter_query.$orderby_query; |
915 | 915 | } |
916 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
916 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
917 | 917 | |
918 | 918 | return $spotter_array; |
919 | 919 | } |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | try { |
931 | 931 | $sth = $this->db->prepare($query); |
932 | 932 | $sth->execute(); |
933 | - } catch(PDOException $e) { |
|
933 | + } catch (PDOException $e) { |
|
934 | 934 | return "error"; |
935 | 935 | } |
936 | 936 | } |
@@ -967,8 +967,8 @@ discard block |
||
967 | 967 | { |
968 | 968 | $limit_array = explode(",", $limit); |
969 | 969 | |
970 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
971 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
970 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
971 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
972 | 972 | |
973 | 973 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
974 | 974 | { |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | $query_values = array(); |
1010 | 1010 | $limit_query = ''; |
1011 | 1011 | $additional_query = ''; |
1012 | - $filter_query = $this->getFilter($filter,true,true); |
|
1012 | + $filter_query = $this->getFilter($filter, true, true); |
|
1013 | 1013 | |
1014 | 1014 | if ($owner != "") |
1015 | 1015 | { |
@@ -1026,8 +1026,8 @@ discard block |
||
1026 | 1026 | { |
1027 | 1027 | $limit_array = explode(",", $limit); |
1028 | 1028 | |
1029 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1030 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1029 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1030 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1031 | 1031 | |
1032 | 1032 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1033 | 1033 | { |
@@ -1067,7 +1067,7 @@ discard block |
||
1067 | 1067 | $query_values = array(); |
1068 | 1068 | $limit_query = ''; |
1069 | 1069 | $additional_query = ''; |
1070 | - $filter_query = $this->getFilter($filter,true,true); |
|
1070 | + $filter_query = $this->getFilter($filter, true, true); |
|
1071 | 1071 | |
1072 | 1072 | if ($pilot != "") |
1073 | 1073 | { |
@@ -1079,8 +1079,8 @@ discard block |
||
1079 | 1079 | { |
1080 | 1080 | $limit_array = explode(",", $limit); |
1081 | 1081 | |
1082 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1083 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1082 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1083 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1084 | 1084 | |
1085 | 1085 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1086 | 1086 | { |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | * @return Array the airline country list |
1111 | 1111 | * |
1112 | 1112 | */ |
1113 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1113 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1114 | 1114 | { |
1115 | 1115 | global $globalDBdriver; |
1116 | 1116 | /* |
@@ -1139,7 +1139,7 @@ discard block |
||
1139 | 1139 | $flight_array = array(); |
1140 | 1140 | $temp_array = array(); |
1141 | 1141 | |
1142 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1142 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1143 | 1143 | { |
1144 | 1144 | $temp_array['flight_count'] = $row['nb']; |
1145 | 1145 | $temp_array['flight_country'] = $row['name']; |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | * @return Array the airline country list |
1157 | 1157 | * |
1158 | 1158 | */ |
1159 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1159 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1160 | 1160 | { |
1161 | 1161 | global $globalDBdriver; |
1162 | 1162 | /* |
@@ -1185,7 +1185,7 @@ discard block |
||
1185 | 1185 | $flight_array = array(); |
1186 | 1186 | $temp_array = array(); |
1187 | 1187 | |
1188 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1188 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1189 | 1189 | { |
1190 | 1190 | $temp_array['airline_icao'] = $row['airline_icao']; |
1191 | 1191 | $temp_array['flight_count'] = $row['nb']; |
@@ -1203,14 +1203,14 @@ discard block |
||
1203 | 1203 | * @return Array the spotter information |
1204 | 1204 | * |
1205 | 1205 | */ |
1206 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1206 | + public function getDateArchiveSpotterDataById($id, $date) |
|
1207 | 1207 | { |
1208 | 1208 | $Spotter = new Spotter($this->db); |
1209 | 1209 | date_default_timezone_set('UTC'); |
1210 | 1210 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1211 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1212 | - $date = date('c',$date); |
|
1213 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1211 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1212 | + $date = date('c', $date); |
|
1213 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1214 | 1214 | return $spotter_array; |
1215 | 1215 | } |
1216 | 1216 | |
@@ -1220,14 +1220,14 @@ discard block |
||
1220 | 1220 | * @return Array the spotter information |
1221 | 1221 | * |
1222 | 1222 | */ |
1223 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1223 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
1224 | 1224 | { |
1225 | 1225 | $Spotter = new Spotter($this->db); |
1226 | 1226 | date_default_timezone_set('UTC'); |
1227 | 1227 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1228 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1229 | - $date = date('c',$date); |
|
1230 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1228 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1229 | + $date = date('c', $date); |
|
1230 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1231 | 1231 | return $spotter_array; |
1232 | 1232 | } |
1233 | 1233 | |
@@ -1237,7 +1237,7 @@ discard block |
||
1237 | 1237 | * @return Array the spotter information |
1238 | 1238 | * |
1239 | 1239 | */ |
1240 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1240 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1241 | 1241 | { |
1242 | 1242 | global $global_query; |
1243 | 1243 | $Spotter = new Spotter(); |
@@ -1245,7 +1245,7 @@ discard block |
||
1245 | 1245 | $query_values = array(); |
1246 | 1246 | $limit_query = ''; |
1247 | 1247 | $additional_query = ''; |
1248 | - $filter_query = $this->getFilter($filters,true,true); |
|
1248 | + $filter_query = $this->getFilter($filters, true, true); |
|
1249 | 1249 | |
1250 | 1250 | if ($airport != "") |
1251 | 1251 | { |
@@ -1262,8 +1262,8 @@ discard block |
||
1262 | 1262 | { |
1263 | 1263 | $limit_array = explode(",", $limit); |
1264 | 1264 | |
1265 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1266 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1265 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1266 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1267 | 1267 | |
1268 | 1268 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1269 | 1269 | { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | if (isset($this->all_tracked[$key]['id'])) { |
59 | 59 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
60 | 60 | $Marine = new Marine($this->db); |
61 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
61 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
70 | 70 | foreach ($this->all_tracked as $key => $flight) { |
71 | 71 | if (isset($flight['lastupdate'])) { |
72 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
72 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
73 | 73 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
74 | 74 | if (isset($this->all_tracked[$key]['id'])) { |
75 | 75 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | //$real_arrival = $this->arrival($key); |
82 | 82 | $Marine = new Marine($this->db); |
83 | 83 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
84 | - $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
84 | + $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
85 | 85 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
86 | 86 | } |
87 | 87 | // Put in archive |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | public function add($line) { |
98 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
|
98 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine; |
|
99 | 99 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
100 | 100 | date_default_timezone_set('UTC'); |
101 | 101 | $dataFound = false; |
102 | 102 | $send = false; |
103 | 103 | |
104 | 104 | // SBS format is CSV format |
105 | - if(is_array($line) && isset($line['mmsi'])) { |
|
105 | + if (is_array($line) && isset($line['mmsi'])) { |
|
106 | 106 | //print_r($line); |
107 | 107 | if (isset($line['mmsi'])) { |
108 | 108 | |
@@ -126,18 +126,18 @@ discard block |
||
126 | 126 | |
127 | 127 | if (!isset($this->all_tracked[$id])) { |
128 | 128 | $this->all_tracked[$id] = array(); |
129 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
130 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
131 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
129 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
130 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '')); |
|
131 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
132 | 132 | if (!isset($line['id'])) { |
133 | 133 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
135 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
135 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
136 | 136 | if ($globalAllTracked !== FALSE) $dataFound = true; |
137 | 137 | } |
138 | 138 | |
139 | 139 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
140 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
140 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
141 | 141 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
142 | 142 | $Marine = new Marine($this->db); |
143 | 143 | $identity = $Marine->getIdentity($line['mmsi']); |
@@ -151,66 +151,66 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | if (isset($line['type_id']) && $line['type_id'] != '') { |
154 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
154 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
155 | 155 | } |
156 | 156 | if (isset($line['type']) && $line['type'] != '') { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
158 | 158 | } |
159 | 159 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
160 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
160 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
161 | 161 | } |
162 | 162 | if (isset($line['imo']) && $line['imo'] != '') { |
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
164 | 164 | } |
165 | 165 | if (isset($line['callsign']) && $line['callsign'] != '') { |
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
167 | 167 | } |
168 | 168 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
170 | 170 | } |
171 | 171 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
172 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
172 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
176 | 176 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
177 | 177 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
178 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
178 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
179 | 179 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
180 | 180 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
181 | 181 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
182 | 182 | $timeelapsed = microtime(true); |
183 | 183 | $Marine = new Marine($this->db); |
184 | 184 | $fromsource = NULL; |
185 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
185 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
186 | 186 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
187 | 187 | $Marine->db = null; |
188 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
188 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
192 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
192 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | if (isset($line['speed']) && $line['speed'] != '') { |
196 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
197 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
196 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
197 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
198 | 198 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
199 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
199 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
200 | 200 | if ($distance > 1000 && $distance < 10000) { |
201 | 201 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
202 | 202 | $speed = $speed*3.6; |
203 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
203 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
204 | 204 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | 208 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
209 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
209 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
210 | 210 | else unset($timediff); |
211 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
211 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
212 | 212 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
213 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
213 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
214 | 214 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
215 | 215 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
216 | 216 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | $timeelapsed = microtime(true); |
220 | 220 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
221 | 221 | $Marine = new Marine($this->db); |
222 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
222 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
223 | 223 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
224 | 224 | $Marine->db = null; |
225 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
225 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
226 | 226 | } |
227 | 227 | $this->tmd = 0; |
228 | 228 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -231,66 +231,66 @@ discard block |
||
231 | 231 | |
232 | 232 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
233 | 233 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
234 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
234 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
235 | 235 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
236 | 236 | $dataFound = true; |
237 | 237 | $this->all_tracked[$id]['time_last_coord'] = time(); |
238 | 238 | } |
239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
240 | 240 | } |
241 | 241 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
242 | 242 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
243 | 243 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
244 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
244 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
245 | 245 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
246 | 246 | $dataFound = true; |
247 | 247 | $this->all_tracked[$id]['time_last_coord'] = time(); |
248 | 248 | } |
249 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
249 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | } else if ($globalDebug && $timediff > 20) { |
253 | 253 | $this->tmd = $this->tmd + 1; |
254 | 254 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
255 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
256 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
255 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
256 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
257 | 257 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
258 | 258 | } |
259 | 259 | } |
260 | 260 | if (isset($line['last_update']) && $line['last_update'] != '') { |
261 | 261 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
263 | 263 | } |
264 | 264 | if (isset($line['format_source']) && $line['format_source'] != '') { |
265 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
265 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
266 | 266 | } |
267 | 267 | if (isset($line['source_name']) && $line['source_name'] != '') { |
268 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
268 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
269 | 269 | } |
270 | 270 | if (isset($line['status']) && $line['status'] != '') { |
271 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
271 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
275 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
275 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | if (isset($line['heading']) && $line['heading'] != '') { |
279 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
280 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
281 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
279 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
280 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
281 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
282 | 282 | //$dataFound = true; |
283 | 283 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
284 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
285 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
286 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
284 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
285 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
286 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
287 | 287 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
288 | 288 | } |
289 | 289 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
290 | 290 | |
291 | 291 | if (isset($line['datetime'])) { |
292 | 292 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
293 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
293 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
294 | 294 | } else { |
295 | 295 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
296 | 296 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -298,14 +298,14 @@ discard block |
||
298 | 298 | } |
299 | 299 | } else { |
300 | 300 | date_default_timezone_set('UTC'); |
301 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
301 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
305 | 305 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
306 | 306 | $this->all_tracked[$id]['lastupdate'] = time(); |
307 | 307 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
308 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
308 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
309 | 309 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
310 | 310 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
311 | 311 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
@@ -313,37 +313,37 @@ discard block |
||
313 | 313 | $MarineLive = new MarineLive($this->db); |
314 | 314 | if (isset($line['id'])) { |
315 | 315 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
316 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
316 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
317 | 317 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
318 | 318 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
319 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
319 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
320 | 320 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
321 | 321 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
322 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
322 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
323 | 323 | } else $recent_ident = ''; |
324 | - $MarineLive->db=null; |
|
324 | + $MarineLive->db = null; |
|
325 | 325 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
326 | 326 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
327 | 327 | } else $recent_ident = ''; |
328 | 328 | } else { |
329 | 329 | $recent_ident = ''; |
330 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
330 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
331 | 331 | } |
332 | 332 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
333 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
333 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
334 | 334 | { |
335 | 335 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
336 | 336 | //adds the spotter data for the archive |
337 | 337 | $highlight = ''; |
338 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
338 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
339 | 339 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
340 | 340 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
341 | 341 | $timeelapsed = microtime(true); |
342 | 342 | $Marine = new Marine($this->db); |
343 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
343 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
344 | 344 | $Marine->db = null; |
345 | 345 | if ($globalDebug && isset($result)) echo $result."\n"; |
346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
346 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | /* |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
384 | 384 | $MarineLive = new MarineLive($this->db); |
385 | 385 | $MarineLive->deleteLiveMarineData(); |
386 | - $MarineLive->db=null; |
|
386 | + $MarineLive->db = null; |
|
387 | 387 | if ($globalDebug) echo " Done\n"; |
388 | 388 | } |
389 | 389 | $this->last_delete = time(); |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
395 | 395 | if (isset($globalDaemon) && !$globalDaemon) { |
396 | 396 | $Marine = new Marine($this->db); |
397 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
397 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
398 | 398 | $Marine->db = null; |
399 | 399 | } |
400 | 400 | } |
@@ -409,20 +409,20 @@ discard block |
||
409 | 409 | $ignoreImport = false; |
410 | 410 | |
411 | 411 | if (!$ignoreImport) { |
412 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
412 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
413 | 413 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
414 | 414 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
415 | 415 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
416 | 416 | $timeelapsed = microtime(true); |
417 | 417 | $MarineLive = new MarineLive($this->db); |
418 | - $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
418 | + $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
419 | 419 | $MarineLive->db = null; |
420 | 420 | if ($globalDebug) echo $result."\n"; |
421 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
421 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
425 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
425 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
426 | 426 | } |
427 | 427 | $this->all_tracked[$id]['putinarchive'] = false; |
428 | 428 | |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | |
483 | 483 | $this->all_tracked[$id]['lastupdate'] = time(); |
484 | 484 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
485 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
485 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
486 | 486 | //$this->del(); |
487 | 487 | |
488 | 488 |
@@ -16,33 +16,33 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
37 | 37 | if (isset($flt['source'])) { |
38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
39 | 39 | } else { |
40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
46 | 46 | } |
47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
72 | 72 | } |
73 | 73 | } |
74 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
74 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
75 | 75 | } |
76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
78 | 78 | } |
79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
81 | 81 | if ($filter_query_where != '') { |
82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
83 | 83 | } |
84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | if ($limit != '') |
103 | 103 | { |
104 | 104 | $limit_array = explode(',', $limit); |
105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
108 | 108 | { |
109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } else { |
127 | 127 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
128 | 128 | } |
129 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
129 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
130 | 130 | |
131 | 131 | return $spotter_array; |
132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
143 | 143 | date_default_timezone_set('UTC'); |
144 | 144 | |
145 | - $filter_query = $this->getFilter($filter,true,true); |
|
145 | + $filter_query = $this->getFilter($filter, true, true); |
|
146 | 146 | |
147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
148 | 148 | if ($globalDBdriver == 'mysql') { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | try { |
157 | 157 | $sth = $this->db->prepare($query); |
158 | 158 | $sth->execute(); |
159 | - } catch(PDOException $e) { |
|
159 | + } catch (PDOException $e) { |
|
160 | 160 | echo $e->getMessage(); |
161 | 161 | die; |
162 | 162 | } |
@@ -176,15 +176,15 @@ discard block |
||
176 | 176 | global $globalDBdriver, $globalLiveInterval; |
177 | 177 | date_default_timezone_set('UTC'); |
178 | 178 | |
179 | - $filter_query = $this->getFilter($filter,true,true); |
|
179 | + $filter_query = $this->getFilter($filter, true, true); |
|
180 | 180 | |
181 | 181 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
182 | 182 | if ($globalDBdriver == 'mysql') { |
183 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
183 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
186 | 186 | } else { |
187 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
187 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
190 | 190 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | try { |
193 | 193 | $sth = $this->db->prepare($query); |
194 | 194 | $sth->execute(); |
195 | - } catch(PDOException $e) { |
|
195 | + } catch (PDOException $e) { |
|
196 | 196 | echo $e->getMessage(); |
197 | 197 | die; |
198 | 198 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | public function getLiveMarineCount($filter = array()) |
210 | 210 | { |
211 | 211 | global $globalDBdriver, $globalLiveInterval; |
212 | - $filter_query = $this->getFilter($filter,true,true); |
|
212 | + $filter_query = $this->getFilter($filter, true, true); |
|
213 | 213 | |
214 | 214 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
215 | 215 | if ($globalDBdriver == 'mysql') { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | try { |
221 | 221 | $sth = $this->db->prepare($query); |
222 | 222 | $sth->execute(); |
223 | - } catch(PDOException $e) { |
|
223 | + } catch (PDOException $e) { |
|
224 | 224 | echo $e->getMessage(); |
225 | 225 | die; |
226 | 226 | } |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | $filter_query = $this->getFilter($filter); |
244 | 244 | |
245 | 245 | if (is_array($coord)) { |
246 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
247 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
248 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
249 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
246 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
247 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
248 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
249 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
250 | 250 | } else return array(); |
251 | 251 | if ($globalDBdriver == 'mysql') { |
252 | 252 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
@@ -271,17 +271,17 @@ discard block |
||
271 | 271 | $filter_query = $this->getFilter($filter); |
272 | 272 | |
273 | 273 | if (is_array($coord)) { |
274 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
275 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
276 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
277 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
274 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
275 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
276 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
277 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
278 | 278 | } else return array(); |
279 | 279 | if ($globalDBdriver == 'mysql') { |
280 | 280 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
281 | 281 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
282 | 282 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
283 | 283 | } else { |
284 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
284 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
285 | 285 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
286 | 286 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
287 | 287 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | if ($interval == '1m') |
331 | 331 | { |
332 | 332 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
333 | - } else if ($interval == '15m'){ |
|
333 | + } else if ($interval == '15m') { |
|
334 | 334 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
335 | 335 | } |
336 | 336 | } |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
339 | 339 | } |
340 | 340 | |
341 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
341 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
342 | 342 | WHERE marine_live.latitude <> '' |
343 | 343 | AND marine_live.longitude <> '' |
344 | 344 | ".$additional_query." |
345 | 345 | HAVING distance < :radius |
346 | 346 | ORDER BY distance"; |
347 | 347 | |
348 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
348 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
349 | 349 | |
350 | 350 | return $spotter_array; |
351 | 351 | } |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | date_default_timezone_set('UTC'); |
364 | 364 | |
365 | 365 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
366 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
366 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
367 | 367 | |
368 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
368 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
369 | 369 | |
370 | 370 | return $spotter_array; |
371 | 371 | } |
@@ -376,16 +376,16 @@ discard block |
||
376 | 376 | * @return Array the spotter information |
377 | 377 | * |
378 | 378 | */ |
379 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
379 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
380 | 380 | { |
381 | 381 | $Marine = new Marine($this->db); |
382 | 382 | date_default_timezone_set('UTC'); |
383 | 383 | |
384 | 384 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
385 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
385 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
386 | 386 | |
387 | - $date = date('c',$date); |
|
388 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
387 | + $date = date('c', $date); |
|
388 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
389 | 389 | |
390 | 390 | return $spotter_array; |
391 | 391 | } |
@@ -402,9 +402,9 @@ discard block |
||
402 | 402 | date_default_timezone_set('UTC'); |
403 | 403 | |
404 | 404 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
405 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
405 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
406 | 406 | |
407 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
407 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
408 | 408 | |
409 | 409 | return $spotter_array; |
410 | 410 | } |
@@ -415,15 +415,15 @@ discard block |
||
415 | 415 | * @return Array the spotter information |
416 | 416 | * |
417 | 417 | */ |
418 | - public function getDateLiveMarineDataById($id,$date) |
|
418 | + public function getDateLiveMarineDataById($id, $date) |
|
419 | 419 | { |
420 | 420 | $Marine = new Marine($this->db); |
421 | 421 | date_default_timezone_set('UTC'); |
422 | 422 | |
423 | 423 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
424 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
425 | - $date = date('c',$date); |
|
426 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
424 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
425 | + $date = date('c', $date); |
|
426 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
427 | 427 | |
428 | 428 | return $spotter_array; |
429 | 429 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @return Array the spotter information |
436 | 436 | * |
437 | 437 | */ |
438 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
438 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
439 | 439 | { |
440 | 440 | global $globalDBdriver, $globalLiveInterval; |
441 | 441 | date_default_timezone_set('UTC'); |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | try { |
455 | 455 | $sth = $this->db->prepare($query); |
456 | 456 | $sth->execute(array(':id' => $id)); |
457 | - } catch(PDOException $e) { |
|
457 | + } catch (PDOException $e) { |
|
458 | 458 | echo $e->getMessage(); |
459 | 459 | die; |
460 | 460 | } |
@@ -472,12 +472,12 @@ discard block |
||
472 | 472 | { |
473 | 473 | date_default_timezone_set('UTC'); |
474 | 474 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
475 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
475 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
476 | 476 | try { |
477 | 477 | |
478 | 478 | $sth = $this->db->prepare($query); |
479 | 479 | $sth->execute(array(':ident' => $ident)); |
480 | - } catch(PDOException $e) { |
|
480 | + } catch (PDOException $e) { |
|
481 | 481 | echo $e->getMessage(); |
482 | 482 | die; |
483 | 483 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | |
508 | 508 | $sth = $this->db->prepare($query); |
509 | 509 | $sth->execute(); |
510 | - } catch(PDOException $e) { |
|
510 | + } catch (PDOException $e) { |
|
511 | 511 | return "error"; |
512 | 512 | } |
513 | 513 | |
@@ -530,14 +530,14 @@ discard block |
||
530 | 530 | |
531 | 531 | $sth = $this->db->prepare($query); |
532 | 532 | $sth->execute(); |
533 | - } catch(PDOException $e) { |
|
533 | + } catch (PDOException $e) { |
|
534 | 534 | return "error"; |
535 | 535 | } |
536 | 536 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
537 | 537 | $i = 0; |
538 | - $j =0; |
|
538 | + $j = 0; |
|
539 | 539 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
540 | - foreach($all as $row) |
|
540 | + foreach ($all as $row) |
|
541 | 541 | { |
542 | 542 | $i++; |
543 | 543 | $j++; |
@@ -545,9 +545,9 @@ discard block |
||
545 | 545 | if ($globalDebug) echo "."; |
546 | 546 | try { |
547 | 547 | |
548 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
548 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
549 | 549 | $sth->execute(); |
550 | - } catch(PDOException $e) { |
|
550 | + } catch (PDOException $e) { |
|
551 | 551 | return "error"; |
552 | 552 | } |
553 | 553 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -558,9 +558,9 @@ discard block |
||
558 | 558 | if ($i > 0) { |
559 | 559 | try { |
560 | 560 | |
561 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
561 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
562 | 562 | $sth->execute(); |
563 | - } catch(PDOException $e) { |
|
563 | + } catch (PDOException $e) { |
|
564 | 564 | return "error"; |
565 | 565 | } |
566 | 566 | } |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | |
574 | 574 | $sth = $this->db->prepare($query); |
575 | 575 | $sth->execute(); |
576 | - } catch(PDOException $e) { |
|
576 | + } catch (PDOException $e) { |
|
577 | 577 | return "error"; |
578 | 578 | } |
579 | 579 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -621,13 +621,13 @@ discard block |
||
621 | 621 | public function deleteLiveMarineDataByIdent($ident) |
622 | 622 | { |
623 | 623 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
624 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
624 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
625 | 625 | |
626 | 626 | try { |
627 | 627 | |
628 | 628 | $sth = $this->db->prepare($query); |
629 | 629 | $sth->execute(array(':ident' => $ident)); |
630 | - } catch(PDOException $e) { |
|
630 | + } catch (PDOException $e) { |
|
631 | 631 | return "error"; |
632 | 632 | } |
633 | 633 | |
@@ -643,13 +643,13 @@ discard block |
||
643 | 643 | public function deleteLiveMarineDataById($id) |
644 | 644 | { |
645 | 645 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
646 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
646 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
647 | 647 | |
648 | 648 | try { |
649 | 649 | |
650 | 650 | $sth = $this->db->prepare($query); |
651 | 651 | $sth->execute(array(':id' => $id)); |
652 | - } catch(PDOException $e) { |
|
652 | + } catch (PDOException $e) { |
|
653 | 653 | return "error"; |
654 | 654 | } |
655 | 655 | |
@@ -667,13 +667,13 @@ discard block |
||
667 | 667 | { |
668 | 668 | global $globalDBdriver, $globalTimezone; |
669 | 669 | if ($globalDBdriver == 'mysql') { |
670 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
670 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
671 | 671 | WHERE marine_live.ident = :ident |
672 | 672 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
673 | 673 | AND marine_live.date < UTC_TIMESTAMP()'; |
674 | 674 | $query_data = array(':ident' => $ident); |
675 | 675 | } else { |
676 | - $query = "SELECT marine_live.ident FROM marine_live |
|
676 | + $query = "SELECT marine_live.ident FROM marine_live |
|
677 | 677 | WHERE marine_live.ident = :ident |
678 | 678 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
679 | 679 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -682,8 +682,8 @@ discard block |
||
682 | 682 | |
683 | 683 | $sth = $this->db->prepare($query); |
684 | 684 | $sth->execute($query_data); |
685 | - $ident_result=''; |
|
686 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
685 | + $ident_result = ''; |
|
686 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
687 | 687 | { |
688 | 688 | $ident_result = $row['ident']; |
689 | 689 | } |
@@ -700,13 +700,13 @@ discard block |
||
700 | 700 | { |
701 | 701 | global $globalDBdriver, $globalTimezone; |
702 | 702 | if ($globalDBdriver == 'mysql') { |
703 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
703 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
704 | 704 | WHERE marine_live.ident = :ident |
705 | 705 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
706 | 706 | // AND marine_live.date < UTC_TIMESTAMP()"; |
707 | 707 | $query_data = array(':ident' => $ident); |
708 | 708 | } else { |
709 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
709 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
710 | 710 | WHERE marine_live.ident = :ident |
711 | 711 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
712 | 712 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -715,8 +715,8 @@ discard block |
||
715 | 715 | |
716 | 716 | $sth = $this->db->prepare($query); |
717 | 717 | $sth->execute($query_data); |
718 | - $ident_result=''; |
|
719 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
718 | + $ident_result = ''; |
|
719 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
720 | 720 | { |
721 | 721 | $ident_result = $row['fammarine_id']; |
722 | 722 | } |
@@ -733,13 +733,13 @@ discard block |
||
733 | 733 | { |
734 | 734 | global $globalDBdriver, $globalTimezone; |
735 | 735 | if ($globalDBdriver == 'mysql') { |
736 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
736 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
737 | 737 | WHERE marine_live.fammarine_id = :id |
738 | 738 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
739 | 739 | // AND marine_live.date < UTC_TIMESTAMP()"; |
740 | 740 | $query_data = array(':id' => $id); |
741 | 741 | } else { |
742 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
742 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
743 | 743 | WHERE marine_live.fammarine_id = :id |
744 | 744 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
745 | 745 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -748,8 +748,8 @@ discard block |
||
748 | 748 | |
749 | 749 | $sth = $this->db->prepare($query); |
750 | 750 | $sth->execute($query_data); |
751 | - $ident_result=''; |
|
752 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
751 | + $ident_result = ''; |
|
752 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
753 | 753 | { |
754 | 754 | $ident_result = $row['fammarine_id']; |
755 | 755 | } |
@@ -766,13 +766,13 @@ discard block |
||
766 | 766 | { |
767 | 767 | global $globalDBdriver, $globalTimezone; |
768 | 768 | if ($globalDBdriver == 'mysql') { |
769 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
769 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
770 | 770 | WHERE marine_live.mmsi = :mmsi |
771 | 771 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
772 | 772 | // AND marine_live.date < UTC_TIMESTAMP()"; |
773 | 773 | $query_data = array(':mmsi' => $mmsi); |
774 | 774 | } else { |
775 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
775 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
776 | 776 | WHERE marine_live.mmsi = :mmsi |
777 | 777 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
778 | 778 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -781,8 +781,8 @@ discard block |
||
781 | 781 | |
782 | 782 | $sth = $this->db->prepare($query); |
783 | 783 | $sth->execute($query_data); |
784 | - $ident_result=''; |
|
785 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
784 | + $ident_result = ''; |
|
785 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
786 | 786 | { |
787 | 787 | $ident_result = $row['fammarine_id']; |
788 | 788 | } |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | * @return String success or false |
801 | 801 | * |
802 | 802 | */ |
803 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
803 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
804 | 804 | { |
805 | 805 | global $globalURL, $globalArchive, $globalDebug; |
806 | 806 | $Common = new Common(); |
@@ -852,36 +852,36 @@ discard block |
||
852 | 852 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
853 | 853 | |
854 | 854 | |
855 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
856 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
857 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
858 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
859 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
860 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
861 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
862 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
863 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
864 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
865 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
866 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
867 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
868 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
869 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
870 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
855 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
856 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
857 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
858 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
859 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
860 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
861 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
862 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
863 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
864 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
865 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
866 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
867 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
868 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
869 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
870 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
871 | 871 | |
872 | 872 | |
873 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
874 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
873 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
874 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
875 | 875 | if ($arrival_date == '') $arrival_date = NULL; |
876 | - $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
876 | + $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
877 | 877 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
878 | 878 | |
879 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
879 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
880 | 880 | try { |
881 | 881 | |
882 | 882 | $sth = $this->db->prepare($query); |
883 | 883 | $sth->execute($query_values); |
884 | - } catch(PDOException $e) { |
|
884 | + } catch (PDOException $e) { |
|
885 | 885 | return "error : ".$e->getMessage(); |
886 | 886 | } |
887 | 887 | /* |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | |
899 | 899 | public function getOrderBy() |
900 | 900 | { |
901 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
901 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
902 | 902 | return $orderby; |
903 | 903 | } |
904 | 904 |
@@ -16,33 +16,33 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
37 | 37 | if (isset($flt['source'])) { |
38 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
39 | 39 | } else { |
40 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
46 | 46 | } |
47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
72 | 72 | } |
73 | 73 | } |
74 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
74 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
75 | 75 | } |
76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
78 | 78 | } |
79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
81 | 81 | if ($filter_query_where != '') { |
82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
83 | 83 | } |
84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | if ($limit != '') |
103 | 103 | { |
104 | 104 | $limit_array = explode(',', $limit); |
105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
108 | 108 | { |
109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } else { |
127 | 127 | $query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query; |
128 | 128 | } |
129 | - $spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true); |
|
129 | + $spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true); |
|
130 | 130 | |
131 | 131 | return $spotter_array; |
132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
143 | 143 | date_default_timezone_set('UTC'); |
144 | 144 | |
145 | - $filter_query = $this->getFilter($filter,true,true); |
|
145 | + $filter_query = $this->getFilter($filter, true, true); |
|
146 | 146 | |
147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
148 | 148 | if ($globalDBdriver == 'mysql') { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | try { |
161 | 161 | $sth = $this->db->prepare($query); |
162 | 162 | $sth->execute(); |
163 | - } catch(PDOException $e) { |
|
163 | + } catch (PDOException $e) { |
|
164 | 164 | echo $e->getMessage(); |
165 | 165 | die; |
166 | 166 | } |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | global $globalDBdriver, $globalLiveInterval; |
181 | 181 | date_default_timezone_set('UTC'); |
182 | 182 | |
183 | - $filter_query = $this->getFilter($filter,true,true); |
|
183 | + $filter_query = $this->getFilter($filter, true, true); |
|
184 | 184 | |
185 | 185 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
186 | 186 | if ($globalDBdriver == 'mysql') { |
187 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
187 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
188 | 188 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
189 | 189 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
190 | 190 | } else { |
191 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
191 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
192 | 192 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
193 | 193 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
194 | 194 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $this->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | echo $e->getMessage(); |
201 | 201 | die; |
202 | 202 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | public function getLiveTrackerCount($filter = array()) |
214 | 214 | { |
215 | 215 | global $globalDBdriver, $globalLiveInterval; |
216 | - $filter_query = $this->getFilter($filter,true,true); |
|
216 | + $filter_query = $this->getFilter($filter, true, true); |
|
217 | 217 | |
218 | 218 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
219 | 219 | if ($globalDBdriver == 'mysql') { |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | try { |
225 | 225 | $sth = $this->db->prepare($query); |
226 | 226 | $sth->execute(); |
227 | - } catch(PDOException $e) { |
|
227 | + } catch (PDOException $e) { |
|
228 | 228 | echo $e->getMessage(); |
229 | 229 | die; |
230 | 230 | } |
@@ -247,10 +247,10 @@ discard block |
||
247 | 247 | $filter_query = $this->getFilter($filter); |
248 | 248 | |
249 | 249 | if (is_array($coord)) { |
250 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
251 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
252 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
253 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
250 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
251 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
252 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
253 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
254 | 254 | } else return array(); |
255 | 255 | if ($globalDBdriver == 'mysql') { |
256 | 256 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
@@ -275,17 +275,17 @@ discard block |
||
275 | 275 | $filter_query = $this->getFilter($filter); |
276 | 276 | |
277 | 277 | if (is_array($coord)) { |
278 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
279 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
280 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
281 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
278 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
279 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
280 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
281 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
282 | 282 | } else return array(); |
283 | 283 | if ($globalDBdriver == 'mysql') { |
284 | 284 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
285 | 285 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
286 | 286 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
287 | 287 | } else { |
288 | - $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
288 | + $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
289 | 289 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date l.latitude BETWEEN ".$minlat." AND ".$maxlat." AND l.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query." tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'"; |
290 | 290 | } |
291 | 291 | $spotter_array = $Spotter->getDataFromDB($query); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | if ($interval == '1m') |
334 | 334 | { |
335 | 335 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
336 | - } else if ($interval == '15m'){ |
|
336 | + } else if ($interval == '15m') { |
|
337 | 337 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
338 | 338 | } |
339 | 339 | } |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
342 | 342 | } |
343 | 343 | |
344 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
344 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
345 | 345 | WHERE tracker_live.latitude <> '' |
346 | 346 | AND tracker_live.longitude <> '' |
347 | 347 | ".$additional_query." |
348 | 348 | HAVING distance < :radius |
349 | 349 | ORDER BY distance"; |
350 | 350 | |
351 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
351 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
352 | 352 | |
353 | 353 | return $spotter_array; |
354 | 354 | } |
@@ -366,9 +366,9 @@ discard block |
||
366 | 366 | date_default_timezone_set('UTC'); |
367 | 367 | |
368 | 368 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
369 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
369 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
370 | 370 | |
371 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
371 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
372 | 372 | |
373 | 373 | return $spotter_array; |
374 | 374 | } |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | * @return Array the spotter information |
380 | 380 | * |
381 | 381 | */ |
382 | - public function getDateLiveTrackerDataByIdent($ident,$date) |
|
382 | + public function getDateLiveTrackerDataByIdent($ident, $date) |
|
383 | 383 | { |
384 | 384 | $Tracker = new Tracker($this->db); |
385 | 385 | date_default_timezone_set('UTC'); |
386 | 386 | |
387 | 387 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
388 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
388 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
389 | 389 | |
390 | - $date = date('c',$date); |
|
391 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
390 | + $date = date('c', $date); |
|
391 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
392 | 392 | |
393 | 393 | return $spotter_array; |
394 | 394 | } |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | date_default_timezone_set('UTC'); |
406 | 406 | |
407 | 407 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
408 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
408 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
409 | 409 | |
410 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
|
410 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true); |
|
411 | 411 | |
412 | 412 | return $spotter_array; |
413 | 413 | } |
@@ -418,15 +418,15 @@ discard block |
||
418 | 418 | * @return Array the spotter information |
419 | 419 | * |
420 | 420 | */ |
421 | - public function getDateLiveTrackerDataById($id,$date) |
|
421 | + public function getDateLiveTrackerDataById($id, $date) |
|
422 | 422 | { |
423 | 423 | $Tracker = new Tracker($this->db); |
424 | 424 | date_default_timezone_set('UTC'); |
425 | 425 | |
426 | 426 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
427 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
428 | - $date = date('c',$date); |
|
429 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
427 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
428 | + $date = date('c', $date); |
|
429 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
430 | 430 | |
431 | 431 | return $spotter_array; |
432 | 432 | } |
@@ -443,13 +443,13 @@ discard block |
||
443 | 443 | date_default_timezone_set('UTC'); |
444 | 444 | |
445 | 445 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
446 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
446 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
447 | 447 | |
448 | 448 | try { |
449 | 449 | |
450 | 450 | $sth = $this->db->prepare($query); |
451 | 451 | $sth->execute(array(':ident' => $ident)); |
452 | - } catch(PDOException $e) { |
|
452 | + } catch (PDOException $e) { |
|
453 | 453 | echo $e->getMessage(); |
454 | 454 | die; |
455 | 455 | } |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | * @return Array the spotter information |
465 | 465 | * |
466 | 466 | */ |
467 | - public function getAllLiveTrackerDataById($id,$liveinterval = false) |
|
467 | + public function getAllLiveTrackerDataById($id, $liveinterval = false) |
|
468 | 468 | { |
469 | 469 | global $globalDBdriver, $globalLiveInterval; |
470 | 470 | date_default_timezone_set('UTC'); |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | try { |
484 | 484 | $sth = $this->db->prepare($query); |
485 | 485 | $sth->execute(array(':id' => $id)); |
486 | - } catch(PDOException $e) { |
|
486 | + } catch (PDOException $e) { |
|
487 | 487 | echo $e->getMessage(); |
488 | 488 | die; |
489 | 489 | } |
@@ -501,12 +501,12 @@ discard block |
||
501 | 501 | { |
502 | 502 | date_default_timezone_set('UTC'); |
503 | 503 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
504 | - $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
504 | + $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
505 | 505 | try { |
506 | 506 | |
507 | 507 | $sth = $this->db->prepare($query); |
508 | 508 | $sth->execute(array(':ident' => $ident)); |
509 | - } catch(PDOException $e) { |
|
509 | + } catch (PDOException $e) { |
|
510 | 510 | echo $e->getMessage(); |
511 | 511 | die; |
512 | 512 | } |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | |
537 | 537 | $sth = $this->db->prepare($query); |
538 | 538 | $sth->execute(); |
539 | - } catch(PDOException $e) { |
|
539 | + } catch (PDOException $e) { |
|
540 | 540 | return "error"; |
541 | 541 | } |
542 | 542 | |
@@ -559,14 +559,14 @@ discard block |
||
559 | 559 | |
560 | 560 | $sth = $this->db->prepare($query); |
561 | 561 | $sth->execute(); |
562 | - } catch(PDOException $e) { |
|
562 | + } catch (PDOException $e) { |
|
563 | 563 | return "error"; |
564 | 564 | } |
565 | 565 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
566 | 566 | $i = 0; |
567 | - $j =0; |
|
567 | + $j = 0; |
|
568 | 568 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
569 | - foreach($all as $row) |
|
569 | + foreach ($all as $row) |
|
570 | 570 | { |
571 | 571 | $i++; |
572 | 572 | $j++; |
@@ -574,9 +574,9 @@ discard block |
||
574 | 574 | if ($globalDebug) echo "."; |
575 | 575 | try { |
576 | 576 | |
577 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
577 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
578 | 578 | $sth->execute(); |
579 | - } catch(PDOException $e) { |
|
579 | + } catch (PDOException $e) { |
|
580 | 580 | return "error"; |
581 | 581 | } |
582 | 582 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | if ($i > 0) { |
588 | 588 | try { |
589 | 589 | |
590 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
590 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error"; |
594 | 594 | } |
595 | 595 | } |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | |
603 | 603 | $sth = $this->db->prepare($query); |
604 | 604 | $sth->execute(); |
605 | - } catch(PDOException $e) { |
|
605 | + } catch (PDOException $e) { |
|
606 | 606 | return "error"; |
607 | 607 | } |
608 | 608 | /* $query_delete = "DELETE FROM tracker_live WHERE famtrackid IN ("; |
@@ -650,13 +650,13 @@ discard block |
||
650 | 650 | public function deleteLiveTrackerDataByIdent($ident) |
651 | 651 | { |
652 | 652 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
653 | - $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
653 | + $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
654 | 654 | |
655 | 655 | try { |
656 | 656 | |
657 | 657 | $sth = $this->db->prepare($query); |
658 | 658 | $sth->execute(array(':ident' => $ident)); |
659 | - } catch(PDOException $e) { |
|
659 | + } catch (PDOException $e) { |
|
660 | 660 | return "error"; |
661 | 661 | } |
662 | 662 | |
@@ -672,13 +672,13 @@ discard block |
||
672 | 672 | public function deleteLiveTrackerDataById($id) |
673 | 673 | { |
674 | 674 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
675 | - $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
675 | + $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
676 | 676 | |
677 | 677 | try { |
678 | 678 | |
679 | 679 | $sth = $this->db->prepare($query); |
680 | 680 | $sth->execute(array(':id' => $id)); |
681 | - } catch(PDOException $e) { |
|
681 | + } catch (PDOException $e) { |
|
682 | 682 | return "error"; |
683 | 683 | } |
684 | 684 | |
@@ -696,13 +696,13 @@ discard block |
||
696 | 696 | { |
697 | 697 | global $globalDBdriver, $globalTimezone; |
698 | 698 | if ($globalDBdriver == 'mysql') { |
699 | - $query = 'SELECT tracker_live.ident FROM tracker_live |
|
699 | + $query = 'SELECT tracker_live.ident FROM tracker_live |
|
700 | 700 | WHERE tracker_live.ident = :ident |
701 | 701 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
702 | 702 | AND tracker_live.date < UTC_TIMESTAMP()'; |
703 | 703 | $query_data = array(':ident' => $ident); |
704 | 704 | } else { |
705 | - $query = "SELECT tracker_live.ident FROM tracker_live |
|
705 | + $query = "SELECT tracker_live.ident FROM tracker_live |
|
706 | 706 | WHERE tracker_live.ident = :ident |
707 | 707 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
708 | 708 | AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -711,8 +711,8 @@ discard block |
||
711 | 711 | |
712 | 712 | $sth = $this->db->prepare($query); |
713 | 713 | $sth->execute($query_data); |
714 | - $ident_result=''; |
|
715 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
714 | + $ident_result = ''; |
|
715 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
716 | 716 | { |
717 | 717 | $ident_result = $row['ident']; |
718 | 718 | } |
@@ -729,13 +729,13 @@ discard block |
||
729 | 729 | { |
730 | 730 | global $globalDBdriver, $globalTimezone; |
731 | 731 | if ($globalDBdriver == 'mysql') { |
732 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
732 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
733 | 733 | WHERE tracker_live.ident = :ident |
734 | 734 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
735 | 735 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
736 | 736 | $query_data = array(':ident' => $ident); |
737 | 737 | } else { |
738 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
738 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
739 | 739 | WHERE tracker_live.ident = :ident |
740 | 740 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
741 | 741 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -744,8 +744,8 @@ discard block |
||
744 | 744 | |
745 | 745 | $sth = $this->db->prepare($query); |
746 | 746 | $sth->execute($query_data); |
747 | - $ident_result=''; |
|
748 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
747 | + $ident_result = ''; |
|
748 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
749 | 749 | { |
750 | 750 | $ident_result = $row['famtrackid']; |
751 | 751 | } |
@@ -762,13 +762,13 @@ discard block |
||
762 | 762 | { |
763 | 763 | global $globalDBdriver, $globalTimezone; |
764 | 764 | if ($globalDBdriver == 'mysql') { |
765 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
765 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
766 | 766 | WHERE tracker_live.famtrackid = :id |
767 | 767 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
768 | 768 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
769 | 769 | $query_data = array(':id' => $id); |
770 | 770 | } else { |
771 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
771 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
772 | 772 | WHERE tracker_live.famtrackid = :id |
773 | 773 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
774 | 774 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | |
778 | 778 | $sth = $this->db->prepare($query); |
779 | 779 | $sth->execute($query_data); |
780 | - $ident_result=''; |
|
781 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
780 | + $ident_result = ''; |
|
781 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
782 | 782 | { |
783 | 783 | $ident_result = $row['famtrackid']; |
784 | 784 | } |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | * @return String success or false |
797 | 797 | * |
798 | 798 | */ |
799 | - public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
799 | + public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
800 | 800 | { |
801 | 801 | global $globalURL, $globalArchive, $globalDebug; |
802 | 802 | $Common = new Common(); |
@@ -855,31 +855,31 @@ discard block |
||
855 | 855 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
856 | 856 | |
857 | 857 | |
858 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
859 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
860 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
861 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
862 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
863 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
864 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
865 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
866 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
867 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
868 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
869 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
870 | - |
|
871 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
872 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
858 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
859 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
860 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
861 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
862 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
863 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
864 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
865 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
866 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
867 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
868 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
869 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
870 | + |
|
871 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
872 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
873 | 873 | |
874 | - $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
874 | + $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
875 | 875 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
876 | 876 | |
877 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type); |
|
877 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type); |
|
878 | 878 | try { |
879 | 879 | |
880 | 880 | $sth = $this->db->prepare($query); |
881 | 881 | $sth->execute($query_values); |
882 | - } catch(PDOException $e) { |
|
882 | + } catch (PDOException $e) { |
|
883 | 883 | return "error : ".$e->getMessage(); |
884 | 884 | } |
885 | 885 | /* |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | |
897 | 897 | public function getOrderBy() |
898 | 898 | { |
899 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
899 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
900 | 900 | return $orderby; |
901 | 901 | } |
902 | 902 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
4 | 4 | |
5 | -class Marine{ |
|
5 | +class Marine { |
|
6 | 6 | public $db; |
7 | 7 | |
8 | 8 | public function __construct($dbc = null) { |
@@ -16,33 +16,33 @@ discard block |
||
16 | 16 | * @return Array the SQL part |
17 | 17 | */ |
18 | 18 | |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
37 | 37 | if (isset($flt['source'])) { |
38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
39 | 39 | } else { |
40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
46 | 46 | } |
47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
72 | 72 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
73 | 73 | if ($filter_query_where != '') { |
74 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
74 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
75 | 75 | } |
76 | 76 | $filter_query = $filter_query_join.$filter_query_where; |
77 | 77 | return $filter_query; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return Array the spotter information |
87 | 87 | * |
88 | 88 | */ |
89 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
89 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
90 | 90 | { |
91 | 91 | date_default_timezone_set('UTC'); |
92 | 92 | if (!is_string($query)) |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | $sth = $this->db->prepare($query.$limitQuery); |
107 | 107 | $sth->execute($params); |
108 | 108 | } catch (PDOException $e) { |
109 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
109 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
110 | 110 | exit(); |
111 | 111 | } |
112 | 112 | |
113 | 113 | $num_rows = 0; |
114 | 114 | $spotter_array = array(); |
115 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
115 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
116 | 116 | { |
117 | 117 | $num_rows++; |
118 | 118 | $temp_array = array(); |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | } |
144 | 144 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
145 | 145 | |
146 | - if($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) |
|
146 | + if ($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) |
|
147 | 147 | { |
148 | 148 | $Image = new Image($this->db); |
149 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
149 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
150 | 150 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
151 | 151 | unset($Image); |
152 | 152 | if (count($image_array) > 0) { |
@@ -182,17 +182,17 @@ discard block |
||
182 | 182 | { |
183 | 183 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
184 | 184 | } else { |
185 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
185 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
186 | 186 | } |
187 | 187 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
188 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
189 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
188 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
189 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
190 | 190 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
191 | 191 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
192 | 192 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
193 | 193 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
194 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
195 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
194 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
195 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
196 | 196 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
197 | 197 | } |
198 | 198 | } |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | { |
230 | 230 | $limit_array = explode(",", $limit); |
231 | 231 | |
232 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
233 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
232 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
233 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
234 | 234 | |
235 | 235 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
236 | 236 | { |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | $orderby_query = " ORDER BY marine_output.date DESC"; |
248 | 248 | } |
249 | 249 | |
250 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
250 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
251 | 251 | |
252 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
252 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
253 | 253 | |
254 | 254 | return $spotter_array; |
255 | 255 | } |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | if ($id == '') return array(); |
269 | 269 | $additional_query = "marine_output.fammarine_id = :id"; |
270 | 270 | $query_values = array(':id' => $id); |
271 | - $query = $global_query." WHERE ".$additional_query." "; |
|
272 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
271 | + $query = $global_query." WHERE ".$additional_query." "; |
|
272 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
273 | 273 | return $spotter_array; |
274 | 274 | } |
275 | 275 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $query_values = array(); |
289 | 289 | $limit_query = ''; |
290 | 290 | $additional_query = ''; |
291 | - $filter_query = $this->getFilter($filter,true,true); |
|
291 | + $filter_query = $this->getFilter($filter, true, true); |
|
292 | 292 | if ($ident != "") |
293 | 293 | { |
294 | 294 | if (!is_string($ident)) |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | { |
305 | 305 | $limit_array = explode(",", $limit); |
306 | 306 | |
307 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
308 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
307 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
308 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
309 | 309 | |
310 | 310 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
311 | 311 | { |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | return $spotter_array; |
330 | 330 | } |
331 | 331 | |
332 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
332 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
333 | 333 | { |
334 | 334 | global $global_query, $globalTimezone, $globalDBdriver; |
335 | 335 | |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $limit_query = ''; |
338 | 338 | $additional_query = ''; |
339 | 339 | |
340 | - $filter_query = $this->getFilter($filter,true,true); |
|
340 | + $filter_query = $this->getFilter($filter, true, true); |
|
341 | 341 | |
342 | 342 | if ($date != "") |
343 | 343 | { |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | { |
364 | 364 | $limit_array = explode(",", $limit); |
365 | 365 | |
366 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
367 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
366 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
367 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
368 | 368 | |
369 | 369 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
370 | 370 | { |
@@ -395,11 +395,11 @@ discard block |
||
395 | 395 | * @return Array list of source name |
396 | 396 | * |
397 | 397 | */ |
398 | - public function getAllSourceName($type = '',$filters = array()) |
|
398 | + public function getAllSourceName($type = '', $filters = array()) |
|
399 | 399 | { |
400 | - $filter_query = $this->getFilter($filters,true,true); |
|
400 | + $filter_query = $this->getFilter($filters, true, true); |
|
401 | 401 | $query_values = array(); |
402 | - $query = "SELECT DISTINCT marine_output.source_name |
|
402 | + $query = "SELECT DISTINCT marine_output.source_name |
|
403 | 403 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
404 | 404 | if ($type != '') { |
405 | 405 | $query_values = array(':type' => $type); |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | $source_array = array(); |
415 | 415 | $temp_array = array(); |
416 | 416 | |
417 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
417 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
418 | 418 | { |
419 | 419 | $temp_array['source_name'] = $row['source_name']; |
420 | 420 | $source_array[] = $temp_array; |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | */ |
432 | 432 | public function getAllIdents($filters = array()) |
433 | 433 | { |
434 | - $filter_query = $this->getFilter($filters,true,true); |
|
435 | - $query = "SELECT DISTINCT marine_output.ident |
|
434 | + $filter_query = $this->getFilter($filters, true, true); |
|
435 | + $query = "SELECT DISTINCT marine_output.ident |
|
436 | 436 | FROM marine_output".$filter_query." marine_output.ident <> '' |
437 | 437 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
438 | 438 | |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | $ident_array = array(); |
443 | 443 | $temp_array = array(); |
444 | 444 | |
445 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
445 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
446 | 446 | { |
447 | 447 | $temp_array['ident'] = $row['ident']; |
448 | 448 | $ident_array[] = $temp_array; |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function getIdentity($mmsi) |
461 | 461 | { |
462 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
462 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
463 | 463 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
464 | 464 | $sth = $this->db->prepare($query); |
465 | 465 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | } else $offset = '+00:00'; |
485 | 485 | |
486 | 486 | if ($globalDBdriver == 'mysql') { |
487 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
487 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
488 | 488 | FROM marine_output |
489 | 489 | WHERE marine_output.date <> '' |
490 | 490 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
491 | 491 | } else { |
492 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
492 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
493 | 493 | FROM marine_output |
494 | 494 | WHERE marine_output.date <> '' |
495 | 495 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | $date_array = array(); |
502 | 502 | $temp_array = array(); |
503 | 503 | |
504 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
504 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
505 | 505 | { |
506 | 506 | $temp_array['date'] = $row['date']; |
507 | 507 | |
@@ -520,11 +520,11 @@ discard block |
||
520 | 520 | * @return String success or false |
521 | 521 | * |
522 | 522 | */ |
523 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
523 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
524 | 524 | { |
525 | 525 | |
526 | 526 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
527 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
527 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
528 | 528 | |
529 | 529 | try { |
530 | 530 | $sth = $this->db->prepare($query); |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
548 | 548 | { |
549 | 549 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
550 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
550 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
551 | 551 | |
552 | 552 | try { |
553 | 553 | $sth = $this->db->prepare($query); |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | * @param String $verticalrate vertival rate of flight |
586 | 586 | * @return String success or false |
587 | 587 | */ |
588 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '') |
|
588 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $format_source = '', $source_name = '') |
|
589 | 589 | { |
590 | 590 | global $globalURL, $globalMarineImageFetch; |
591 | 591 | |
@@ -652,31 +652,31 @@ discard block |
||
652 | 652 | } |
653 | 653 | |
654 | 654 | |
655 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
655 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
656 | 656 | { |
657 | 657 | $date = date("Y-m-d H:i:s", time()); |
658 | 658 | } |
659 | 659 | |
660 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
661 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
662 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
663 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
664 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
665 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
666 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
667 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
668 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
669 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
670 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
671 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
672 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
673 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
660 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
661 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
662 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
663 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
664 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
665 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
666 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
667 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
668 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
669 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
670 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
671 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
672 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
673 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
674 | 674 | |
675 | 675 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
676 | 676 | $Image = new Image($this->db); |
677 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
677 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
678 | 678 | if (!isset($image_array[0]['mmsi'])) { |
679 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
679 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
680 | 680 | } |
681 | 681 | unset($Image); |
682 | 682 | } |
@@ -688,10 +688,10 @@ discard block |
||
688 | 688 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
689 | 689 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
690 | 690 | if ($arrival_date == '') $arrival_date = NULL; |
691 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
691 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
692 | 692 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
693 | 693 | |
694 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
694 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
695 | 695 | try { |
696 | 696 | |
697 | 697 | $sth = $this->db->prepare($query); |
@@ -716,13 +716,13 @@ discard block |
||
716 | 716 | { |
717 | 717 | global $globalDBdriver, $globalTimezone; |
718 | 718 | if ($globalDBdriver == 'mysql') { |
719 | - $query = "SELECT marine_output.ident FROM marine_output |
|
719 | + $query = "SELECT marine_output.ident FROM marine_output |
|
720 | 720 | WHERE marine_output.ident = :ident |
721 | 721 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
722 | 722 | AND marine_output.date < UTC_TIMESTAMP()"; |
723 | 723 | $query_data = array(':ident' => $ident); |
724 | 724 | } else { |
725 | - $query = "SELECT marine_output.ident FROM marine_output |
|
725 | + $query = "SELECT marine_output.ident FROM marine_output |
|
726 | 726 | WHERE marine_output.ident = :ident |
727 | 727 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
728 | 728 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -731,8 +731,8 @@ discard block |
||
731 | 731 | |
732 | 732 | $sth = $this->db->prepare($query); |
733 | 733 | $sth->execute($query_data); |
734 | - $ident_result=''; |
|
735 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
734 | + $ident_result = ''; |
|
735 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
736 | 736 | { |
737 | 737 | $ident_result = $row['ident']; |
738 | 738 | } |
@@ -758,8 +758,8 @@ discard block |
||
758 | 758 | return false; |
759 | 759 | } else { |
760 | 760 | $q_array = explode(" ", $q); |
761 | - foreach ($q_array as $q_item){ |
|
762 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
761 | + foreach ($q_array as $q_item) { |
|
762 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
763 | 763 | $additional_query .= " AND ("; |
764 | 764 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
765 | 765 | $additional_query .= ")"; |
@@ -767,11 +767,11 @@ discard block |
||
767 | 767 | } |
768 | 768 | } |
769 | 769 | if ($globalDBdriver == 'mysql') { |
770 | - $query = "SELECT marine_output.* FROM marine_output |
|
770 | + $query = "SELECT marine_output.* FROM marine_output |
|
771 | 771 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
772 | 772 | AND marine_output.date < UTC_TIMESTAMP()"; |
773 | 773 | } else { |
774 | - $query = "SELECT marine_output.* FROM marine_output |
|
774 | + $query = "SELECT marine_output.* FROM marine_output |
|
775 | 775 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
776 | 776 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
777 | 777 | } |
@@ -844,11 +844,11 @@ discard block |
||
844 | 844 | * @return Array the callsign list |
845 | 845 | * |
846 | 846 | */ |
847 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
847 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
848 | 848 | { |
849 | 849 | global $globalDBdriver; |
850 | - $filter_query = $this->getFilter($filters,true,true); |
|
851 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
850 | + $filter_query = $this->getFilter($filters, true, true); |
|
851 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
852 | 852 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
853 | 853 | if ($olderthanmonths > 0) { |
854 | 854 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -862,28 +862,28 @@ discard block |
||
862 | 862 | if ($year != '') { |
863 | 863 | if ($globalDBdriver == 'mysql') { |
864 | 864 | $query .= " AND YEAR(marine_output.date) = :year"; |
865 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
865 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
866 | 866 | } else { |
867 | 867 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
868 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
868 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
869 | 869 | } |
870 | 870 | } |
871 | 871 | if ($month != '') { |
872 | 872 | if ($globalDBdriver == 'mysql') { |
873 | 873 | $query .= " AND MONTH(marine_output.date) = :month"; |
874 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
874 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
875 | 875 | } else { |
876 | 876 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
877 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
877 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
878 | 878 | } |
879 | 879 | } |
880 | 880 | if ($day != '') { |
881 | 881 | if ($globalDBdriver == 'mysql') { |
882 | 882 | $query .= " AND DAY(marine_output.date) = :day"; |
883 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
883 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
884 | 884 | } else { |
885 | 885 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
886 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
886 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
887 | 887 | } |
888 | 888 | } |
889 | 889 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | $callsign_array = array(); |
896 | 896 | $temp_array = array(); |
897 | 897 | |
898 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
898 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
899 | 899 | { |
900 | 900 | $temp_array['callsign_icao'] = $row['ident']; |
901 | 901 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | $date_array = array(); |
948 | 948 | $temp_array = array(); |
949 | 949 | |
950 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
950 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
951 | 951 | { |
952 | 952 | $temp_array['date_name'] = $row['date_name']; |
953 | 953 | $temp_array['date_count'] = $row['date_count']; |
@@ -973,7 +973,7 @@ discard block |
||
973 | 973 | $datetime = new DateTime(); |
974 | 974 | $offset = $datetime->format('P'); |
975 | 975 | } else $offset = '+00:00'; |
976 | - $filter_query = $this->getFilter($filters,true,true); |
|
976 | + $filter_query = $this->getFilter($filters, true, true); |
|
977 | 977 | if ($globalDBdriver == 'mysql') { |
978 | 978 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
979 | 979 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | $date_array = array(); |
995 | 995 | $temp_array = array(); |
996 | 996 | |
997 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
997 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
998 | 998 | { |
999 | 999 | $temp_array['date_name'] = $row['date_name']; |
1000 | 1000 | $temp_array['date_count'] = $row['date_count']; |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | $datetime = new DateTime(); |
1020 | 1020 | $offset = $datetime->format('P'); |
1021 | 1021 | } else $offset = '+00:00'; |
1022 | - $filter_query = $this->getFilter($filters,true,true); |
|
1022 | + $filter_query = $this->getFilter($filters, true, true); |
|
1023 | 1023 | if ($globalDBdriver == 'mysql') { |
1024 | 1024 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1025 | 1025 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | $date_array = array(); |
1041 | 1041 | $temp_array = array(); |
1042 | 1042 | |
1043 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1043 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1044 | 1044 | { |
1045 | 1045 | $temp_array['date_name'] = $row['date_name']; |
1046 | 1046 | $temp_array['date_count'] = $row['date_count']; |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | $date_array = array(); |
1088 | 1088 | $temp_array = array(); |
1089 | 1089 | |
1090 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1090 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1091 | 1091 | { |
1092 | 1092 | $temp_array['month_name'] = $row['month_name']; |
1093 | 1093 | $temp_array['year_name'] = $row['year_name']; |
@@ -1116,7 +1116,7 @@ discard block |
||
1116 | 1116 | $datetime = new DateTime(); |
1117 | 1117 | $offset = $datetime->format('P'); |
1118 | 1118 | } else $offset = '+00:00'; |
1119 | - $filter_query = $this->getFilter($filters,true,true); |
|
1119 | + $filter_query = $this->getFilter($filters, true, true); |
|
1120 | 1120 | if ($globalDBdriver == 'mysql') { |
1121 | 1121 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
1122 | 1122 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | $date_array = array(); |
1138 | 1138 | $temp_array = array(); |
1139 | 1139 | |
1140 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1140 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1141 | 1141 | { |
1142 | 1142 | $temp_array['year_name'] = $row['year_name']; |
1143 | 1143 | $temp_array['month_name'] = $row['month_name']; |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | * @return Array the hour list |
1158 | 1158 | * |
1159 | 1159 | */ |
1160 | - public function countAllHours($orderby,$filters = array()) |
|
1160 | + public function countAllHours($orderby, $filters = array()) |
|
1161 | 1161 | { |
1162 | 1162 | global $globalTimezone, $globalDBdriver; |
1163 | 1163 | if ($globalTimezone != '') { |
@@ -1205,7 +1205,7 @@ discard block |
||
1205 | 1205 | $hour_array = array(); |
1206 | 1206 | $temp_array = array(); |
1207 | 1207 | |
1208 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1208 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1209 | 1209 | { |
1210 | 1210 | $temp_array['hour_name'] = $row['hour_name']; |
1211 | 1211 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1227,8 +1227,8 @@ discard block |
||
1227 | 1227 | public function countAllHoursByDate($date, $filters = array()) |
1228 | 1228 | { |
1229 | 1229 | global $globalTimezone, $globalDBdriver; |
1230 | - $filter_query = $this->getFilter($filters,true,true); |
|
1231 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1230 | + $filter_query = $this->getFilter($filters, true, true); |
|
1231 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1232 | 1232 | if ($globalTimezone != '') { |
1233 | 1233 | date_default_timezone_set($globalTimezone); |
1234 | 1234 | $datetime = new DateTime($date); |
@@ -1236,12 +1236,12 @@ discard block |
||
1236 | 1236 | } else $offset = '+00:00'; |
1237 | 1237 | |
1238 | 1238 | if ($globalDBdriver == 'mysql') { |
1239 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1239 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1240 | 1240 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
1241 | 1241 | GROUP BY hour_name |
1242 | 1242 | ORDER BY hour_name ASC"; |
1243 | 1243 | } else { |
1244 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1244 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1245 | 1245 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1246 | 1246 | GROUP BY hour_name |
1247 | 1247 | ORDER BY hour_name ASC"; |
@@ -1253,7 +1253,7 @@ discard block |
||
1253 | 1253 | $hour_array = array(); |
1254 | 1254 | $temp_array = array(); |
1255 | 1255 | |
1256 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1256 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1257 | 1257 | { |
1258 | 1258 | $temp_array['hour_name'] = $row['hour_name']; |
1259 | 1259 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1275,8 +1275,8 @@ discard block |
||
1275 | 1275 | public function countAllHoursByIdent($ident, $filters = array()) |
1276 | 1276 | { |
1277 | 1277 | global $globalTimezone, $globalDBdriver; |
1278 | - $filter_query = $this->getFilter($filters,true,true); |
|
1279 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1278 | + $filter_query = $this->getFilter($filters, true, true); |
|
1279 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1280 | 1280 | if ($globalTimezone != '') { |
1281 | 1281 | date_default_timezone_set($globalTimezone); |
1282 | 1282 | $datetime = new DateTime(); |
@@ -1284,12 +1284,12 @@ discard block |
||
1284 | 1284 | } else $offset = '+00:00'; |
1285 | 1285 | |
1286 | 1286 | if ($globalDBdriver == 'mysql') { |
1287 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1287 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1288 | 1288 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1289 | 1289 | GROUP BY hour_name |
1290 | 1290 | ORDER BY hour_name ASC"; |
1291 | 1291 | } else { |
1292 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1292 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1293 | 1293 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1294 | 1294 | GROUP BY hour_name |
1295 | 1295 | ORDER BY hour_name ASC"; |
@@ -1297,12 +1297,12 @@ discard block |
||
1297 | 1297 | |
1298 | 1298 | |
1299 | 1299 | $sth = $this->db->prepare($query); |
1300 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1300 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1301 | 1301 | |
1302 | 1302 | $hour_array = array(); |
1303 | 1303 | $temp_array = array(); |
1304 | 1304 | |
1305 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1305 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1306 | 1306 | { |
1307 | 1307 | $temp_array['hour_name'] = $row['hour_name']; |
1308 | 1308 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1321,32 +1321,32 @@ discard block |
||
1321 | 1321 | * @return Integer the number of flights |
1322 | 1322 | * |
1323 | 1323 | */ |
1324 | - public function countOverallTracked($filters = array(),$year = '',$month = '') |
|
1324 | + public function countOverallTracked($filters = array(), $year = '', $month = '') |
|
1325 | 1325 | { |
1326 | 1326 | global $globalDBdriver; |
1327 | - $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
1327 | + $queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
|
1328 | 1328 | $query_values = array(); |
1329 | 1329 | $query = ''; |
1330 | 1330 | if ($year != '') { |
1331 | 1331 | if ($globalDBdriver == 'mysql') { |
1332 | 1332 | $query .= " AND YEAR(marine_output.date) = :year"; |
1333 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1333 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1334 | 1334 | } else { |
1335 | 1335 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1336 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1336 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1337 | 1337 | } |
1338 | 1338 | } |
1339 | 1339 | if ($month != '') { |
1340 | 1340 | if ($globalDBdriver == 'mysql') { |
1341 | 1341 | $query .= " AND MONTH(marine_output.date) = :month"; |
1342 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1342 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1343 | 1343 | } else { |
1344 | 1344 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1345 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1345 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1346 | 1346 | } |
1347 | 1347 | } |
1348 | 1348 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1349 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1349 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1350 | 1350 | |
1351 | 1351 | $sth = $this->db->prepare($queryi); |
1352 | 1352 | $sth->execute($query_values); |
@@ -1363,7 +1363,7 @@ discard block |
||
1363 | 1363 | public function countAllHoursFromToday($filters = array()) |
1364 | 1364 | { |
1365 | 1365 | global $globalTimezone, $globalDBdriver; |
1366 | - $filter_query = $this->getFilter($filters,true,true); |
|
1366 | + $filter_query = $this->getFilter($filters, true, true); |
|
1367 | 1367 | if ($globalTimezone != '') { |
1368 | 1368 | date_default_timezone_set($globalTimezone); |
1369 | 1369 | $datetime = new DateTime(); |
@@ -1371,12 +1371,12 @@ discard block |
||
1371 | 1371 | } else $offset = '+00:00'; |
1372 | 1372 | |
1373 | 1373 | if ($globalDBdriver == 'mysql') { |
1374 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1374 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1375 | 1375 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
1376 | 1376 | GROUP BY hour_name |
1377 | 1377 | ORDER BY hour_name ASC"; |
1378 | 1378 | } else { |
1379 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1379 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1380 | 1380 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1381 | 1381 | GROUP BY hour_name |
1382 | 1382 | ORDER BY hour_name ASC"; |
@@ -1388,7 +1388,7 @@ discard block |
||
1388 | 1388 | $hour_array = array(); |
1389 | 1389 | $temp_array = array(); |
1390 | 1390 | |
1391 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1391 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1392 | 1392 | { |
1393 | 1393 | $temp_array['hour_name'] = $row['hour_name']; |
1394 | 1394 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1407,9 +1407,9 @@ discard block |
||
1407 | 1407 | */ |
1408 | 1408 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1409 | 1409 | { |
1410 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1410 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1411 | 1411 | |
1412 | - $query = "SELECT marine_output.marine_id |
|
1412 | + $query = "SELECT marine_output.marine_id |
|
1413 | 1413 | FROM marine_output |
1414 | 1414 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
1415 | 1415 | |
@@ -1417,7 +1417,7 @@ discard block |
||
1417 | 1417 | $sth = $this->db->prepare($query); |
1418 | 1418 | $sth->execute(); |
1419 | 1419 | |
1420 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1420 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1421 | 1421 | { |
1422 | 1422 | return $row['marine_id']; |
1423 | 1423 | } |
@@ -1442,23 +1442,23 @@ discard block |
||
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | $current_date = date("Y-m-d H:i:s"); |
1445 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1445 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1446 | 1446 | |
1447 | 1447 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1448 | 1448 | |
1449 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1449 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1450 | 1450 | $years = $time_array['years']; |
1451 | 1451 | |
1452 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1452 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1453 | 1453 | $months = $time_array['months']; |
1454 | 1454 | |
1455 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1455 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1456 | 1456 | $days = $time_array['days']; |
1457 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1457 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1458 | 1458 | $hours = $time_array['hours']; |
1459 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1459 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1460 | 1460 | $minutes = $time_array['minutes']; |
1461 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1461 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1462 | 1462 | |
1463 | 1463 | return $time_array; |
1464 | 1464 | } |
@@ -1481,63 +1481,63 @@ discard block |
||
1481 | 1481 | $temp_array['direction_degree'] = $direction; |
1482 | 1482 | $temp_array['direction_shortname'] = "N"; |
1483 | 1483 | $temp_array['direction_fullname'] = "North"; |
1484 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1484 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1485 | 1485 | $temp_array['direction_degree'] = $direction; |
1486 | 1486 | $temp_array['direction_shortname'] = "NNE"; |
1487 | 1487 | $temp_array['direction_fullname'] = "North-Northeast"; |
1488 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1488 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1489 | 1489 | $temp_array['direction_degree'] = $direction; |
1490 | 1490 | $temp_array['direction_shortname'] = "NE"; |
1491 | 1491 | $temp_array['direction_fullname'] = "Northeast"; |
1492 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1492 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1493 | 1493 | $temp_array['direction_degree'] = $direction; |
1494 | 1494 | $temp_array['direction_shortname'] = "ENE"; |
1495 | 1495 | $temp_array['direction_fullname'] = "East-Northeast"; |
1496 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1496 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1497 | 1497 | $temp_array['direction_degree'] = $direction; |
1498 | 1498 | $temp_array['direction_shortname'] = "E"; |
1499 | 1499 | $temp_array['direction_fullname'] = "East"; |
1500 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1500 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1501 | 1501 | $temp_array['direction_degree'] = $direction; |
1502 | 1502 | $temp_array['direction_shortname'] = "ESE"; |
1503 | 1503 | $temp_array['direction_fullname'] = "East-Southeast"; |
1504 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1504 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1505 | 1505 | $temp_array['direction_degree'] = $direction; |
1506 | 1506 | $temp_array['direction_shortname'] = "SE"; |
1507 | 1507 | $temp_array['direction_fullname'] = "Southeast"; |
1508 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1508 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1509 | 1509 | $temp_array['direction_degree'] = $direction; |
1510 | 1510 | $temp_array['direction_shortname'] = "SSE"; |
1511 | 1511 | $temp_array['direction_fullname'] = "South-Southeast"; |
1512 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1512 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1513 | 1513 | $temp_array['direction_degree'] = $direction; |
1514 | 1514 | $temp_array['direction_shortname'] = "S"; |
1515 | 1515 | $temp_array['direction_fullname'] = "South"; |
1516 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1516 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1517 | 1517 | $temp_array['direction_degree'] = $direction; |
1518 | 1518 | $temp_array['direction_shortname'] = "SSW"; |
1519 | 1519 | $temp_array['direction_fullname'] = "South-Southwest"; |
1520 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1520 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1521 | 1521 | $temp_array['direction_degree'] = $direction; |
1522 | 1522 | $temp_array['direction_shortname'] = "SW"; |
1523 | 1523 | $temp_array['direction_fullname'] = "Southwest"; |
1524 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1524 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1525 | 1525 | $temp_array['direction_degree'] = $direction; |
1526 | 1526 | $temp_array['direction_shortname'] = "WSW"; |
1527 | 1527 | $temp_array['direction_fullname'] = "West-Southwest"; |
1528 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1528 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1529 | 1529 | $temp_array['direction_degree'] = $direction; |
1530 | 1530 | $temp_array['direction_shortname'] = "W"; |
1531 | 1531 | $temp_array['direction_fullname'] = "West"; |
1532 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1532 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1533 | 1533 | $temp_array['direction_degree'] = $direction; |
1534 | 1534 | $temp_array['direction_shortname'] = "WNW"; |
1535 | 1535 | $temp_array['direction_fullname'] = "West-Northwest"; |
1536 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1536 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1537 | 1537 | $temp_array['direction_degree'] = $direction; |
1538 | 1538 | $temp_array['direction_shortname'] = "NW"; |
1539 | 1539 | $temp_array['direction_fullname'] = "Northwest"; |
1540 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1540 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1541 | 1541 | $temp_array['direction_degree'] = $direction; |
1542 | 1542 | $temp_array['direction_shortname'] = "NNW"; |
1543 | 1543 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1554,11 +1554,11 @@ discard block |
||
1554 | 1554 | * @param Float $longitude longitute of the flight |
1555 | 1555 | * @return String the countrie |
1556 | 1556 | */ |
1557 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1557 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1558 | 1558 | { |
1559 | 1559 | global $globalDBdriver, $globalDebug; |
1560 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1561 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1560 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1561 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1562 | 1562 | |
1563 | 1563 | $Connection = new Connection($this->db); |
1564 | 1564 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1598,7 +1598,7 @@ discard block |
||
1598 | 1598 | public function getCountryFromISO2($iso2) |
1599 | 1599 | { |
1600 | 1600 | global $globalDBdriver, $globalDebug; |
1601 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1601 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1602 | 1602 | |
1603 | 1603 | $Connection = new Connection($this->db); |
1604 | 1604 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1646,7 +1646,7 @@ discard block |
||
1646 | 1646 | |
1647 | 1647 | $bitly_data = json_decode($bitly_data); |
1648 | 1648 | $bitly_url = ''; |
1649 | - if ($bitly_data->status_txt = "OK"){ |
|
1649 | + if ($bitly_data->status_txt = "OK") { |
|
1650 | 1650 | $bitly_url = $bitly_data->data->url; |
1651 | 1651 | } |
1652 | 1652 | |
@@ -1656,7 +1656,7 @@ discard block |
||
1656 | 1656 | |
1657 | 1657 | public function getOrderBy() |
1658 | 1658 | { |
1659 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
1659 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
1660 | 1660 | |
1661 | 1661 | return $orderby; |
1662 | 1662 |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | * @return Array the images list |
18 | 18 | * |
19 | 19 | */ |
20 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
20 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
21 | 21 | { |
22 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
23 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
24 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
22 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
23 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
24 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
25 | 25 | $reg = $registration; |
26 | 26 | if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
27 | 27 | $reg = trim($reg); |
28 | - $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
28 | + $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
29 | 29 | FROM spotter_image |
30 | 30 | WHERE spotter_image.registration = :registration LIMIT 1"; |
31 | 31 | $sth = $this->db->prepare($query); |
32 | 32 | $sth->execute(array(':registration' => $reg)); |
33 | 33 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
34 | 34 | if (!empty($result)) return $result; |
35 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
35 | + elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
36 | 36 | else return array(); |
37 | 37 | } |
38 | 38 | |
@@ -42,23 +42,23 @@ discard block |
||
42 | 42 | * @return Array the images list |
43 | 43 | * |
44 | 44 | */ |
45 | - public function getMarineImage($mmsi,$imo = '',$name = '') |
|
45 | + public function getMarineImage($mmsi, $imo = '', $name = '') |
|
46 | 46 | { |
47 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
48 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
49 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
47 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
48 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
49 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
50 | 50 | $name = trim($name); |
51 | - $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
51 | + $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
52 | 52 | FROM marine_image |
53 | 53 | WHERE marine_image.mmsi = :mmsi"; |
54 | 54 | $query_data = array(':mmsi' => $mmsi); |
55 | 55 | if ($imo != '') { |
56 | 56 | $query .= " AND marine_image.imo = :imo"; |
57 | - $query_data = array_merge($query_data,array(':imo' => $imo)); |
|
57 | + $query_data = array_merge($query_data, array(':imo' => $imo)); |
|
58 | 58 | } |
59 | 59 | if ($name != '') { |
60 | 60 | $query .= " AND marine_image.name = :name"; |
61 | - $query_data = array_merge($query_data,array(':name' => $name)); |
|
61 | + $query_data = array_merge($query_data, array(':name' => $name)); |
|
62 | 62 | } |
63 | 63 | $query .= " LIMIT 1"; |
64 | 64 | $sth = $this->db->prepare($query); |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
80 | 80 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
81 | 81 | if ($copyright != '') { |
82 | - $copyright = str_replace('Copyright ','',$copyright); |
|
83 | - $copyright = str_replace('© ','',$copyright); |
|
84 | - $copyright = str_replace('(c) ','',$copyright); |
|
82 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
83 | + $copyright = str_replace('© ', '', $copyright); |
|
84 | + $copyright = str_replace('(c) ', '', $copyright); |
|
85 | 85 | } |
86 | 86 | return $copyright; |
87 | 87 | } |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | * @return String either success or error |
93 | 93 | * |
94 | 94 | */ |
95 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
95 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
96 | 96 | { |
97 | - global $globalDebug,$globalAircraftImageFetch; |
|
97 | + global $globalDebug, $globalAircraftImageFetch; |
|
98 | 98 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
99 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
99 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
100 | 100 | $registration = trim($registration); |
101 | 101 | //getting the aircraft image |
102 | 102 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
103 | 103 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
104 | 104 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
105 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
105 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
106 | 106 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
107 | 107 | if ($image_url['original'] != '') { |
108 | 108 | if ($globalDebug) echo 'Found !'."\n"; |
109 | - $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
109 | + $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
110 | 110 | try { |
111 | 111 | $sth = $this->db->prepare($query); |
112 | - $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
113 | - } catch(PDOException $e) { |
|
112 | + $sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | echo $e->getMessage()."\n"; |
115 | 115 | return "error"; |
116 | 116 | } |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * @return String either success or error |
125 | 125 | * |
126 | 126 | */ |
127 | - public function addMarineImage($mmsi,$imo = '',$name = '') |
|
127 | + public function addMarineImage($mmsi, $imo = '', $name = '') |
|
128 | 128 | { |
129 | - global $globalDebug,$globalMarineImageFetch; |
|
129 | + global $globalDebug, $globalMarineImageFetch; |
|
130 | 130 | if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
131 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
132 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
133 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
131 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
132 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
133 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
134 | 134 | $name = trim($name); |
135 | 135 | $Marine = new Marine($this->db); |
136 | 136 | if ($imo == '' || $name == '') { |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | |
145 | 145 | //getting the aircraft image |
146 | 146 | if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
147 | - $image_url = $this->findMarineImage($mmsi,$imo,$name); |
|
147 | + $image_url = $this->findMarineImage($mmsi, $imo, $name); |
|
148 | 148 | if ($image_url['original'] != '') { |
149 | 149 | if ($globalDebug) echo 'Found !'."\n"; |
150 | - $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
150 | + $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
151 | 151 | try { |
152 | 152 | $sth = $this->db->prepare($query); |
153 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
154 | - } catch(PDOException $e) { |
|
153 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
154 | + } catch (PDOException $e) { |
|
155 | 155 | echo $e->getMessage()."\n"; |
156 | 156 | return "error"; |
157 | 157 | } |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO; |
172 | 172 | $Spotter = new Spotter($this->db); |
173 | 173 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
174 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
174 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
175 | 175 | if ($aircraft_registration != '') { |
176 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
176 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
177 | 177 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
178 | 178 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
179 | 179 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -187,25 +187,25 @@ discard block |
||
187 | 187 | if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
188 | 188 | else $aircraft_name = ''; |
189 | 189 | $aircraft_registration = $aircraft_icao; |
190 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
190 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
191 | 191 | unset($Spotter); |
192 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
192 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
193 | 193 | foreach ($globalAircraftImageSources as $source) { |
194 | 194 | $source = strtolower($source); |
195 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
196 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
197 | - if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
198 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
199 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
200 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
201 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
202 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
203 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
204 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
195 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao); |
|
196 | + if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name); |
|
197 | + if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name); |
|
198 | + if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name); |
|
199 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name); |
|
200 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name); |
|
201 | + if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name); |
|
202 | + if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name); |
|
203 | + if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name); |
|
204 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name); |
|
205 | 205 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
206 | 206 | } |
207 | 207 | if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
208 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
208 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | * @return Array the aircraft thumbnail, orignal url and copyright |
218 | 218 | * |
219 | 219 | */ |
220 | - public function findMarineImage($mmsi,$imo = '',$name = '') |
|
220 | + public function findMarineImage($mmsi, $imo = '', $name = '') |
|
221 | 221 | { |
222 | 222 | global $globalMarineSources; |
223 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
224 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
225 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
223 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
224 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
225 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
226 | 226 | $name = trim($name); |
227 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
227 | + if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
228 | 228 | /* |
229 | 229 | $Marine = new Marine($this->db); |
230 | 230 | if ($imo == '' || $name == '') { |
@@ -236,17 +236,17 @@ discard block |
||
236 | 236 | } |
237 | 237 | unset($Marine); |
238 | 238 | */ |
239 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
239 | + if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing'); |
|
240 | 240 | foreach ($globalMarineImageSources as $source) { |
241 | 241 | $source = strtolower($source); |
242 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
243 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
244 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
245 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
246 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
242 | + if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name); |
|
243 | + if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name); |
|
244 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name); |
|
245 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name); |
|
246 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name); |
|
247 | 247 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
248 | 248 | } |
249 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
249 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -257,24 +257,24 @@ discard block |
||
257 | 257 | * @return Array the aircraft thumbnail, orignal url and copyright |
258 | 258 | * |
259 | 259 | */ |
260 | - public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
|
260 | + public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') { |
|
261 | 261 | $Common = new Common(); |
262 | 262 | // If aircraft registration is only number, also check with aircraft model |
263 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
264 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
263 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
264 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
265 | 265 | } else { |
266 | 266 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
267 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
267 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
268 | 268 | } |
269 | 269 | $data = $Common->getData($url); |
270 | 270 | if ($xml = simplexml_load_string($data)) { |
271 | 271 | if (isset($xml->channel->item)) { |
272 | 272 | $image_url = array(); |
273 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
273 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
274 | 274 | $image_url['thumbnail'] = $thumbnail_url; |
275 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
276 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
277 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
275 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
276 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
277 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
278 | 278 | $image_url['source'] = 'planespotters'; |
279 | 279 | return $image_url; |
280 | 280 | } |
@@ -290,29 +290,29 @@ discard block |
||
290 | 290 | * @return Array the aircraft thumbnail, orignal url and copyright |
291 | 291 | * |
292 | 292 | */ |
293 | - public function fromDeviantart($type,$registration, $name='') { |
|
293 | + public function fromDeviantart($type, $registration, $name = '') { |
|
294 | 294 | $Common = new Common(); |
295 | 295 | if ($type == 'aircraft') { |
296 | 296 | // If aircraft registration is only number, also check with aircraft model |
297 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
298 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
297 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
298 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
299 | 299 | } else { |
300 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
300 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
301 | 301 | } |
302 | 302 | } elseif ($type == 'marine') { |
303 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
303 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | $data = $Common->getData($url); |
307 | 307 | if ($xml = simplexml_load_string($data)) { |
308 | 308 | if (isset($xml->channel->item->link)) { |
309 | 309 | $image_url = array(); |
310 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
310 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
311 | 311 | $image_url['thumbnail'] = $thumbnail_url; |
312 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
312 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
313 | 313 | $image_url['original'] = $original_url; |
314 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
315 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
314 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
315 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
316 | 316 | $image_url['source'] = 'deviantart'; |
317 | 317 | return $image_url; |
318 | 318 | } |
@@ -328,32 +328,32 @@ discard block |
||
328 | 328 | * @return Array the aircraft thumbnail, orignal url and copyright |
329 | 329 | * |
330 | 330 | */ |
331 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
331 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
332 | 332 | $Common = new Common(); |
333 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
333 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
334 | 334 | $data = $Common->getData($url); |
335 | 335 | $dom = new DOMDocument(); |
336 | 336 | @$dom->loadHTML($data); |
337 | 337 | $all_pics = array(); |
338 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
338 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
339 | 339 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
340 | 340 | $all_pics[] = $image->getAttribute('src'); |
341 | 341 | } |
342 | 342 | } |
343 | 343 | $all_authors = array(); |
344 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
344 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
345 | 345 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
346 | 346 | $all_authors[] = $author->getAttribute('content'); |
347 | 347 | } |
348 | 348 | } |
349 | 349 | $all_ref = array(); |
350 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
350 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
351 | 351 | $all_ref[] = $link->getAttribute('href'); |
352 | 352 | } |
353 | 353 | if (isset($all_pics[0])) { |
354 | 354 | $image_url = array(); |
355 | 355 | $image_url['thumbnail'] = $all_pics[0]; |
356 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
356 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
357 | 357 | $image_url['copyright'] = $all_authors[0]; |
358 | 358 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
359 | 359 | $image_url['source'] = 'JetPhotos'; |
@@ -370,24 +370,24 @@ discard block |
||
370 | 370 | * @return Array the aircraft thumbnail, orignal url and copyright |
371 | 371 | * |
372 | 372 | */ |
373 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
373 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
374 | 374 | $Common = new Common(); |
375 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
375 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
376 | 376 | $data = $Common->getData($url); |
377 | 377 | $dom = new DOMDocument(); |
378 | 378 | @$dom->loadHTML($data); |
379 | 379 | $all_pics = array(); |
380 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
380 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
381 | 381 | $all_pics[] = $image->getAttribute('src'); |
382 | 382 | } |
383 | 383 | $all_links = array(); |
384 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
385 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
384 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
385 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
386 | 386 | } |
387 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
387 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
388 | 388 | $image_url = array(); |
389 | 389 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
390 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
390 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
391 | 391 | $image_url['copyright'] = $all_links[6]['text']; |
392 | 392 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
393 | 393 | $image_url['source'] = 'PlanePictures'; |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @return Array the aircraft thumbnail, orignal url and copyright |
405 | 405 | * |
406 | 406 | */ |
407 | - public function fromFlickr($type,$registration,$name='') { |
|
407 | + public function fromFlickr($type, $registration, $name = '') { |
|
408 | 408 | $Common = new Common(); |
409 | 409 | if ($type == 'aircraft') { |
410 | 410 | if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
@@ -416,12 +416,12 @@ discard block |
||
416 | 416 | $data = $Common->getData($url); |
417 | 417 | if ($xml = simplexml_load_string($data)) { |
418 | 418 | if (isset($xml->channel->item)) { |
419 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
419 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
420 | 420 | $image_url = array(); |
421 | 421 | $image_url['thumbnail'] = $original_url; |
422 | 422 | $image_url['original'] = $original_url; |
423 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
424 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
423 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
424 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
425 | 425 | $image_url['source'] = 'flickr'; |
426 | 426 | return $image_url; |
427 | 427 | } |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | return false; |
430 | 430 | } |
431 | 431 | |
432 | - public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
|
432 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
433 | 433 | $Common = new Common(); |
434 | 434 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
435 | 435 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -453,14 +453,14 @@ discard block |
||
453 | 453 | * @return Array the aircraft thumbnail, orignal url and copyright |
454 | 454 | * |
455 | 455 | */ |
456 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
456 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
457 | 457 | global $globalImageBingKey; |
458 | 458 | $Common = new Common(); |
459 | 459 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
460 | 460 | if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
461 | 461 | else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
462 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
463 | - $data = $Common->getData($url,'get','',$headers); |
|
462 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
463 | + $data = $Common->getData($url, 'get', '', $headers); |
|
464 | 464 | $result = json_decode($data); |
465 | 465 | if (isset($result->d->results[0]->MediaUrl)) { |
466 | 466 | $image_url = array(); |
@@ -485,14 +485,14 @@ discard block |
||
485 | 485 | * @return Array the aircraft thumbnail, orignal url and copyright |
486 | 486 | * |
487 | 487 | */ |
488 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
488 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
489 | 489 | $Common = new Common(); |
490 | 490 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
491 | 491 | $data = $Common->getData($url); |
492 | 492 | $result = json_decode($data); |
493 | 493 | if (isset($result->count) && $result->count > 0) { |
494 | 494 | $image_url = array(); |
495 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
495 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
496 | 496 | $image_url['source_website'] = $result->data[0]->link; |
497 | 497 | $image_url['thumbnail'] = $result->data[0]->image; |
498 | 498 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | * @return Array the aircraft thumbnail, orignal url and copyright |
511 | 511 | * |
512 | 512 | */ |
513 | - public function fromWikimedia($type,$registration,$name='') { |
|
513 | + public function fromWikimedia($type, $registration, $name = '') { |
|
514 | 514 | $Common = new Common(); |
515 | 515 | if ($type == 'aircraft') { |
516 | 516 | if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | $result = json_decode($data); |
524 | 524 | if (isset($result->query->search[0]->title)) { |
525 | 525 | $fileo = $result->query->search[0]->title; |
526 | - if (substr($fileo,-3) == 'pdf') return false; |
|
526 | + if (substr($fileo, -3) == 'pdf') return false; |
|
527 | 527 | $file = urlencode($fileo); |
528 | 528 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
529 | 529 | $data2 = $Common->getData($url2); |
@@ -548,11 +548,11 @@ discard block |
||
548 | 548 | if (isset($result2->query->pages)) { |
549 | 549 | foreach ($result2->query->pages as $page) { |
550 | 550 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
551 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
551 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
552 | 552 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
553 | 553 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
554 | 554 | } |
555 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
555 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
556 | 556 | return $image_url; |
557 | 557 | } |
558 | 558 | } |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | * @return Array the aircraft thumbnail, orignal url and copyright |
572 | 572 | * |
573 | 573 | */ |
574 | - public function fromCustomSource($type,$aircraft_registration,$aircraft_name='') { |
|
574 | + public function fromCustomSource($type, $aircraft_registration, $aircraft_name = '') { |
|
575 | 575 | global $globalAircraftImageCustomSources, $globalDebug; |
576 | 576 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
577 | 577 | if (!empty($globalAircraftImageCustomSources)) { |
@@ -588,15 +588,15 @@ discard block |
||
588 | 588 | print_r($source); |
589 | 589 | print_r($customsources); |
590 | 590 | } |
591 | - $url = str_replace('{registration}',$aircraft_registration,$source['original']); |
|
592 | - $url_thumbnail = str_replace('{registration}',$aircraft_registration,$source['thumbnail']); |
|
591 | + $url = str_replace('{registration}', $aircraft_registration, $source['original']); |
|
592 | + $url_thumbnail = str_replace('{registration}', $aircraft_registration, $source['thumbnail']); |
|
593 | 593 | if ($Common->urlexist($url)) { |
594 | 594 | $image_url = array(); |
595 | 595 | $image_url['thumbnail'] = $url_thumbnail; |
596 | 596 | $image_url['original'] = $url; |
597 | 597 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
598 | 598 | else $exifCopyright = ''; |
599 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
599 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
600 | 600 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
601 | 601 | else $image_url['copyright'] = $source['source_website']; |
602 | 602 | $image_url['source_website'] = $source['source_website']; |