@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | try { |
21 | 21 | $sth = $this->db->prepare($query); |
22 | 22 | $sth->execute(array(':name' => $name)); |
23 | - } catch(PDOException $e) { |
|
23 | + } catch (PDOException $e) { |
|
24 | 24 | echo $e->getMessage(); |
25 | 25 | } |
26 | 26 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | try { |
33 | 33 | $sth = $this->db->prepare($query); |
34 | 34 | $sth->execute(); |
35 | - } catch(PDOException $e) { |
|
35 | + } catch (PDOException $e) { |
|
36 | 36 | echo $e->getMessage(); |
37 | 37 | } |
38 | 38 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | try { |
45 | 45 | $sth = $this->db->prepare($query); |
46 | 46 | $sth->execute(); |
47 | - } catch(PDOException $e) { |
|
47 | + } catch (PDOException $e) { |
|
48 | 48 | echo $e->getMessage(); |
49 | 49 | } |
50 | 50 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | try { |
57 | 57 | $sth = $this->db->prepare($query); |
58 | 58 | $sth->execute(array(':type' => $type)); |
59 | - } catch(PDOException $e) { |
|
59 | + } catch (PDOException $e) { |
|
60 | 60 | echo $e->getMessage(); |
61 | 61 | } |
62 | 62 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -64,49 +64,49 @@ discard block |
||
64 | 64 | else return array(); |
65 | 65 | } |
66 | 66 | |
67 | - public function position_all($timestamp_begin = '',$timestamp_end = '',$second = 10) { |
|
67 | + public function position_all($timestamp_begin = '', $timestamp_end = '', $second = 10) { |
|
68 | 68 | $all_sat = $this->get_tle_names(); |
69 | 69 | $result = array(); |
70 | 70 | foreach ($all_sat as $sat) { |
71 | - $position = $this->position($sat['tle_name'],$timestamp_begin,$timestamp_end,$second); |
|
72 | - $result = array_merge($position,$result); |
|
71 | + $position = $this->position($sat['tle_name'], $timestamp_begin, $timestamp_end, $second); |
|
72 | + $result = array_merge($position, $result); |
|
73 | 73 | } |
74 | 74 | return $result; |
75 | 75 | } |
76 | 76 | |
77 | - public function position_all_type($type,$timestamp_begin = '',$timestamp_end = '',$second = 10) { |
|
77 | + public function position_all_type($type, $timestamp_begin = '', $timestamp_end = '', $second = 10) { |
|
78 | 78 | $all_sat = $this->get_tle_names_type($type); |
79 | 79 | $result = array(); |
80 | 80 | foreach ($all_sat as $sat) { |
81 | - $position = $this->position($sat['tle_name'],$timestamp_begin,$timestamp_end,$second); |
|
82 | - if (isset($position[0])) $result = array_merge($position,$result); |
|
81 | + $position = $this->position($sat['tle_name'], $timestamp_begin, $timestamp_end, $second); |
|
82 | + if (isset($position[0])) $result = array_merge($position, $result); |
|
83 | 83 | else $result[] = $position; |
84 | 84 | } |
85 | 85 | return $result; |
86 | 86 | } |
87 | 87 | |
88 | - public function position($name,$timestamp_begin = '',$timestamp_end = '',$second = 10) { |
|
88 | + public function position($name, $timestamp_begin = '', $timestamp_end = '', $second = 10) { |
|
89 | 89 | $qth = new Predict_QTH(); |
90 | 90 | $qth->lat = floatval(37.790252); |
91 | 91 | $qth->lon = floatval(-122.419968); |
92 | 92 | |
93 | 93 | $tle_file = $this->get_tle($name); |
94 | 94 | $type = $tle_file['tle_type']; |
95 | - $tle = new Predict_TLE($tle_file['tle_name'],$tle_file['tle_tle1'],$tle_file['tle_tle2']); |
|
95 | + $tle = new Predict_TLE($tle_file['tle_name'], $tle_file['tle_tle1'], $tle_file['tle_tle2']); |
|
96 | 96 | $sat = new Predict_Sat($tle); |
97 | 97 | $predict = new Predict(); |
98 | 98 | //if ($timestamp == '') $now = Predict_Time::get_current_daynum(); |
99 | 99 | if ($timestamp_begin == '') $timestamp_begin = time(); |
100 | 100 | if ($timestamp_end == '') { |
101 | 101 | $now = Predict_Time::unix2daynum($timestamp_begin); |
102 | - $predict->predict_calc($sat,$qth,$now); |
|
103 | - return array('name' => $name, 'latitude' => $sat->ssplat,'longitude' => $sat->ssplon, 'altitude' => $sat->alt,'speed' => $sat->velo*60*60,'timestamp' => $timestamp_begin,'type' => $type); |
|
102 | + $predict->predict_calc($sat, $qth, $now); |
|
103 | + return array('name' => $name, 'latitude' => $sat->ssplat, 'longitude' => $sat->ssplon, 'altitude' => $sat->alt, 'speed' => $sat->velo*60*60, 'timestamp' => $timestamp_begin, 'type' => $type); |
|
104 | 104 | } else { |
105 | 105 | $result = array(); |
106 | - for ($timestamp = $timestamp_begin; $timestamp <= $timestamp_end; $timestamp=$timestamp+$second) { |
|
106 | + for ($timestamp = $timestamp_begin; $timestamp <= $timestamp_end; $timestamp = $timestamp + $second) { |
|
107 | 107 | $now = Predict_Time::unix2daynum($timestamp); |
108 | - $predict->predict_calc($sat,$qth,$now); |
|
109 | - $result[] = array('name' => $name,'latitude' => $sat->ssplat,'longitude' => $sat->ssplon, 'altitude' => $sat->alt,'speed' => $sat->velo*60*60,'timestamp' => $timestamp,'type' => $type); |
|
108 | + $predict->predict_calc($sat, $qth, $now); |
|
109 | + $result[] = array('name' => $name, 'latitude' => $sat->ssplat, 'longitude' => $sat->ssplon, 'altitude' => $sat->alt, 'speed' => $sat->velo*60*60, 'timestamp' => $timestamp, 'type' => $type); |
|
110 | 110 | } |
111 | 111 | return $result; |
112 | 112 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | try { |
118 | 118 | $sth = $this->db->prepare($query); |
119 | 119 | $sth->execute(array(':name' => $name.'%')); |
120 | - } catch(PDOException $e) { |
|
120 | + } catch (PDOException $e) { |
|
121 | 121 | echo $e->getMessage(); |
122 | 122 | } |
123 | 123 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $sth->execute($query_values); |
146 | 146 | $launch_site_array = array(); |
147 | 147 | $temp_array = array(); |
148 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
148 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
149 | 149 | { |
150 | 150 | $temp_array['launch_site'] = $row['launch_site']; |
151 | 151 | $temp_array['launch_site_count'] = $row['launch_site_count']; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $sth->execute($query_values); |
175 | 175 | $owner_array = array(); |
176 | 176 | $temp_array = array(); |
177 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
177 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
178 | 178 | { |
179 | 179 | $temp_array['owner_name'] = $row['owner_name']; |
180 | 180 | $temp_array['owner_count'] = $row['owner_count']; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $sth->execute($query_values); |
204 | 204 | $owner_array = array(); |
205 | 205 | $temp_array = array(); |
206 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
206 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
207 | 207 | { |
208 | 208 | $temp_array['country_name'] = $row['country_name']; |
209 | 209 | $temp_array['country_count'] = $row['country_count']; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $sth->execute($query_data); |
248 | 248 | $date_array = array(); |
249 | 249 | $temp_array = array(); |
250 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
250 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
251 | 251 | { |
252 | 252 | $temp_array['year_name'] = $row['year_name']; |
253 | 253 | $temp_array['month_name'] = $row['month_name']; |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | $sth->execute($query_data); |
293 | 293 | $date_array = array(); |
294 | 294 | $temp_array = array(); |
295 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
295 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
296 | 296 | { |
297 | 297 | $temp_array['year_name'] = $row['year_name']; |
298 | 298 | $temp_array['date_count'] = $row['date_count']; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | header('Content-disposition: attachment; filename="flightairmap-sat.json"'); |
14 | 14 | } |
15 | 15 | } |
16 | -$history = urldecode(filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING)); |
|
16 | +$history = urldecode(filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING)); |
|
17 | 17 | header('Content-Type: text/javascript'); |
18 | 18 | |
19 | 19 | $begintime = microtime(true); |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | |
22 | 22 | $spotter_array = array(); |
23 | 23 | if (isset($_COOKIE['sattypes']) && $_COOKIE['sattypes'] != '') { |
24 | - $sattypes = explode(',',$_COOKIE['sattypes']); |
|
24 | + $sattypes = explode(',', $_COOKIE['sattypes']); |
|
25 | 25 | foreach ($sattypes as $sattype) { |
26 | 26 | //$spotter_array = array_merge($Satellite->position_all_type($sattype,$timeb-$globalLiveInterval,$timeb),$spotter_array); |
27 | - $spotter_array = array_merge($Satellite->position_all_type($sattype),$spotter_array); |
|
27 | + $spotter_array = array_merge($Satellite->position_all_type($sattype), $spotter_array); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | //$spotter_array = array_unique($spotter_array,SORT_REGULAR); |
38 | 38 | //print_r($spotter_array); |
39 | -$sqltime = round(microtime(true)-$begintime,2); |
|
39 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
40 | 40 | |
41 | 41 | $output = '{"type":"FeatureCollection","features":['; |
42 | 42 | if (!empty($spotter_array) && is_array($spotter_array)) |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $last_name = ''; |
45 | 45 | $coordinatearray = ''; |
46 | 46 | $timearray = array(); |
47 | - foreach($spotter_array as $spotter_item) |
|
47 | + foreach ($spotter_array as $spotter_item) |
|
48 | 48 | { |
49 | 49 | $output_data = ''; |
50 | 50 | $output_data .= '{"type":"Feature","properties":{'; |
@@ -61,14 +61,14 @@ discard block |
||
61 | 61 | } |
62 | 62 | $output_data .= '"altitude":0,'; |
63 | 63 | $output_data .= '"sqt":'.$sqltime.','; |
64 | - $nextlatlon = $Satellite->position($spotter_item['name'],time()+$globalMapRefresh+20); |
|
64 | + $nextlatlon = $Satellite->position($spotter_item['name'], time() + $globalMapRefresh + 20); |
|
65 | 65 | $nextlat = $nextlatlon['latitude']; |
66 | - if (abs($nextlat-$spotter_item['latitude']) > 90) { |
|
66 | + if (abs($nextlat - $spotter_item['latitude']) > 90) { |
|
67 | 67 | if ($spotter_item['latitude'] < 0) $nexlat = -90; |
68 | 68 | else $nexlat = 90; |
69 | 69 | } |
70 | 70 | $nextlon = $nextlatlon['longitude']; |
71 | - if (abs($nextlon-$spotter_item['longitude']) > 180) { |
|
71 | + if (abs($nextlon - $spotter_item['longitude']) > 180) { |
|
72 | 72 | if ($spotter_item['longitude'] < 0) $nextlon = -180; |
73 | 73 | else $nextlon = 180; |
74 | 74 | } |
@@ -79,27 +79,27 @@ discard block |
||
79 | 79 | $output_data .= ']}},'; |
80 | 80 | $output .= $output_data; |
81 | 81 | if ($history == $spotter_item['name']) { |
82 | - $spotter_history_array = $Satellite->position($spotter_item['name'],time()-6000,time()); |
|
82 | + $spotter_history_array = $Satellite->position($spotter_item['name'], time() - 6000, time()); |
|
83 | 83 | $spotter_history_array = array_reverse($spotter_history_array); |
84 | 84 | $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['name'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
85 | 85 | foreach ($spotter_history_array as $key => $spotter_history) { |
86 | - if ((isset($previous_lon) && abs($previous_lon-$spotter_history['longitude']) > 180) || (isset($previous_lat) && abs($previous_lat-$spotter_history['latitude']) > 90)) { |
|
86 | + if ((isset($previous_lon) && abs($previous_lon - $spotter_history['longitude']) > 180) || (isset($previous_lat) && abs($previous_lat - $spotter_history['latitude']) > 90)) { |
|
87 | 87 | break; |
88 | 88 | } |
89 | 89 | $output_history .= '['; |
90 | - $output_history .= $spotter_history['longitude'].', '; |
|
91 | - $output_history .= $spotter_history['latitude']; |
|
90 | + $output_history .= $spotter_history['longitude'].', '; |
|
91 | + $output_history .= $spotter_history['latitude']; |
|
92 | 92 | $output_history .= '],'; |
93 | 93 | $previous_lon = $spotter_history['longitude']; |
94 | 94 | $previous_lat = $spotter_history['latitude']; |
95 | 95 | } |
96 | - $output_history = substr($output_history,0,-1); |
|
96 | + $output_history = substr($output_history, 0, -1); |
|
97 | 97 | $output_history .= ']}},'; |
98 | 98 | $output .= $output_history; |
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | -if (isset($output_data)) $output = substr($output,0,-1); |
|
102 | +if (isset($output_data)) $output = substr($output, 0, -1); |
|
103 | 103 | $output .= ']}'; |
104 | 104 | print $output; |
105 | 105 | ?> |
@@ -20,17 +20,17 @@ discard block |
||
20 | 20 | |
21 | 21 | $spotter_array = array(); |
22 | 22 | if (isset($_COOKIE['sattypes']) && $_COOKIE['sattypes'] != '') { |
23 | - $sattypes = explode(',',$_COOKIE['sattypes']); |
|
23 | + $sattypes = explode(',', $_COOKIE['sattypes']); |
|
24 | 24 | foreach ($sattypes as $sattype) { |
25 | - $spotter_array = array_merge($Satellite->position_all_type($sattype,$timeb-$globalLiveInterval,$timeb),$spotter_array); |
|
25 | + $spotter_array = array_merge($Satellite->position_all_type($sattype, $timeb - $globalLiveInterval, $timeb), $spotter_array); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | if ((isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') || !isset($_COOKIE['displayiss'])) { |
29 | - $spotter_array = array_merge($Satellite->position('ISS (ZARYA)',time()-$globalLiveInterval,time()),$spotter_array); |
|
30 | - $spotter_array = array_merge($Satellite->position('TIANGONG 1',time()-$globalLiveInterval,time()),$spotter_array); |
|
31 | - $spotter_array = array_merge($Satellite->position('TIANGONG-2',time()-$globalLiveInterval,time()),$spotter_array); |
|
29 | + $spotter_array = array_merge($Satellite->position('ISS (ZARYA)', time() - $globalLiveInterval, time()), $spotter_array); |
|
30 | + $spotter_array = array_merge($Satellite->position('TIANGONG 1', time() - $globalLiveInterval, time()), $spotter_array); |
|
31 | + $spotter_array = array_merge($Satellite->position('TIANGONG-2', time() - $globalLiveInterval, time()), $spotter_array); |
|
32 | 32 | } |
33 | -$spotter_array = array_unique($spotter_array,SORT_REGULAR); |
|
33 | +$spotter_array = array_unique($spotter_array, SORT_REGULAR); |
|
34 | 34 | /* |
35 | 35 | $modelsdb = array(); |
36 | 36 | if (file_exists('models/space/space_modelsdb')) { |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | // $output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "LOOP_STOP","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
55 | 55 | |
56 | 56 | // $output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
57 | -$output .= ',"clock": {"currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
|
57 | +$output .= ',"clock": {"currentTime" : "'.date("c", time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
|
58 | 58 | //$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
59 | 59 | |
60 | 60 | // $output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
61 | 61 | $output .= '},'; |
62 | 62 | if (!empty($spotter_array) && is_array($spotter_array)) |
63 | 63 | { |
64 | - foreach($spotter_array as $spotter_item) |
|
64 | + foreach ($spotter_array as $spotter_item) |
|
65 | 65 | { |
66 | 66 | $j++; |
67 | 67 | date_default_timezone_set('UTC'); |
@@ -115,23 +115,23 @@ discard block |
||
115 | 115 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/cubiesat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
116 | 116 | } elseif ($spotter_item['name'] == 'TERRA') { |
117 | 117 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/terra.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
118 | - } elseif (strpos($spotter_item['name'],'O3B') !== false) { |
|
118 | + } elseif (strpos($spotter_item['name'], 'O3B') !== false) { |
|
119 | 119 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/o3b.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
120 | - } elseif (strpos($spotter_item['name'],'GLOBALSTAR') !== false) { |
|
120 | + } elseif (strpos($spotter_item['name'], 'GLOBALSTAR') !== false) { |
|
121 | 121 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/globalstar.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
122 | - } elseif (strpos($spotter_item['name'],'GPS') !== false) { |
|
122 | + } elseif (strpos($spotter_item['name'], 'GPS') !== false) { |
|
123 | 123 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/gps.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
124 | - } elseif (strpos($spotter_item['name'],'GENESIS') !== false) { |
|
124 | + } elseif (strpos($spotter_item['name'], 'GENESIS') !== false) { |
|
125 | 125 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/genesis.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
126 | - } elseif (strpos($spotter_item['name'],'OSCAR 7') !== false) { |
|
126 | + } elseif (strpos($spotter_item['name'], 'OSCAR 7') !== false) { |
|
127 | 127 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/oscar7.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
128 | - } elseif (strpos($spotter_item['name'],'FLOCK') !== false) { |
|
128 | + } elseif (strpos($spotter_item['name'], 'FLOCK') !== false) { |
|
129 | 129 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/cubesat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
130 | - } elseif (strpos($spotter_item['name'],'PLEIADES') !== false) { |
|
130 | + } elseif (strpos($spotter_item['name'], 'PLEIADES') !== false) { |
|
131 | 131 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/pleiades.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
132 | - } elseif (strpos($spotter_item['name'],'DUCHIFAT') !== false) { |
|
132 | + } elseif (strpos($spotter_item['name'], 'DUCHIFAT') !== false) { |
|
133 | 133 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/duchifat.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
134 | - } elseif (strpos($spotter_item['name'],'FORMOSAT-2') !== false) { |
|
134 | + } elseif (strpos($spotter_item['name'], 'FORMOSAT-2') !== false) { |
|
135 | 135 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/formosat2.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
136 | 136 | } elseif ($spotter_item['type'] == 'iridium') { |
137 | 137 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/space/iridium.glb'.'","scale" : 1.0,"minimumPixelSize": 25,"maximunPixelSize": 300 },'; |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | // $output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", '; |
154 | 154 | $output .= '"interpolationAlgorithm":"HERMITE","interpolationDegree":3,'; |
155 | 155 | $output .= '"cartographicDegrees": ['; |
156 | - $output .= '"'.date("c",$spotter_item['timestamp']).'", '; |
|
156 | + $output .= '"'.date("c", $spotter_item['timestamp']).'", '; |
|
157 | 157 | $output .= $spotter_item['longitude'].', '; |
158 | 158 | $output .= $spotter_item['latitude'].', '; |
159 | 159 | $output .= $spotter_item['altitude']*1000; |
160 | 160 | $orientation = '"orientation" : { '; |
161 | 161 | $orientation .= '"unitQuaternion": ['; |
162 | 162 | } else { |
163 | - $output .= ',"'.date("c",$spotter_item['timestamp']).'", '; |
|
163 | + $output .= ',"'.date("c", $spotter_item['timestamp']).'", '; |
|
164 | 164 | $output .= $spotter_item['longitude'].', '; |
165 | 165 | $output .= $spotter_item['latitude'].', '; |
166 | 166 | $output .= $spotter_item['altitude']*1000; |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | / @param String $source source of data |
26 | 26 | */ |
27 | 27 | |
28 | - public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
|
28 | + public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') { |
|
29 | 29 | date_default_timezone_set('UTC'); |
30 | - $date = date("Y-m-d H:i:s",time()); |
|
30 | + $date = date("Y-m-d H:i:s", time()); |
|
31 | 31 | //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
32 | 32 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
33 | 33 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
@@ -35,69 +35,69 @@ discard block |
||
35 | 35 | try { |
36 | 36 | $sth = $this->db->prepare($query); |
37 | 37 | $sth->execute($query_values); |
38 | - } catch(PDOException $e) { |
|
38 | + } catch (PDOException $e) { |
|
39 | 39 | return "error : ".$e->getMessage(); |
40 | 40 | } |
41 | 41 | if ($sth->fetchColumn() > 0) { |
42 | 42 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
43 | 43 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
44 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
44 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao); |
|
45 | 45 | } elseif ($arrival_airport_time == '') { |
46 | 46 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
47 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
47 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao); |
|
48 | 48 | } elseif ($departure_airport_time == '') { |
49 | 49 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
50 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
50 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
51 | 51 | } else { |
52 | 52 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
53 | 53 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
54 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
54 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
55 | 55 | } |
56 | 56 | try { |
57 | 57 | $sth = $this->db->prepare($query); |
58 | 58 | $sth->execute($query_values); |
59 | - } catch(PDOException $e) { |
|
59 | + } catch (PDOException $e) { |
|
60 | 60 | return "error : ".$e->getMessage(); |
61 | 61 | } |
62 | 62 | if ($sth->fetchColumn() == 0) { |
63 | 63 | //$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident'; |
64 | 64 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
65 | 65 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
66 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
66 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
67 | 67 | } elseif ($arrival_airport_time == '') { |
68 | 68 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
69 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
69 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
70 | 70 | } elseif ($departure_airport_time == '') { |
71 | 71 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
72 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
72 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
73 | 73 | } else { |
74 | 74 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
75 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
75 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
76 | 76 | } |
77 | 77 | try { |
78 | 78 | $sth = $this->db->prepare($query); |
79 | 79 | $sth->execute($query_values); |
80 | - } catch(PDOException $e) { |
|
80 | + } catch (PDOException $e) { |
|
81 | 81 | return "error : ".$e->getMessage(); |
82 | 82 | } |
83 | 83 | } else { |
84 | 84 | //$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident'; |
85 | 85 | $query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident'; |
86 | - $query_values = array(':ident' => $ident,':date' => $date); |
|
86 | + $query_values = array(':ident' => $ident, ':date' => $date); |
|
87 | 87 | try { |
88 | 88 | $sth = $this->db->prepare($query); |
89 | 89 | $sth->execute($query_values); |
90 | - } catch(PDOException $e) { |
|
90 | + } catch (PDOException $e) { |
|
91 | 91 | return "error : ".$e->getMessage(); |
92 | 92 | } |
93 | 93 | } |
94 | 94 | } else { |
95 | 95 | $query = 'INSERT INTO routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source) VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)'; |
96 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
96 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
97 | 97 | try { |
98 | 98 | $sth = $this->db->prepare($query); |
99 | 99 | $sth->execute($query_values); |
100 | - } catch(PDOException $e) { |
|
100 | + } catch (PDOException $e) { |
|
101 | 101 | return "error : ".$e->getMessage(); |
102 | 102 | } |
103 | 103 | } |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | |
107 | 107 | public function getSchedule($ident) { |
108 | 108 | $Translation = new Translation($this->db); |
109 | - $operator = $Translation->checkTranslation($ident,false); |
|
109 | + $operator = $Translation->checkTranslation($ident, false); |
|
110 | 110 | if ($ident != $operator) { |
111 | 111 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1"; |
112 | - $query_values = array(':ident' => $ident,'operator' => $operator); |
|
112 | + $query_values = array(':ident' => $ident, 'operator' => $operator); |
|
113 | 113 | } else { |
114 | 114 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1"; |
115 | 115 | $query_values = array(':ident' => $ident); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | try { |
118 | 118 | $sth = $this->db->prepare($query); |
119 | 119 | $sth->execute($query_values); |
120 | - } catch(PDOException $e) { |
|
120 | + } catch (PDOException $e) { |
|
121 | 121 | return "error : ".$e->getMessage(); |
122 | 122 | } |
123 | 123 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | try { |
142 | 142 | $sth = $this->db->prepare($query); |
143 | 143 | $sth->execute($query_values); |
144 | - } catch(PDOException $e) { |
|
144 | + } catch (PDOException $e) { |
|
145 | 145 | return "error : ".$e->getMessage(); |
146 | 146 | } |
147 | 147 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | * @param String $carrier IATA code |
157 | 157 | * @return Flight departure and arrival airports and time |
158 | 158 | */ |
159 | - private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
|
159 | + private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') { |
|
160 | 160 | $Common = new Common(); |
161 | 161 | $check_date = new Datetime($date); |
162 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
163 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
162 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
163 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
164 | 164 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
165 | 165 | $json = $Common->getData($url); |
166 | 166 | |
167 | 167 | $parsed_json = json_decode($json); |
168 | - if (property_exists($parsed_json,'errors') === false) { |
|
168 | + if (property_exists($parsed_json, 'errors') === false) { |
|
169 | 169 | //$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'}; |
170 | 170 | $originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'}; |
171 | 171 | //$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'}; |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | //$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'}; |
176 | 176 | $arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'}; |
177 | 177 | |
178 | - preg_match('/\((.*?)\)/',$originShort,$originiata); |
|
178 | + preg_match('/\((.*?)\)/', $originShort, $originiata); |
|
179 | 179 | $DepartureAirportIata = $originiata[1]; |
180 | - preg_match('/\((.*?)\)/',$destinationShort,$destinationiata); |
|
180 | + preg_match('/\((.*?)\)/', $destinationShort, $destinationiata); |
|
181 | 181 | $ArrivalAirportIata = $destinationiata[1]; |
182 | 182 | |
183 | 183 | /* |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $arrivalTime = gmdate('H:i',strtotime($arrivalTime)); |
187 | 187 | */ |
188 | 188 | |
189 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
|
189 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance'); |
|
190 | 190 | } else return array(); |
191 | 191 | } |
192 | 192 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | $Common = new Common(); |
202 | 202 | date_default_timezone_set($globalTimezone); |
203 | 203 | $check_date = new Datetime($date); |
204 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
205 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
204 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
205 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
206 | 206 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
207 | 207 | $json = $Common->getData($url); |
208 | 208 | $parsed_json = json_decode($json); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'}; |
215 | 215 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
216 | 216 | |
217 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
|
217 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet'); |
|
218 | 218 | } else return array(); |
219 | 219 | } |
220 | 220 | |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | */ |
226 | 226 | private function getRyanair($callsign) { |
227 | 227 | $Common = new Common(); |
228 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
229 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
228 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
229 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
230 | 230 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
231 | 231 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
232 | - $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
|
233 | - $json = $Common->getData($url,'post',$post,$headers); |
|
232 | + $headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post)); |
|
233 | + $json = $Common->getData($url, 'post', $post, $headers); |
|
234 | 234 | $parsed_json = json_decode($json); |
235 | 235 | if (isset($parsed_json->{'flightInfo'})) { |
236 | 236 | $flights = $parsed_json->{'flightInfo'}; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name |
240 | 240 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
241 | 241 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
242 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
242 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
243 | 243 | } else return array(); |
244 | 244 | } else return array(); |
245 | 245 | } |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | */ |
252 | 252 | private function getSwiss($callsign) { |
253 | 253 | $Common = new Common(); |
254 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
255 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
254 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
255 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
256 | 256 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
257 | 257 | $json = $Common->getData($url); |
258 | 258 | $parsed_json = json_decode($json); |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | if ($flight->{'no'} == "Vol LX ".$numvol) { |
267 | 267 | $DepartureAirportIata = $flight->{'from'}->{'code'}; //city |
268 | 268 | $ArrivalAirportIata = $flight->{'to'}->{'code'}; //city |
269 | - $departureTime = substr($flight->{'from'}->{'hour'},0,5); |
|
270 | - $arrivalTime = substr($flight->{'to'}->{'hour'},0,5); |
|
269 | + $departureTime = substr($flight->{'from'}->{'hour'},0, 5); |
|
270 | + $arrivalTime = substr($flight->{'to'}->{'hour'},0, 5); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
274 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
|
274 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss'); |
|
275 | 275 | } else return array(); |
276 | 276 | } else return array(); |
277 | 277 | } |
@@ -286,21 +286,21 @@ discard block |
||
286 | 286 | global $globalBritishAirwaysKey; |
287 | 287 | $Common = new Common(); |
288 | 288 | $check_date = new Datetime($date); |
289 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
290 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
289 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
290 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
291 | 291 | if ($globalBritishAirwaysKey == '') return array(); |
292 | 292 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
293 | 293 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
294 | - $json = $Common->getData($url,'get','',$headers); |
|
294 | + $json = $Common->getData($url, 'get', '', $headers); |
|
295 | 295 | if ($json == '') return array(); |
296 | 296 | $parsed_json = json_decode($json); |
297 | 297 | $flights = $parsed_json->{'FlightsResponse'}; |
298 | 298 | if (count($flights) > 0) { |
299 | 299 | $DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'}; |
300 | 300 | $ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'}; |
301 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
302 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
303 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
|
301 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
302 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
303 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways'); |
|
304 | 304 | } else return array(); |
305 | 305 | } |
306 | 306 | |
@@ -314,27 +314,27 @@ discard block |
||
314 | 314 | global $globalLufthansaKey; |
315 | 315 | $Common = new Common(); |
316 | 316 | $check_date = new Datetime($date); |
317 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
318 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
317 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
318 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
319 | 319 | if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
320 | 320 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
321 | - $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
|
322 | - $data = $Common->getData($url,'post',$post); |
|
321 | + $post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials'); |
|
322 | + $data = $Common->getData($url, 'post', $post); |
|
323 | 323 | $parsed_data = json_decode($data); |
324 | 324 | if (!isset($parsed_data->{'access_token'})) return array(); |
325 | 325 | $token = $parsed_data->{'access_token'}; |
326 | 326 | |
327 | 327 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
328 | - $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
|
329 | - $json = $Common->getData($url,'get','',$headers); |
|
328 | + $headers = array('Authorization: Bearer '.$token, 'Accept: application/json'); |
|
329 | + $json = $Common->getData($url, 'get', '', $headers); |
|
330 | 330 | if ($json == '') return array(); |
331 | 331 | $parsed_json = json_decode($json); |
332 | 332 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
333 | 333 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
334 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
334 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
335 | 335 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
336 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
337 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
|
336 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
337 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa'); |
|
338 | 338 | } else return array(); |
339 | 339 | } |
340 | 340 | |
@@ -348,23 +348,23 @@ discard block |
||
348 | 348 | global $globalTransaviaKey; |
349 | 349 | $Common = new Common(); |
350 | 350 | $check_date = new Datetime($date); |
351 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
352 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
351 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
352 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
353 | 353 | if ($globalTransaviaKey == '') return array(); |
354 | 354 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
355 | 355 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
356 | 356 | $headers = array('apikey: '.$globalTransaviaKey); |
357 | - $json = $Common->getData($url,'get','',$headers); |
|
357 | + $json = $Common->getData($url, 'get', '', $headers); |
|
358 | 358 | //echo 'result : '.$json; |
359 | 359 | if ($json == '') return array(); |
360 | 360 | $parsed_json = json_decode($json); |
361 | 361 | |
362 | 362 | if (isset($parsed_json->{'data'}[0])) { |
363 | 363 | $DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'}; |
364 | - $departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
364 | + $departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
365 | 365 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
366 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
367 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
|
366 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
367 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia'); |
|
368 | 368 | } else return array(); |
369 | 369 | } |
370 | 370 | |
@@ -375,14 +375,14 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function getTunisair($callsign) { |
377 | 377 | $Common = new Common(); |
378 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
379 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
378 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
379 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
380 | 380 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
381 | 381 | $data = $Common->getData($url); |
382 | 382 | $table = $Common->table2array($data); |
383 | 383 | foreach ($table as $flight) { |
384 | - if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) { |
|
385 | - return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair'); |
|
384 | + if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) { |
|
385 | + return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair'); |
|
386 | 386 | } |
387 | 387 | } |
388 | 388 | return array(); |
@@ -393,21 +393,21 @@ discard block |
||
393 | 393 | * @param String $callsign The callsign |
394 | 394 | * @return Flight departure and arrival airports and time |
395 | 395 | */ |
396 | - public function getVueling($callsign,$date = 'NOW') { |
|
396 | + public function getVueling($callsign, $date = 'NOW') { |
|
397 | 397 | $Common = new Common(); |
398 | 398 | $check_date = new Datetime($date); |
399 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
400 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
401 | - $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
|
399 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
400 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
401 | + $final_date = str_replace('/', '%2F', $check_date->format('d/m/Y')); |
|
402 | 402 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
403 | 403 | $data = $Common->getData($url); |
404 | - $data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data)); |
|
404 | + $data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data)); |
|
405 | 405 | if ($data != '') { |
406 | - preg_match('/flightOri=[A-Z]{3}/',$data,$result); |
|
407 | - $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
|
408 | - preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
|
409 | - $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
|
410 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
406 | + preg_match('/flightOri=[A-Z]{3}/', $data, $result); |
|
407 | + $DepartureAirportIata = str_replace('flightOri=', '', $result[0]); |
|
408 | + preg_match('/flightDest=[A-Z]{3}/', $data, $result); |
|
409 | + $ArrivalAirportIata = str_replace('flightDest=', '', $result[0]); |
|
410 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling'); |
|
411 | 411 | else return array(); |
412 | 412 | } |
413 | 413 | return array(); |
@@ -421,27 +421,27 @@ discard block |
||
421 | 421 | */ |
422 | 422 | public function getIberia($callsign, $date = 'NOW') { |
423 | 423 | $Common = new Common(); |
424 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
424 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
425 | 425 | $check_date = new Datetime($date); |
426 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
426 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
427 | 427 | $url = "https://www.iberia.com/web/flightDetail.do"; |
428 | - $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
|
429 | - $data = $Common->getData($url,'post',$post); |
|
428 | + $post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB'); |
|
429 | + $data = $Common->getData($url, 'post', $post); |
|
430 | 430 | if ($data != '') { |
431 | 431 | $table = $Common->table2array($data); |
432 | 432 | //print_r($table); |
433 | 433 | if (count($table) > 0) { |
434 | 434 | $flight = $table; |
435 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
436 | - preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch); |
|
435 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
436 | + preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch); |
|
437 | 437 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
438 | 438 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
439 | - $departureTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[3][2]))),0,5); |
|
440 | - $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
|
439 | + $departureTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[3][2]))), 0, 5); |
|
440 | + $arrivalTime = trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][1]))); |
|
441 | 441 | if ($arrivalTime == 'Hora estimada de llegada') { |
442 | - $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
|
443 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
444 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
|
442 | + $arrivalTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][2]))), 0, 5); |
|
443 | + } else $arrivalTime = substr($arrivalTime, 0, 5); |
|
444 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia'); |
|
445 | 445 | } |
446 | 446 | } |
447 | 447 | return array(); |
@@ -454,11 +454,11 @@ discard block |
||
454 | 454 | * @return Flight departure and arrival airports and time |
455 | 455 | */ |
456 | 456 | |
457 | - private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
|
457 | + private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') { |
|
458 | 458 | $Common = new Common(); |
459 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
459 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
460 | 460 | $check_date = new Datetime($date); |
461 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
461 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
462 | 462 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
463 | 463 | $data = $Common->getData($url); |
464 | 464 | if ($data != '') { |
@@ -467,13 +467,13 @@ discard block |
||
467 | 467 | $flight = $table; |
468 | 468 | //print_r($table); |
469 | 469 | if (isset($flight[25]) && isset($flight[29])) { |
470 | - preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch); |
|
471 | - preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch); |
|
470 | + preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch); |
|
471 | + preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch); |
|
472 | 472 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
473 | 473 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
474 | - $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
|
475 | - $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
|
476 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
|
474 | + $departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5); |
|
475 | + $arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5); |
|
476 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance'); |
|
477 | 477 | } else return array(); |
478 | 478 | } |
479 | 479 | |
@@ -491,10 +491,10 @@ discard block |
||
491 | 491 | */ |
492 | 492 | private function getAlitalia($callsign, $date = 'NOW') { |
493 | 493 | $Common = new Common(); |
494 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
494 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
495 | 495 | $check_date = new Datetime($date); |
496 | - $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
497 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
496 | + $url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
497 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
498 | 498 | $data = $Common->getData($url); |
499 | 499 | if ($data != '') { |
500 | 500 | $table = $Common->text2array($data); |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | $ArrivalAirportIata = ''; |
503 | 503 | $departureTime = $table[4]; |
504 | 504 | $arrivalTime = $table[5]; |
505 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia'); |
|
505 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia'); |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
@@ -514,21 +514,21 @@ discard block |
||
514 | 514 | */ |
515 | 515 | private function getBrussels($callsign, $date = 'NOW') { |
516 | 516 | $Common = new Common(); |
517 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
517 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
518 | 518 | $check_date = new Datetime($date); |
519 | - $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
519 | + $url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
520 | 520 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
521 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
521 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
522 | 522 | $data = $Common->getData($url); |
523 | 523 | if ($data != '') { |
524 | 524 | //echo $data; |
525 | - $parsed_json = json_decode($data,true); |
|
525 | + $parsed_json = json_decode($data, true); |
|
526 | 526 | if (isset($parsed_json[0]['FromAirportCode'])) { |
527 | 527 | $DepartureAirportIata = $parsed_json[0]['FromAirportCode']; |
528 | 528 | $ArrivalAirportIata = $parsed_json[0]['ToAirportCode']; |
529 | - $departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
530 | - $arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
531 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
|
529 | + $departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
530 | + $arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
531 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels'); |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | } |
@@ -605,21 +605,21 @@ discard block |
||
605 | 605 | */ |
606 | 606 | private function getFlyTap($callsign) { |
607 | 607 | $Common = new Common(); |
608 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
609 | - $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
608 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
609 | + $url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
610 | 610 | //$check_date = new Datetime($date); |
611 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
612 | - $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
|
613 | - $data = $Common->getData($url,'post',$post); |
|
611 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
612 | + $post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1'); |
|
613 | + $data = $Common->getData($url, 'post', $post); |
|
614 | 614 | if ($data != '') { |
615 | 615 | $table = $Common->table2array($data); |
616 | - $departureTime = trim(substr($table[15][0],0,5)); |
|
617 | - $arrivalTime = trim(substr($table[35][0],0,5)); |
|
618 | - preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch); |
|
619 | - preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch); |
|
616 | + $departureTime = trim(substr($table[15][0], 0, 5)); |
|
617 | + $arrivalTime = trim(substr($table[35][0], 0, 5)); |
|
618 | + preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch); |
|
619 | + preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch); |
|
620 | 620 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
621 | 621 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
622 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap'); |
|
622 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap'); |
|
623 | 623 | } |
624 | 624 | return array(); |
625 | 625 | } |
@@ -641,10 +641,10 @@ discard block |
||
641 | 641 | } |
642 | 642 | } |
643 | 643 | if ($airline_icao == '') return array(); |
644 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
645 | - $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
644 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
645 | + $url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
646 | 646 | //$check_date = new Datetime($date); |
647 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
647 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
648 | 648 | $data = $Common->getData($url); |
649 | 649 | if ($data != '') { |
650 | 650 | $table = $Common->table2array($data); |
@@ -654,13 +654,13 @@ discard block |
||
654 | 654 | $darr = ''; |
655 | 655 | $ahour = ''; |
656 | 656 | $aarr = ''; |
657 | - $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
|
657 | + $n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr); |
|
658 | 658 | if ($n == 7) { |
659 | 659 | $departureTime = $dhour; |
660 | 660 | $arrivalTime = $ahour; |
661 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
662 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
663 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
661 | + $DepartureAirportIata = str_replace(array('(', ')'), '', $darr); |
|
662 | + $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr); |
|
663 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper'); |
|
664 | 664 | } |
665 | 665 | } |
666 | 666 | } |
@@ -684,20 +684,20 @@ discard block |
||
684 | 684 | } |
685 | 685 | } |
686 | 686 | */ |
687 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
688 | - $url= "http://fr.flightaware.com/live/flight/".$callsign; |
|
687 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
688 | + $url = "http://fr.flightaware.com/live/flight/".$callsign; |
|
689 | 689 | //$check_date = new Datetime($date); |
690 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
690 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
691 | 691 | $data = $Common->getData($url); |
692 | 692 | if ($data != '') { |
693 | 693 | $table = $Common->table2array($data); |
694 | 694 | if (isset($table[11][0])) { |
695 | - $departureTime = str_replace('h',':',substr($table[5][0],0,5)); |
|
696 | - $arrivalTime = str_replace('h',':',substr($table[5][1],0,5)); |
|
695 | + $departureTime = str_replace('h', ':', substr($table[5][0], 0, 5)); |
|
696 | + $arrivalTime = str_replace('h', ':', substr($table[5][1], 0, 5)); |
|
697 | 697 | echo $table[3][0]; |
698 | - sscanf($table[3][0],'%*[^(] (%3[A-Z] / %*4[A-Z])',$DepartureAirportIata); |
|
699 | - sscanf($table[3][1],'%*[^(] (%3[A-Z] / %*4[A-Z])',$ArrivalAirportIata); |
|
700 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightaware'); |
|
698 | + sscanf($table[3][0], '%*[^(] (%3[A-Z] / %*4[A-Z])', $DepartureAirportIata); |
|
699 | + sscanf($table[3][1], '%*[^(] (%3[A-Z] / %*4[A-Z])', $ArrivalAirportIata); |
|
700 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightaware'); |
|
701 | 701 | } |
702 | 702 | } |
703 | 703 | return array(); |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | */ |
711 | 711 | public function getCostToTravel($callsign) { |
712 | 712 | $Common = new Common(); |
713 | - $url= "http://www.costtotravel.com/flight-number/".$callsign; |
|
713 | + $url = "http://www.costtotravel.com/flight-number/".$callsign; |
|
714 | 714 | //$check_date = new Datetime($date); |
715 | 715 | //if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
716 | 716 | $data = $Common->getData($url); |
@@ -718,11 +718,11 @@ discard block |
||
718 | 718 | $table = $Common->table2array($data); |
719 | 719 | //print_r($table); |
720 | 720 | if (isset($table[11][1])) { |
721 | - $departureTime = substr($table[11][1],0,5); |
|
722 | - $arrivalTime = substr($table[17][1],0,5); |
|
723 | - $DepartureAirportIata = substr($table[13][1],0,3); |
|
724 | - $ArrivalAirportIata = substr($table[15][1],0,3); |
|
725 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel'); |
|
721 | + $departureTime = substr($table[11][1], 0, 5); |
|
722 | + $arrivalTime = substr($table[17][1], 0, 5); |
|
723 | + $DepartureAirportIata = substr($table[13][1], 0, 3); |
|
724 | + $ArrivalAirportIata = substr($table[15][1], 0, 3); |
|
725 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel'); |
|
726 | 726 | } |
727 | 727 | } |
728 | 728 | return array(); |
@@ -734,14 +734,14 @@ discard block |
||
734 | 734 | * @param String $date date we want flight number info |
735 | 735 | * @return Flight departure and arrival airports and time |
736 | 736 | */ |
737 | - private function getAirCanada($callsign,$date = 'NOW') { |
|
737 | + private function getAirCanada($callsign, $date = 'NOW') { |
|
738 | 738 | $Common = new Common(); |
739 | 739 | if (class_exists("DomDocument") === FALSE) return array(); |
740 | 740 | date_default_timezone_set('UTC'); |
741 | 741 | $check_date = new Datetime($date); |
742 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
743 | - $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
744 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
742 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
743 | + $url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
744 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
745 | 745 | $data = $Common->getData($url); |
746 | 746 | $dom = new DomDocument(); |
747 | 747 | $dom->loadXML($data); |
@@ -749,11 +749,11 @@ discard block |
||
749 | 749 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
750 | 750 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
751 | 751 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
752 | - $departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
752 | + $departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
753 | 753 | $arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0); |
754 | 754 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
755 | - $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
756 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
|
755 | + $arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
756 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada'); |
|
757 | 757 | } else return array(); |
758 | 758 | } |
759 | 759 | |
@@ -765,21 +765,21 @@ discard block |
||
765 | 765 | */ |
766 | 766 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
767 | 767 | $Common = new Common(); |
768 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
768 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
769 | 769 | $check_date = new Datetime($date); |
770 | - $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
771 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
770 | + $url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
771 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
772 | 772 | $data = $Common->getData($url); |
773 | 773 | if ($data != '') { |
774 | 774 | $table = $Common->table2array($data); |
775 | 775 | $flight = $table; |
776 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
777 | - preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch); |
|
776 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
777 | + preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch); |
|
778 | 778 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
779 | 779 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
780 | 780 | $departureTime = $flight[5][1]; |
781 | 781 | $arrivalTime = $flight[23][1]; |
782 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines'); |
|
782 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines'); |
|
783 | 783 | } |
784 | 784 | } |
785 | 785 | |
@@ -790,16 +790,16 @@ discard block |
||
790 | 790 | * @param String $carrier airline code |
791 | 791 | * @return Flight departure and arrival airports and time |
792 | 792 | */ |
793 | - private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
|
793 | + private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') { |
|
794 | 794 | $Common = new Common(); |
795 | 795 | date_default_timezone_set('UTC'); |
796 | 796 | //AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair |
797 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
797 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
798 | 798 | $check_date = new Datetime($date); |
799 | - $url= "http://www.airberlin.com/en-US/site/aims.php"; |
|
800 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
801 | - $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
|
802 | - $data = $Common->getData($url,'post',$post); |
|
799 | + $url = "http://www.airberlin.com/en-US/site/aims.php"; |
|
800 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
801 | + $post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier); |
|
802 | + $data = $Common->getData($url, 'post', $post); |
|
803 | 803 | //echo $data; |
804 | 804 | $DepartureAirportIata = ''; |
805 | 805 | $ArrivalAirportIata = ''; |
@@ -812,8 +812,8 @@ discard block |
||
812 | 812 | if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
813 | 813 | else $departureAirport = ''; |
814 | 814 | } else return array(); |
815 | - $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
|
816 | - $data = $Common->getData($url,'post',$post); |
|
815 | + $post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB'); |
|
816 | + $data = $Common->getData($url, 'post', $post); |
|
817 | 817 | if ($data != '') { |
818 | 818 | $table = $Common->table2array($data); |
819 | 819 | $flight = $table; |
@@ -841,13 +841,13 @@ discard block |
||
841 | 841 | } |
842 | 842 | } |
843 | 843 | if (isset($DepartureAirportIata)) { |
844 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
|
844 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin'); |
|
845 | 845 | } else return array(); |
846 | 846 | } |
847 | 847 | |
848 | 848 | |
849 | 849 | |
850 | - public function fetchSchedule($ident,$date = 'NOW') { |
|
850 | + public function fetchSchedule($ident, $date = 'NOW') { |
|
851 | 851 | global $globalSchedulesSources, $globalSchedulesFetch; |
852 | 852 | //$Common = new Common(); |
853 | 853 | if (!$globalSchedulesFetch) return array(); |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | // Brussels Airlines |
918 | 918 | case "BEL": |
919 | 919 | case "SN": |
920 | - return $this->getBrussels($ident,$date); |
|
920 | + return $this->getBrussels($ident, $date); |
|
921 | 921 | /* |
922 | 922 | // Copa Airlines |
923 | 923 | case "CMP": |
@@ -1002,17 +1002,17 @@ discard block |
||
1002 | 1002 | // Air France |
1003 | 1003 | case "AF": |
1004 | 1004 | case "AFR": |
1005 | - return $this->getAirFrance($ident,$date,'AF'); |
|
1005 | + return $this->getAirFrance($ident, $date, 'AF'); |
|
1006 | 1006 | // HOP |
1007 | 1007 | case "A5": |
1008 | 1008 | case "HOP": |
1009 | - return $this->getAirFrance($ident,$date,'A5'); |
|
1009 | + return $this->getAirFrance($ident, $date, 'A5'); |
|
1010 | 1010 | // EasyJet |
1011 | 1011 | case "U2": |
1012 | 1012 | case "DS": |
1013 | 1013 | case "EZY": |
1014 | 1014 | case "EZS": |
1015 | - return $this->getEasyJet($ident,$date); |
|
1015 | + return $this->getEasyJet($ident, $date); |
|
1016 | 1016 | // Ryanair |
1017 | 1017 | case "FR": |
1018 | 1018 | case "RYR": |
@@ -1062,25 +1062,25 @@ discard block |
||
1062 | 1062 | return $this->getIberia($ident); |
1063 | 1063 | // Vietnam Airlines |
1064 | 1064 | case "HVN": |
1065 | - return $this->getVietnamAirlines($ident,$date); |
|
1065 | + return $this->getVietnamAirlines($ident, $date); |
|
1066 | 1066 | // Air Berlin |
1067 | 1067 | case "AB": |
1068 | 1068 | case "BER": |
1069 | - return $this->getAirBerlin($ident,$date,'AB'); |
|
1069 | + return $this->getAirBerlin($ident, $date, 'AB'); |
|
1070 | 1070 | // NIKI |
1071 | 1071 | case "HG": |
1072 | 1072 | case "NLY": |
1073 | - return $this->getAirBerlin($ident,$date,'HG'); |
|
1073 | + return $this->getAirBerlin($ident, $date, 'HG'); |
|
1074 | 1074 | // BelAir |
1075 | 1075 | case "4T": |
1076 | 1076 | case "BHP": |
1077 | - return $this->getAirBerlin($ident,$date,'4T'); |
|
1077 | + return $this->getAirBerlin($ident, $date, '4T'); |
|
1078 | 1078 | default: |
1079 | 1079 | // Randomly use a generic function to get hours |
1080 | 1080 | if (strlen($airline_icao) == 2) { |
1081 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1081 | + if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware'); |
|
1082 | 1082 | if (count($globalSchedulesSources) > 0) { |
1083 | - $rand = mt_rand(0,count($globalSchedulesSources)-1); |
|
1083 | + $rand = mt_rand(0, count($globalSchedulesSources) - 1); |
|
1084 | 1084 | $source = $globalSchedulesSources[$rand]; |
1085 | 1085 | if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
1086 | 1086 | elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
@@ -18,22 +18,22 @@ discard block |
||
18 | 18 | * @return Array the images list |
19 | 19 | * |
20 | 20 | */ |
21 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
21 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
22 | 22 | { |
23 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
24 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
25 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
23 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
24 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
25 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
26 | 26 | $reg = $registration; |
27 | 27 | if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
28 | 28 | $reg = trim($reg); |
29 | - $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 | + $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
30 | 30 | FROM spotter_image |
31 | 31 | WHERE spotter_image.registration = :registration LIMIT 1"; |
32 | 32 | $sth = $this->db->prepare($query); |
33 | 33 | $sth->execute(array(':registration' => $reg)); |
34 | 34 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
35 | 35 | if (!empty($result)) return $result; |
36 | - elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
36 | + elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
37 | 37 | else return array(); |
38 | 38 | } |
39 | 39 | |
@@ -43,23 +43,23 @@ discard block |
||
43 | 43 | * @return Array the images list |
44 | 44 | * |
45 | 45 | */ |
46 | - public function getMarineImage($mmsi,$imo = '',$name = '') |
|
46 | + public function getMarineImage($mmsi, $imo = '', $name = '') |
|
47 | 47 | { |
48 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
49 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
50 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
48 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
49 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
50 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
51 | 51 | $name = trim($name); |
52 | - $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 | + $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 |
|
53 | 53 | FROM marine_image |
54 | 54 | WHERE marine_image.mmsi = :mmsi"; |
55 | 55 | $query_data = array(':mmsi' => $mmsi); |
56 | 56 | if ($imo != '') { |
57 | 57 | $query .= " AND marine_image.imo = :imo"; |
58 | - $query_data = array_merge($query_data,array(':imo' => $imo)); |
|
58 | + $query_data = array_merge($query_data, array(':imo' => $imo)); |
|
59 | 59 | } |
60 | 60 | if ($name != '') { |
61 | 61 | $query .= " AND marine_image.name = :name"; |
62 | - $query_data = array_merge($query_data,array(':name' => $name)); |
|
62 | + $query_data = array_merge($query_data, array(':name' => $name)); |
|
63 | 63 | } |
64 | 64 | $query .= " LIMIT 1"; |
65 | 65 | $sth = $this->db->prepare($query); |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
81 | 81 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
82 | 82 | if ($copyright != '') { |
83 | - $copyright = str_replace('Copyright ','',$copyright); |
|
84 | - $copyright = str_replace('© ','',$copyright); |
|
85 | - $copyright = str_replace('(c) ','',$copyright); |
|
83 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
84 | + $copyright = str_replace('© ', '', $copyright); |
|
85 | + $copyright = str_replace('(c) ', '', $copyright); |
|
86 | 86 | } |
87 | 87 | return $copyright; |
88 | 88 | } |
@@ -93,25 +93,25 @@ discard block |
||
93 | 93 | * @return String either success or error |
94 | 94 | * |
95 | 95 | */ |
96 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
96 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
97 | 97 | { |
98 | - global $globalDebug,$globalAircraftImageFetch; |
|
98 | + global $globalDebug, $globalAircraftImageFetch; |
|
99 | 99 | if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
100 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
100 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
101 | 101 | $registration = trim($registration); |
102 | 102 | //getting the aircraft image |
103 | 103 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
104 | 104 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
105 | 105 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
106 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
106 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
107 | 107 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
108 | 108 | if ($image_url['original'] != '') { |
109 | 109 | if ($globalDebug) echo 'Found !'."\n"; |
110 | - $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 | + $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
111 | 111 | try { |
112 | 112 | $sth = $this->db->prepare($query); |
113 | - $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'])); |
|
114 | - } catch(PDOException $e) { |
|
113 | + $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'])); |
|
114 | + } catch (PDOException $e) { |
|
115 | 115 | echo $e->getMessage()."\n"; |
116 | 116 | return "error"; |
117 | 117 | } |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | * @return String either success or error |
126 | 126 | * |
127 | 127 | */ |
128 | - public function addMarineImage($mmsi,$imo = '',$name = '') |
|
128 | + public function addMarineImage($mmsi, $imo = '', $name = '') |
|
129 | 129 | { |
130 | - global $globalDebug,$globalMarineImageFetch; |
|
130 | + global $globalDebug, $globalMarineImageFetch; |
|
131 | 131 | if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return ''; |
132 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
133 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
134 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
132 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
133 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
134 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
135 | 135 | $name = trim($name); |
136 | 136 | $Marine = new Marine($this->db); |
137 | 137 | if ($imo == '' || $name == '') { |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | |
146 | 146 | //getting the aircraft image |
147 | 147 | if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
148 | - $image_url = $this->findMarineImage($mmsi,$imo,$name); |
|
148 | + $image_url = $this->findMarineImage($mmsi, $imo, $name); |
|
149 | 149 | if ($image_url['original'] != '') { |
150 | 150 | if ($globalDebug) echo 'Found !'."\n"; |
151 | - $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 | + $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
152 | 152 | try { |
153 | 153 | $sth = $this->db->prepare($query); |
154 | - $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'])); |
|
155 | - } catch(PDOException $e) { |
|
154 | + $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'])); |
|
155 | + } catch (PDOException $e) { |
|
156 | 156 | echo $e->getMessage()."\n"; |
157 | 157 | return "error"; |
158 | 158 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
173 | 173 | $Spotter = new Spotter($this->db); |
174 | 174 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
175 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
175 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
176 | 176 | if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) { |
177 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
177 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
178 | 178 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
179 | 179 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
180 | 180 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -188,25 +188,25 @@ discard block |
||
188 | 188 | if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
189 | 189 | else $aircraft_name = ''; |
190 | 190 | $aircraft_registration = $aircraft_icao; |
191 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
191 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
192 | 192 | unset($Spotter); |
193 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
193 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
194 | 194 | foreach ($globalAircraftImageSources as $source) { |
195 | 195 | $source = strtolower($source); |
196 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
197 | - if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
198 | - if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
199 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
200 | - if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
201 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
202 | - if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
203 | - if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
204 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
205 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
196 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao); |
|
197 | + if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name); |
|
198 | + if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name); |
|
199 | + if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name); |
|
200 | + if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name); |
|
201 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name); |
|
202 | + if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name); |
|
203 | + if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name); |
|
204 | + if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name); |
|
205 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name); |
|
206 | 206 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
207 | 207 | } |
208 | 208 | if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
209 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
209 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | * @return Array the aircraft thumbnail, orignal url and copyright |
219 | 219 | * |
220 | 220 | */ |
221 | - public function findMarineImage($mmsi,$imo = '',$name = '') |
|
221 | + public function findMarineImage($mmsi, $imo = '', $name = '') |
|
222 | 222 | { |
223 | 223 | global $globalMarineImageSources; |
224 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
224 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
225 | 225 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
226 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
226 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
227 | 227 | $name = trim($name); |
228 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
228 | + if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
229 | 229 | /* |
230 | 230 | $Marine = new Marine($this->db); |
231 | 231 | if ($imo == '' || $name == '') { |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | } |
238 | 238 | unset($Marine); |
239 | 239 | */ |
240 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
240 | + if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing'); |
|
241 | 241 | foreach ($globalMarineImageSources as $source) { |
242 | 242 | $source = strtolower($source); |
243 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
244 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
245 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
246 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
247 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
243 | + if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name); |
|
244 | + if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name); |
|
245 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name); |
|
246 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name); |
|
247 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name); |
|
248 | 248 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
249 | 249 | } |
250 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
250 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -258,25 +258,25 @@ discard block |
||
258 | 258 | * @return Array the aircraft thumbnail, orignal url and copyright |
259 | 259 | * |
260 | 260 | */ |
261 | - public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
|
261 | + public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') { |
|
262 | 262 | $Common = new Common(); |
263 | 263 | // If aircraft registration is only number, also check with aircraft model |
264 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
265 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
264 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
265 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
266 | 266 | } else { |
267 | 267 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
268 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
268 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
269 | 269 | } |
270 | 270 | $data = $Common->getData($url); |
271 | 271 | if (substr($data, 0, 5) != "<?xml") return false; |
272 | 272 | if ($xml = simplexml_load_string($data)) { |
273 | 273 | if (isset($xml->channel->item)) { |
274 | 274 | $image_url = array(); |
275 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
275 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
276 | 276 | $image_url['thumbnail'] = $thumbnail_url; |
277 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
278 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
279 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
277 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
278 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
279 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
280 | 280 | $image_url['source'] = 'planespotters'; |
281 | 281 | return $image_url; |
282 | 282 | } |
@@ -292,31 +292,31 @@ discard block |
||
292 | 292 | * @return Array the aircraft thumbnail, orignal url and copyright |
293 | 293 | * |
294 | 294 | */ |
295 | - public function fromDeviantart($type,$registration, $name='') { |
|
295 | + public function fromDeviantart($type, $registration, $name = '') { |
|
296 | 296 | $Common = new Common(); |
297 | 297 | if ($type == 'aircraft') { |
298 | 298 | // If aircraft registration is only number, also check with aircraft model |
299 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
300 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
299 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
300 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
301 | 301 | } else { |
302 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
302 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
303 | 303 | } |
304 | 304 | } elseif ($type == 'marine') { |
305 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
305 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
306 | 306 | } else { |
307 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
307 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
308 | 308 | } |
309 | 309 | $data = $Common->getData($url); |
310 | 310 | if (substr($data, 0, 5) != "<?xml") return false; |
311 | 311 | if ($xml = simplexml_load_string($data)) { |
312 | 312 | if (isset($xml->channel->item->link)) { |
313 | 313 | $image_url = array(); |
314 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
314 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
315 | 315 | $image_url['thumbnail'] = $thumbnail_url; |
316 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
316 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
317 | 317 | $image_url['original'] = $original_url; |
318 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
319 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
318 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
319 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
320 | 320 | $image_url['source'] = 'deviantart'; |
321 | 321 | return $image_url; |
322 | 322 | } |
@@ -332,32 +332,32 @@ discard block |
||
332 | 332 | * @return Array the aircraft thumbnail, orignal url and copyright |
333 | 333 | * |
334 | 334 | */ |
335 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
335 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
336 | 336 | $Common = new Common(); |
337 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
337 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
338 | 338 | $data = $Common->getData($url); |
339 | 339 | $dom = new DOMDocument(); |
340 | 340 | @$dom->loadHTML($data); |
341 | 341 | $all_pics = array(); |
342 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
342 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
343 | 343 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
344 | 344 | $all_pics[] = $image->getAttribute('src'); |
345 | 345 | } |
346 | 346 | } |
347 | 347 | $all_authors = array(); |
348 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
348 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
349 | 349 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
350 | 350 | $all_authors[] = $author->getAttribute('content'); |
351 | 351 | } |
352 | 352 | } |
353 | 353 | $all_ref = array(); |
354 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
354 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
355 | 355 | $all_ref[] = $link->getAttribute('href'); |
356 | 356 | } |
357 | 357 | if (isset($all_pics[0])) { |
358 | 358 | $image_url = array(); |
359 | 359 | $image_url['thumbnail'] = $all_pics[0]; |
360 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
360 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
361 | 361 | $image_url['copyright'] = $all_authors[0]; |
362 | 362 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
363 | 363 | $image_url['source'] = 'JetPhotos'; |
@@ -374,24 +374,24 @@ discard block |
||
374 | 374 | * @return Array the aircraft thumbnail, orignal url and copyright |
375 | 375 | * |
376 | 376 | */ |
377 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
377 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
378 | 378 | $Common = new Common(); |
379 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
379 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
380 | 380 | $data = $Common->getData($url); |
381 | 381 | $dom = new DOMDocument(); |
382 | 382 | @$dom->loadHTML($data); |
383 | 383 | $all_pics = array(); |
384 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
384 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
385 | 385 | $all_pics[] = $image->getAttribute('src'); |
386 | 386 | } |
387 | 387 | $all_links = array(); |
388 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
389 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
388 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
389 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
390 | 390 | } |
391 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
391 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
392 | 392 | $image_url = array(); |
393 | 393 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
394 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
394 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
395 | 395 | $image_url['copyright'] = $all_links[6]['text']; |
396 | 396 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
397 | 397 | $image_url['source'] = 'PlanePictures'; |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @return Array the aircraft thumbnail, orignal url and copyright |
409 | 409 | * |
410 | 410 | */ |
411 | - public function fromFlickr($type,$registration,$name='') { |
|
411 | + public function fromFlickr($type, $registration, $name = '') { |
|
412 | 412 | $Common = new Common(); |
413 | 413 | if ($type == 'aircraft') { |
414 | 414 | if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
@@ -421,12 +421,12 @@ discard block |
||
421 | 421 | if (substr($data, 0, 5) != "<?xml") return false; |
422 | 422 | if ($xml = simplexml_load_string($data)) { |
423 | 423 | if (isset($xml->channel->item)) { |
424 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
424 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
425 | 425 | $image_url = array(); |
426 | 426 | $image_url['thumbnail'] = $original_url; |
427 | 427 | $image_url['original'] = $original_url; |
428 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
429 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
428 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
429 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
430 | 430 | $image_url['source'] = 'flickr'; |
431 | 431 | return $image_url; |
432 | 432 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | return false; |
435 | 435 | } |
436 | 436 | |
437 | - public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
|
437 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
438 | 438 | $Common = new Common(); |
439 | 439 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
440 | 440 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | * @return Array the aircraft thumbnail, orignal url and copyright |
459 | 459 | * |
460 | 460 | */ |
461 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
461 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
462 | 462 | global $globalImageBingKey; |
463 | 463 | $Common = new Common(); |
464 | 464 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
470 | 470 | else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
471 | 471 | } |
472 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
473 | - $data = $Common->getData($url,'get','',$headers); |
|
472 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
473 | + $data = $Common->getData($url, 'get', '', $headers); |
|
474 | 474 | $result = json_decode($data); |
475 | 475 | if (isset($result->d->results[0]->MediaUrl)) { |
476 | 476 | $image_url = array(); |
@@ -495,14 +495,14 @@ discard block |
||
495 | 495 | * @return Array the aircraft thumbnail, orignal url and copyright |
496 | 496 | * |
497 | 497 | */ |
498 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
498 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
499 | 499 | $Common = new Common(); |
500 | 500 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
501 | 501 | $data = $Common->getData($url); |
502 | 502 | $result = json_decode($data); |
503 | 503 | if (isset($result->count) && $result->count > 0) { |
504 | 504 | $image_url = array(); |
505 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
505 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
506 | 506 | $image_url['source_website'] = $result->data[0]->link; |
507 | 507 | $image_url['thumbnail'] = $result->data[0]->image; |
508 | 508 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @return Array the aircraft thumbnail, orignal url and copyright |
521 | 521 | * |
522 | 522 | */ |
523 | - public function fromWikimedia($type,$registration,$name='') { |
|
523 | + public function fromWikimedia($type, $registration, $name = '') { |
|
524 | 524 | $Common = new Common(); |
525 | 525 | if ($type == 'aircraft') { |
526 | 526 | if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $result = json_decode($data); |
534 | 534 | if (isset($result->query->search[0]->title)) { |
535 | 535 | $fileo = $result->query->search[0]->title; |
536 | - if (substr($fileo,-3) == 'pdf') return false; |
|
536 | + if (substr($fileo, -3) == 'pdf') return false; |
|
537 | 537 | $file = urlencode($fileo); |
538 | 538 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
539 | 539 | $data2 = $Common->getData($url2); |
@@ -558,11 +558,11 @@ discard block |
||
558 | 558 | if (isset($result2->query->pages)) { |
559 | 559 | foreach ($result2->query->pages as $page) { |
560 | 560 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
561 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
561 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
562 | 562 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
563 | 563 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
564 | 564 | } |
565 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
565 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
566 | 566 | return $image_url; |
567 | 567 | } |
568 | 568 | } |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @return Array the aircraft thumbnail, orignal url and copyright |
582 | 582 | * |
583 | 583 | */ |
584 | - public function fromCustomSource($type,$registration,$name='') { |
|
584 | + public function fromCustomSource($type, $registration, $name = '') { |
|
585 | 585 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
586 | 586 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
587 | 587 | if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') { |
@@ -598,15 +598,15 @@ discard block |
||
598 | 598 | print_r($source); |
599 | 599 | print_r($customsources); |
600 | 600 | } |
601 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
602 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
601 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
602 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
603 | 603 | if ($Common->urlexist($url)) { |
604 | 604 | $image_url = array(); |
605 | 605 | $image_url['thumbnail'] = $url_thumbnail; |
606 | 606 | $image_url['original'] = $url; |
607 | 607 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
608 | 608 | else $exifCopyright = ''; |
609 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
609 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
610 | 610 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
611 | 611 | else $image_url['copyright'] = $source['source_website']; |
612 | 612 | $image_url['source_website'] = $source['source_website']; |
@@ -630,19 +630,19 @@ discard block |
||
630 | 630 | print_r($source); |
631 | 631 | print_r($customsources); |
632 | 632 | } |
633 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
634 | - $url = str_replace('{mmsi}',$registration,$url); |
|
635 | - $url = str_replace('{name}',$name,$url); |
|
636 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
637 | - $url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail); |
|
638 | - $url_thumbnail = str_replace('{name}',$name,$url_thumbnail); |
|
633 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
634 | + $url = str_replace('{mmsi}', $registration, $url); |
|
635 | + $url = str_replace('{name}', $name, $url); |
|
636 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
637 | + $url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail); |
|
638 | + $url_thumbnail = str_replace('{name}', $name, $url_thumbnail); |
|
639 | 639 | if ($Common->urlexist($url)) { |
640 | 640 | $image_url = array(); |
641 | 641 | $image_url['thumbnail'] = $url_thumbnail; |
642 | 642 | $image_url['original'] = $url; |
643 | 643 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
644 | 644 | else $exifCopyright = ''; |
645 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
645 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
646 | 646 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
647 | 647 | else $image_url['copyright'] = $source['source_website']; |
648 | 648 | $image_url['source_website'] = $source['source_website']; |
@@ -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) { |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | 19 | |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $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 | + $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"; |
|
40 | 40 | } else { |
41 | - $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 | + $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"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
47 | 47 | } |
48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
73 | 73 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
74 | 74 | if ($filter_query_where != '') { |
75 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
75 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
76 | 76 | } |
77 | 77 | $filter_query = $filter_query_join.$filter_query_where; |
78 | 78 | return $filter_query; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return Array the spotter information |
88 | 88 | * |
89 | 89 | */ |
90 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
90 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
91 | 91 | { |
92 | 92 | date_default_timezone_set('UTC'); |
93 | 93 | if (!is_string($query)) |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | $sth = $this->db->prepare($query.$limitQuery); |
108 | 108 | $sth->execute($params); |
109 | 109 | } catch (PDOException $e) { |
110 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
110 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
111 | 111 | exit(); |
112 | 112 | } |
113 | 113 | |
114 | 114 | $num_rows = 0; |
115 | 115 | $spotter_array = array(); |
116 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
116 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
117 | 117 | { |
118 | 118 | $num_rows++; |
119 | 119 | $temp_array = array(); |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | } |
146 | 146 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
147 | 147 | |
148 | - if($temp_array['mmsi'] != "") |
|
148 | + if ($temp_array['mmsi'] != "") |
|
149 | 149 | { |
150 | 150 | $Image = new Image($this->db); |
151 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
151 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
152 | 152 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
153 | 153 | unset($Image); |
154 | 154 | if (count($image_array) > 0) { |
@@ -184,17 +184,17 @@ discard block |
||
184 | 184 | { |
185 | 185 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
186 | 186 | } else { |
187 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
187 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
188 | 188 | } |
189 | 189 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
190 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
191 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
190 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
191 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
192 | 192 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
193 | 193 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
194 | 194 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
195 | 195 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
196 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
197 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
196 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
197 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
198 | 198 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
199 | 199 | } |
200 | 200 | } |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | if ($limit != "") |
228 | 228 | { |
229 | 229 | $limit_array = explode(",", $limit); |
230 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
231 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
230 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
231 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
232 | 232 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
233 | 233 | { |
234 | 234 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | } else { |
243 | 243 | $orderby_query = " ORDER BY marine_output.date DESC"; |
244 | 244 | } |
245 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
246 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
245 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
246 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
247 | 247 | return $spotter_array; |
248 | 248 | } |
249 | 249 | |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | if ($id == '') return array(); |
262 | 262 | $additional_query = "marine_output.fammarine_id = :id"; |
263 | 263 | $query_values = array(':id' => $id); |
264 | - $query = $global_query." WHERE ".$additional_query." "; |
|
265 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
264 | + $query = $global_query." WHERE ".$additional_query." "; |
|
265 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
266 | 266 | return $spotter_array; |
267 | 267 | } |
268 | 268 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $query_values = array(); |
282 | 282 | $limit_query = ''; |
283 | 283 | $additional_query = ''; |
284 | - $filter_query = $this->getFilter($filter,true,true); |
|
284 | + $filter_query = $this->getFilter($filter, true, true); |
|
285 | 285 | if ($ident != "") |
286 | 286 | { |
287 | 287 | if (!is_string($ident)) |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | { |
298 | 298 | $limit_array = explode(",", $limit); |
299 | 299 | |
300 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
301 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
300 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
301 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
302 | 302 | |
303 | 303 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
304 | 304 | { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | return $spotter_array; |
323 | 323 | } |
324 | 324 | |
325 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
325 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
326 | 326 | { |
327 | 327 | global $global_query, $globalTimezone, $globalDBdriver; |
328 | 328 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $limit_query = ''; |
331 | 331 | $additional_query = ''; |
332 | 332 | |
333 | - $filter_query = $this->getFilter($filter,true,true); |
|
333 | + $filter_query = $this->getFilter($filter, true, true); |
|
334 | 334 | |
335 | 335 | if ($date != "") |
336 | 336 | { |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | { |
357 | 357 | $limit_array = explode(",", $limit); |
358 | 358 | |
359 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
360 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
359 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
360 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
361 | 361 | |
362 | 362 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
363 | 363 | { |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | * @return Array list of source name |
389 | 389 | * |
390 | 390 | */ |
391 | - public function getAllSourceName($type = '',$filters = array()) |
|
391 | + public function getAllSourceName($type = '', $filters = array()) |
|
392 | 392 | { |
393 | - $filter_query = $this->getFilter($filters,true,true); |
|
393 | + $filter_query = $this->getFilter($filters, true, true); |
|
394 | 394 | $query_values = array(); |
395 | - $query = "SELECT DISTINCT marine_output.source_name |
|
395 | + $query = "SELECT DISTINCT marine_output.source_name |
|
396 | 396 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
397 | 397 | if ($type != '') { |
398 | 398 | $query_values = array(':type' => $type); |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $source_array = array(); |
408 | 408 | $temp_array = array(); |
409 | 409 | |
410 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
410 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
411 | 411 | { |
412 | 412 | $temp_array['source_name'] = $row['source_name']; |
413 | 413 | $source_array[] = $temp_array; |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | */ |
425 | 425 | public function getAllIdents($filters = array()) |
426 | 426 | { |
427 | - $filter_query = $this->getFilter($filters,true,true); |
|
428 | - $query = "SELECT DISTINCT marine_output.ident |
|
427 | + $filter_query = $this->getFilter($filters, true, true); |
|
428 | + $query = "SELECT DISTINCT marine_output.ident |
|
429 | 429 | FROM marine_output".$filter_query." marine_output.ident <> '' |
430 | 430 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
431 | 431 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $ident_array = array(); |
436 | 436 | $temp_array = array(); |
437 | 437 | |
438 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
438 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
439 | 439 | { |
440 | 440 | $temp_array['ident'] = $row['ident']; |
441 | 441 | $ident_array[] = $temp_array; |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | */ |
453 | 453 | public function getIdentity($mmsi) |
454 | 454 | { |
455 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
455 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
456 | 456 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
457 | 457 | $sth = $this->db->prepare($query); |
458 | 458 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -477,12 +477,12 @@ discard block |
||
477 | 477 | } else $offset = '+00:00'; |
478 | 478 | |
479 | 479 | if ($globalDBdriver == 'mysql') { |
480 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
480 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
481 | 481 | FROM marine_output |
482 | 482 | WHERE marine_output.date <> '' |
483 | 483 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
484 | 484 | } else { |
485 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
485 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
486 | 486 | FROM marine_output |
487 | 487 | WHERE marine_output.date <> '' |
488 | 488 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $date_array = array(); |
495 | 495 | $temp_array = array(); |
496 | 496 | |
497 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
497 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
498 | 498 | { |
499 | 499 | $temp_array['date'] = $row['date']; |
500 | 500 | |
@@ -513,11 +513,11 @@ discard block |
||
513 | 513 | * @return String success or false |
514 | 514 | * |
515 | 515 | */ |
516 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
516 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
517 | 517 | { |
518 | 518 | |
519 | 519 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
520 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
520 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
521 | 521 | |
522 | 522 | try { |
523 | 523 | $sth = $this->db->prepare($query); |
@@ -539,11 +539,11 @@ discard block |
||
539 | 539 | * @return String success or false |
540 | 540 | * |
541 | 541 | */ |
542 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
542 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
543 | 543 | { |
544 | 544 | |
545 | 545 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
546 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
546 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
547 | 547 | |
548 | 548 | try { |
549 | 549 | $sth = $this->db->prepare($query); |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
567 | 567 | { |
568 | 568 | $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'; |
569 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
569 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
570 | 570 | |
571 | 571 | try { |
572 | 572 | $sth = $this->db->prepare($query); |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | * @param String $verticalrate vertival rate of flight |
605 | 605 | * @return String success or false |
606 | 606 | */ |
607 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
|
607 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '') |
|
608 | 608 | { |
609 | 609 | global $globalURL, $globalMarineImageFetch; |
610 | 610 | |
@@ -671,31 +671,31 @@ discard block |
||
671 | 671 | } |
672 | 672 | |
673 | 673 | |
674 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
674 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
675 | 675 | { |
676 | 676 | $date = date("Y-m-d H:i:s", time()); |
677 | 677 | } |
678 | 678 | |
679 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
680 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
681 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
682 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
683 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
684 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
685 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
686 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
687 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
688 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
689 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
690 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
691 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
692 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
679 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
680 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
681 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
682 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
683 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
684 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
685 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
686 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
687 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
688 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
689 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
690 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
691 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
692 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
693 | 693 | |
694 | 694 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
695 | 695 | $Image = new Image($this->db); |
696 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
696 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
697 | 697 | if (!isset($image_array[0]['mmsi'])) { |
698 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
698 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
699 | 699 | } |
700 | 700 | unset($Image); |
701 | 701 | } |
@@ -707,10 +707,10 @@ discard block |
||
707 | 707 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
708 | 708 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
709 | 709 | if ($arrival_date == '') $arrival_date = NULL; |
710 | - $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) |
|
710 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
711 | 711 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
712 | 712 | |
713 | - $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); |
|
713 | + $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); |
|
714 | 714 | try { |
715 | 715 | |
716 | 716 | $sth = $this->db->prepare($query); |
@@ -735,13 +735,13 @@ discard block |
||
735 | 735 | { |
736 | 736 | global $globalDBdriver, $globalTimezone; |
737 | 737 | if ($globalDBdriver == 'mysql') { |
738 | - $query = "SELECT marine_output.ident FROM marine_output |
|
738 | + $query = "SELECT marine_output.ident FROM marine_output |
|
739 | 739 | WHERE marine_output.ident = :ident |
740 | 740 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
741 | 741 | AND marine_output.date < UTC_TIMESTAMP()"; |
742 | 742 | $query_data = array(':ident' => $ident); |
743 | 743 | } else { |
744 | - $query = "SELECT marine_output.ident FROM marine_output |
|
744 | + $query = "SELECT marine_output.ident FROM marine_output |
|
745 | 745 | WHERE marine_output.ident = :ident |
746 | 746 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
747 | 747 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -750,8 +750,8 @@ discard block |
||
750 | 750 | |
751 | 751 | $sth = $this->db->prepare($query); |
752 | 752 | $sth->execute($query_data); |
753 | - $ident_result=''; |
|
754 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
753 | + $ident_result = ''; |
|
754 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
755 | 755 | { |
756 | 756 | $ident_result = $row['ident']; |
757 | 757 | } |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | return false; |
778 | 778 | } else { |
779 | 779 | $q_array = explode(" ", $q); |
780 | - foreach ($q_array as $q_item){ |
|
781 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
780 | + foreach ($q_array as $q_item) { |
|
781 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
782 | 782 | $additional_query .= " AND ("; |
783 | 783 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
784 | 784 | $additional_query .= ")"; |
@@ -786,11 +786,11 @@ discard block |
||
786 | 786 | } |
787 | 787 | } |
788 | 788 | if ($globalDBdriver == 'mysql') { |
789 | - $query = "SELECT marine_output.* FROM marine_output |
|
789 | + $query = "SELECT marine_output.* FROM marine_output |
|
790 | 790 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
791 | 791 | AND marine_output.date < UTC_TIMESTAMP()"; |
792 | 792 | } else { |
793 | - $query = "SELECT marine_output.* FROM marine_output |
|
793 | + $query = "SELECT marine_output.* FROM marine_output |
|
794 | 794 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
795 | 795 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
796 | 796 | } |
@@ -809,16 +809,16 @@ discard block |
||
809 | 809 | * |
810 | 810 | */ |
811 | 811 | |
812 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
812 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
813 | 813 | { |
814 | 814 | global $globalDBdriver, $globalArchive; |
815 | 815 | //$filter_query = $this->getFilter($filters,true,true); |
816 | - $Connection= new Connection($this->db); |
|
816 | + $Connection = new Connection($this->db); |
|
817 | 817 | if (!$Connection->tableExists('countries')) return array(); |
818 | 818 | require_once('class.SpotterLive.php'); |
819 | 819 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
820 | 820 | $MarineLive = new MarineLive($this->db); |
821 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
821 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
822 | 822 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
823 | 823 | if ($olderthanmonths > 0) { |
824 | 824 | if ($globalDBdriver == 'mysql') { |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | } else { |
839 | 839 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
840 | 840 | $MarineArchive = new MarineArchive($this->db); |
841 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
841 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
842 | 842 | $filter_query .= " over_country <> ''"; |
843 | 843 | if ($olderthanmonths > 0) { |
844 | 844 | if ($globalDBdriver == 'mysql') { |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | $flight_array = array(); |
867 | 867 | $temp_array = array(); |
868 | 868 | |
869 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
869 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
870 | 870 | { |
871 | 871 | $temp_array['marine_count'] = $row['nb']; |
872 | 872 | $temp_array['marine_country'] = $row['name']; |
@@ -885,11 +885,11 @@ discard block |
||
885 | 885 | * @return Array the callsign list |
886 | 886 | * |
887 | 887 | */ |
888 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
888 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
889 | 889 | { |
890 | 890 | global $globalDBdriver; |
891 | - $filter_query = $this->getFilter($filters,true,true); |
|
892 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
891 | + $filter_query = $this->getFilter($filters, true, true); |
|
892 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
893 | 893 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
894 | 894 | if ($olderthanmonths > 0) { |
895 | 895 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -903,28 +903,28 @@ discard block |
||
903 | 903 | if ($year != '') { |
904 | 904 | if ($globalDBdriver == 'mysql') { |
905 | 905 | $query .= " AND YEAR(marine_output.date) = :year"; |
906 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
906 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
907 | 907 | } else { |
908 | 908 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
909 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
909 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
910 | 910 | } |
911 | 911 | } |
912 | 912 | if ($month != '') { |
913 | 913 | if ($globalDBdriver == 'mysql') { |
914 | 914 | $query .= " AND MONTH(marine_output.date) = :month"; |
915 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
915 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
916 | 916 | } else { |
917 | 917 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
918 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
918 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
919 | 919 | } |
920 | 920 | } |
921 | 921 | if ($day != '') { |
922 | 922 | if ($globalDBdriver == 'mysql') { |
923 | 923 | $query .= " AND DAY(marine_output.date) = :day"; |
924 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
924 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
925 | 925 | } else { |
926 | 926 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
927 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
927 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
928 | 928 | } |
929 | 929 | } |
930 | 930 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | $callsign_array = array(); |
937 | 937 | $temp_array = array(); |
938 | 938 | |
939 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
939 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
940 | 940 | { |
941 | 941 | $temp_array['callsign_icao'] = $row['ident']; |
942 | 942 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | $date_array = array(); |
989 | 989 | $temp_array = array(); |
990 | 990 | |
991 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
991 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
992 | 992 | { |
993 | 993 | $temp_array['date_name'] = $row['date_name']; |
994 | 994 | $temp_array['date_count'] = $row['date_count']; |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | $datetime = new DateTime(); |
1015 | 1015 | $offset = $datetime->format('P'); |
1016 | 1016 | } else $offset = '+00:00'; |
1017 | - $filter_query = $this->getFilter($filters,true,true); |
|
1017 | + $filter_query = $this->getFilter($filters, true, true); |
|
1018 | 1018 | if ($globalDBdriver == 'mysql') { |
1019 | 1019 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1020 | 1020 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | $date_array = array(); |
1036 | 1036 | $temp_array = array(); |
1037 | 1037 | |
1038 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1038 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1039 | 1039 | { |
1040 | 1040 | $temp_array['date_name'] = $row['date_name']; |
1041 | 1041 | $temp_array['date_count'] = $row['date_count']; |
@@ -1060,7 +1060,7 @@ discard block |
||
1060 | 1060 | $datetime = new DateTime(); |
1061 | 1061 | $offset = $datetime->format('P'); |
1062 | 1062 | } else $offset = '+00:00'; |
1063 | - $filter_query = $this->getFilter($filters,true,true); |
|
1063 | + $filter_query = $this->getFilter($filters, true, true); |
|
1064 | 1064 | if ($globalDBdriver == 'mysql') { |
1065 | 1065 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1066 | 1066 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | $date_array = array(); |
1082 | 1082 | $temp_array = array(); |
1083 | 1083 | |
1084 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1084 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1085 | 1085 | { |
1086 | 1086 | $temp_array['date_name'] = $row['date_name']; |
1087 | 1087 | $temp_array['date_count'] = $row['date_count']; |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | $date_array = array(); |
1129 | 1129 | $temp_array = array(); |
1130 | 1130 | |
1131 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1131 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1132 | 1132 | { |
1133 | 1133 | $temp_array['month_name'] = $row['month_name']; |
1134 | 1134 | $temp_array['year_name'] = $row['year_name']; |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | $datetime = new DateTime(); |
1158 | 1158 | $offset = $datetime->format('P'); |
1159 | 1159 | } else $offset = '+00:00'; |
1160 | - $filter_query = $this->getFilter($filters,true,true); |
|
1160 | + $filter_query = $this->getFilter($filters, true, true); |
|
1161 | 1161 | if ($globalDBdriver == 'mysql') { |
1162 | 1162 | $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 |
1163 | 1163 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | $date_array = array(); |
1179 | 1179 | $temp_array = array(); |
1180 | 1180 | |
1181 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1181 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1182 | 1182 | { |
1183 | 1183 | $temp_array['year_name'] = $row['year_name']; |
1184 | 1184 | $temp_array['month_name'] = $row['month_name']; |
@@ -1198,7 +1198,7 @@ discard block |
||
1198 | 1198 | * @return Array the hour list |
1199 | 1199 | * |
1200 | 1200 | */ |
1201 | - public function countAllHours($orderby,$filters = array()) |
|
1201 | + public function countAllHours($orderby, $filters = array()) |
|
1202 | 1202 | { |
1203 | 1203 | global $globalTimezone, $globalDBdriver; |
1204 | 1204 | if ($globalTimezone != '') { |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | $hour_array = array(); |
1247 | 1247 | $temp_array = array(); |
1248 | 1248 | |
1249 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1249 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1250 | 1250 | { |
1251 | 1251 | $temp_array['hour_name'] = $row['hour_name']; |
1252 | 1252 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1268,8 +1268,8 @@ discard block |
||
1268 | 1268 | public function countAllHoursByDate($date, $filters = array()) |
1269 | 1269 | { |
1270 | 1270 | global $globalTimezone, $globalDBdriver; |
1271 | - $filter_query = $this->getFilter($filters,true,true); |
|
1272 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1271 | + $filter_query = $this->getFilter($filters, true, true); |
|
1272 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1273 | 1273 | if ($globalTimezone != '') { |
1274 | 1274 | date_default_timezone_set($globalTimezone); |
1275 | 1275 | $datetime = new DateTime($date); |
@@ -1277,12 +1277,12 @@ discard block |
||
1277 | 1277 | } else $offset = '+00:00'; |
1278 | 1278 | |
1279 | 1279 | if ($globalDBdriver == 'mysql') { |
1280 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1280 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1281 | 1281 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
1282 | 1282 | GROUP BY hour_name |
1283 | 1283 | ORDER BY hour_name ASC"; |
1284 | 1284 | } else { |
1285 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1285 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1286 | 1286 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1287 | 1287 | GROUP BY hour_name |
1288 | 1288 | ORDER BY hour_name ASC"; |
@@ -1294,7 +1294,7 @@ discard block |
||
1294 | 1294 | $hour_array = array(); |
1295 | 1295 | $temp_array = array(); |
1296 | 1296 | |
1297 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1297 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1298 | 1298 | { |
1299 | 1299 | $temp_array['hour_name'] = $row['hour_name']; |
1300 | 1300 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1316,8 +1316,8 @@ discard block |
||
1316 | 1316 | public function countAllHoursByIdent($ident, $filters = array()) |
1317 | 1317 | { |
1318 | 1318 | global $globalTimezone, $globalDBdriver; |
1319 | - $filter_query = $this->getFilter($filters,true,true); |
|
1320 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1319 | + $filter_query = $this->getFilter($filters, true, true); |
|
1320 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1321 | 1321 | if ($globalTimezone != '') { |
1322 | 1322 | date_default_timezone_set($globalTimezone); |
1323 | 1323 | $datetime = new DateTime(); |
@@ -1325,12 +1325,12 @@ discard block |
||
1325 | 1325 | } else $offset = '+00:00'; |
1326 | 1326 | |
1327 | 1327 | if ($globalDBdriver == 'mysql') { |
1328 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1328 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1329 | 1329 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1330 | 1330 | GROUP BY hour_name |
1331 | 1331 | ORDER BY hour_name ASC"; |
1332 | 1332 | } else { |
1333 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1333 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1334 | 1334 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1335 | 1335 | GROUP BY hour_name |
1336 | 1336 | ORDER BY hour_name ASC"; |
@@ -1338,12 +1338,12 @@ discard block |
||
1338 | 1338 | |
1339 | 1339 | |
1340 | 1340 | $sth = $this->db->prepare($query); |
1341 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1341 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1342 | 1342 | |
1343 | 1343 | $hour_array = array(); |
1344 | 1344 | $temp_array = array(); |
1345 | 1345 | |
1346 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1346 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1347 | 1347 | { |
1348 | 1348 | $temp_array['hour_name'] = $row['hour_name']; |
1349 | 1349 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1362,33 +1362,33 @@ discard block |
||
1362 | 1362 | * @return Integer the number of vessels |
1363 | 1363 | * |
1364 | 1364 | */ |
1365 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
1365 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
1366 | 1366 | { |
1367 | 1367 | global $globalDBdriver; |
1368 | 1368 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
1369 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1369 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1370 | 1370 | $query_values = array(); |
1371 | 1371 | $query = ''; |
1372 | 1372 | if ($year != '') { |
1373 | 1373 | if ($globalDBdriver == 'mysql') { |
1374 | 1374 | $query .= " AND YEAR(marine_output.date) = :year"; |
1375 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1375 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1376 | 1376 | } else { |
1377 | 1377 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1378 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1378 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1379 | 1379 | } |
1380 | 1380 | } |
1381 | 1381 | if ($month != '') { |
1382 | 1382 | if ($globalDBdriver == 'mysql') { |
1383 | 1383 | $query .= " AND MONTH(marine_output.date) = :month"; |
1384 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1384 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1385 | 1385 | } else { |
1386 | 1386 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1387 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1387 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1388 | 1388 | } |
1389 | 1389 | } |
1390 | 1390 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1391 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1391 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1392 | 1392 | |
1393 | 1393 | $sth = $this->db->prepare($queryi); |
1394 | 1394 | $sth->execute($query_values); |
@@ -1401,32 +1401,32 @@ discard block |
||
1401 | 1401 | * @return Integer the number of vessels |
1402 | 1402 | * |
1403 | 1403 | */ |
1404 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
1404 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
1405 | 1405 | { |
1406 | 1406 | global $globalDBdriver; |
1407 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1407 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1408 | 1408 | $query_values = array(); |
1409 | 1409 | $query = ''; |
1410 | 1410 | if ($year != '') { |
1411 | 1411 | if ($globalDBdriver == 'mysql') { |
1412 | 1412 | $query .= " AND YEAR(marine_output.date) = :year"; |
1413 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1413 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1414 | 1414 | } else { |
1415 | 1415 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1416 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1416 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1417 | 1417 | } |
1418 | 1418 | } |
1419 | 1419 | if ($month != '') { |
1420 | 1420 | if ($globalDBdriver == 'mysql') { |
1421 | 1421 | $query .= " AND MONTH(marine_output.date) = :month"; |
1422 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1422 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1423 | 1423 | } else { |
1424 | 1424 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1425 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1425 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1426 | 1426 | } |
1427 | 1427 | } |
1428 | 1428 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1429 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1429 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1430 | 1430 | |
1431 | 1431 | $sth = $this->db->prepare($queryi); |
1432 | 1432 | $sth->execute($query_values); |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | public function countAllHoursFromToday($filters = array()) |
1444 | 1444 | { |
1445 | 1445 | global $globalTimezone, $globalDBdriver; |
1446 | - $filter_query = $this->getFilter($filters,true,true); |
|
1446 | + $filter_query = $this->getFilter($filters, true, true); |
|
1447 | 1447 | if ($globalTimezone != '') { |
1448 | 1448 | date_default_timezone_set($globalTimezone); |
1449 | 1449 | $datetime = new DateTime(); |
@@ -1451,12 +1451,12 @@ discard block |
||
1451 | 1451 | } else $offset = '+00:00'; |
1452 | 1452 | |
1453 | 1453 | if ($globalDBdriver == 'mysql') { |
1454 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1454 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1455 | 1455 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
1456 | 1456 | GROUP BY hour_name |
1457 | 1457 | ORDER BY hour_name ASC"; |
1458 | 1458 | } else { |
1459 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1459 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1460 | 1460 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1461 | 1461 | GROUP BY hour_name |
1462 | 1462 | ORDER BY hour_name ASC"; |
@@ -1468,7 +1468,7 @@ discard block |
||
1468 | 1468 | $hour_array = array(); |
1469 | 1469 | $temp_array = array(); |
1470 | 1470 | |
1471 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1471 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1472 | 1472 | { |
1473 | 1473 | $temp_array['hour_name'] = $row['hour_name']; |
1474 | 1474 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1487,9 +1487,9 @@ discard block |
||
1487 | 1487 | */ |
1488 | 1488 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1489 | 1489 | { |
1490 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1490 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1491 | 1491 | |
1492 | - $query = "SELECT marine_output.marine_id |
|
1492 | + $query = "SELECT marine_output.marine_id |
|
1493 | 1493 | FROM marine_output |
1494 | 1494 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
1495 | 1495 | |
@@ -1497,7 +1497,7 @@ discard block |
||
1497 | 1497 | $sth = $this->db->prepare($query); |
1498 | 1498 | $sth->execute(); |
1499 | 1499 | |
1500 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1500 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1501 | 1501 | { |
1502 | 1502 | return $row['marine_id']; |
1503 | 1503 | } |
@@ -1522,23 +1522,23 @@ discard block |
||
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | $current_date = date("Y-m-d H:i:s"); |
1525 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1525 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1526 | 1526 | |
1527 | 1527 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1528 | 1528 | |
1529 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1529 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1530 | 1530 | $years = $time_array['years']; |
1531 | 1531 | |
1532 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1532 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1533 | 1533 | $months = $time_array['months']; |
1534 | 1534 | |
1535 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1535 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1536 | 1536 | $days = $time_array['days']; |
1537 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1537 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1538 | 1538 | $hours = $time_array['hours']; |
1539 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1539 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1540 | 1540 | $minutes = $time_array['minutes']; |
1541 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1541 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1542 | 1542 | |
1543 | 1543 | return $time_array; |
1544 | 1544 | } |
@@ -1561,63 +1561,63 @@ discard block |
||
1561 | 1561 | $temp_array['direction_degree'] = $direction; |
1562 | 1562 | $temp_array['direction_shortname'] = "N"; |
1563 | 1563 | $temp_array['direction_fullname'] = "North"; |
1564 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1564 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1565 | 1565 | $temp_array['direction_degree'] = $direction; |
1566 | 1566 | $temp_array['direction_shortname'] = "NNE"; |
1567 | 1567 | $temp_array['direction_fullname'] = "North-Northeast"; |
1568 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1568 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1569 | 1569 | $temp_array['direction_degree'] = $direction; |
1570 | 1570 | $temp_array['direction_shortname'] = "NE"; |
1571 | 1571 | $temp_array['direction_fullname'] = "Northeast"; |
1572 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1572 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1573 | 1573 | $temp_array['direction_degree'] = $direction; |
1574 | 1574 | $temp_array['direction_shortname'] = "ENE"; |
1575 | 1575 | $temp_array['direction_fullname'] = "East-Northeast"; |
1576 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1576 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1577 | 1577 | $temp_array['direction_degree'] = $direction; |
1578 | 1578 | $temp_array['direction_shortname'] = "E"; |
1579 | 1579 | $temp_array['direction_fullname'] = "East"; |
1580 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1580 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1581 | 1581 | $temp_array['direction_degree'] = $direction; |
1582 | 1582 | $temp_array['direction_shortname'] = "ESE"; |
1583 | 1583 | $temp_array['direction_fullname'] = "East-Southeast"; |
1584 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1584 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1585 | 1585 | $temp_array['direction_degree'] = $direction; |
1586 | 1586 | $temp_array['direction_shortname'] = "SE"; |
1587 | 1587 | $temp_array['direction_fullname'] = "Southeast"; |
1588 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1588 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1589 | 1589 | $temp_array['direction_degree'] = $direction; |
1590 | 1590 | $temp_array['direction_shortname'] = "SSE"; |
1591 | 1591 | $temp_array['direction_fullname'] = "South-Southeast"; |
1592 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1592 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1593 | 1593 | $temp_array['direction_degree'] = $direction; |
1594 | 1594 | $temp_array['direction_shortname'] = "S"; |
1595 | 1595 | $temp_array['direction_fullname'] = "South"; |
1596 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1596 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1597 | 1597 | $temp_array['direction_degree'] = $direction; |
1598 | 1598 | $temp_array['direction_shortname'] = "SSW"; |
1599 | 1599 | $temp_array['direction_fullname'] = "South-Southwest"; |
1600 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1600 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1601 | 1601 | $temp_array['direction_degree'] = $direction; |
1602 | 1602 | $temp_array['direction_shortname'] = "SW"; |
1603 | 1603 | $temp_array['direction_fullname'] = "Southwest"; |
1604 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1604 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1605 | 1605 | $temp_array['direction_degree'] = $direction; |
1606 | 1606 | $temp_array['direction_shortname'] = "WSW"; |
1607 | 1607 | $temp_array['direction_fullname'] = "West-Southwest"; |
1608 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1608 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1609 | 1609 | $temp_array['direction_degree'] = $direction; |
1610 | 1610 | $temp_array['direction_shortname'] = "W"; |
1611 | 1611 | $temp_array['direction_fullname'] = "West"; |
1612 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1612 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1613 | 1613 | $temp_array['direction_degree'] = $direction; |
1614 | 1614 | $temp_array['direction_shortname'] = "WNW"; |
1615 | 1615 | $temp_array['direction_fullname'] = "West-Northwest"; |
1616 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1616 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1617 | 1617 | $temp_array['direction_degree'] = $direction; |
1618 | 1618 | $temp_array['direction_shortname'] = "NW"; |
1619 | 1619 | $temp_array['direction_fullname'] = "Northwest"; |
1620 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1620 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1621 | 1621 | $temp_array['direction_degree'] = $direction; |
1622 | 1622 | $temp_array['direction_shortname'] = "NNW"; |
1623 | 1623 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1634,11 +1634,11 @@ discard block |
||
1634 | 1634 | * @param Float $longitude longitute of the flight |
1635 | 1635 | * @return String the countrie |
1636 | 1636 | */ |
1637 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1637 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1638 | 1638 | { |
1639 | 1639 | global $globalDBdriver, $globalDebug; |
1640 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1641 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1640 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1641 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1642 | 1642 | |
1643 | 1643 | $Connection = new Connection($this->db); |
1644 | 1644 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1678,7 +1678,7 @@ discard block |
||
1678 | 1678 | public function getCountryFromISO2($iso2) |
1679 | 1679 | { |
1680 | 1680 | global $globalDBdriver, $globalDebug; |
1681 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1681 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1682 | 1682 | |
1683 | 1683 | $Connection = new Connection($this->db); |
1684 | 1684 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1726,7 +1726,7 @@ discard block |
||
1726 | 1726 | |
1727 | 1727 | $bitly_data = json_decode($bitly_data); |
1728 | 1728 | $bitly_url = ''; |
1729 | - if ($bitly_data->status_txt = "OK"){ |
|
1729 | + if ($bitly_data->status_txt = "OK") { |
|
1730 | 1730 | $bitly_url = $bitly_data->data->url; |
1731 | 1731 | } |
1732 | 1732 | |
@@ -1740,11 +1740,11 @@ discard block |
||
1740 | 1740 | * @return Array the vessel type list |
1741 | 1741 | * |
1742 | 1742 | */ |
1743 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1743 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1744 | 1744 | { |
1745 | 1745 | global $globalDBdriver; |
1746 | - $filter_query = $this->getFilter($filters,true,true); |
|
1747 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
1746 | + $filter_query = $this->getFilter($filters, true, true); |
|
1747 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
1748 | 1748 | FROM marine_output ".$filter_query." marine_output.type <> ''"; |
1749 | 1749 | if ($olderthanmonths > 0) { |
1750 | 1750 | if ($globalDBdriver == 'mysql') { |
@@ -1764,28 +1764,28 @@ discard block |
||
1764 | 1764 | if ($year != '') { |
1765 | 1765 | if ($globalDBdriver == 'mysql') { |
1766 | 1766 | $query .= " AND YEAR(marine_output.date) = :year"; |
1767 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1767 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1768 | 1768 | } else { |
1769 | 1769 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1770 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1770 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1771 | 1771 | } |
1772 | 1772 | } |
1773 | 1773 | if ($month != '') { |
1774 | 1774 | if ($globalDBdriver == 'mysql') { |
1775 | 1775 | $query .= " AND MONTH(marine_output.date) = :month"; |
1776 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1776 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1777 | 1777 | } else { |
1778 | 1778 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1779 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1779 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1780 | 1780 | } |
1781 | 1781 | } |
1782 | 1782 | if ($day != '') { |
1783 | 1783 | if ($globalDBdriver == 'mysql') { |
1784 | 1784 | $query .= " AND DAY(marine_output.date) = :day"; |
1785 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1785 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1786 | 1786 | } else { |
1787 | 1787 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1788 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1788 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1789 | 1789 | } |
1790 | 1790 | } |
1791 | 1791 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
@@ -1794,7 +1794,7 @@ discard block |
||
1794 | 1794 | $sth->execute($query_values); |
1795 | 1795 | $marine_array = array(); |
1796 | 1796 | $temp_array = array(); |
1797 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1797 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1798 | 1798 | { |
1799 | 1799 | $temp_array['marine_type'] = $row['marine_type']; |
1800 | 1800 | $temp_array['marine_type_count'] = $row['marine_type_count']; |
@@ -1805,7 +1805,7 @@ discard block |
||
1805 | 1805 | |
1806 | 1806 | public function getOrderBy() |
1807 | 1807 | { |
1808 | - $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")); |
|
1808 | + $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")); |
|
1809 | 1809 | |
1810 | 1810 | return $orderby; |
1811 | 1811 |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | try { |
983 | 983 | $sth = $this->db->prepare($query); |
984 | 984 | $sth->execute($query_values); |
985 | - } catch(PDOException $e) { |
|
985 | + } catch (PDOException $e) { |
|
986 | 986 | echo "error : ".$e->getMessage(); |
987 | 987 | } |
988 | 988 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1000,19 +1000,19 @@ discard block |
||
1000 | 1000 | try { |
1001 | 1001 | $sth = $this->db->prepare($query); |
1002 | 1002 | $sth->execute($query_values); |
1003 | - } catch(PDOException $e) { |
|
1003 | + } catch (PDOException $e) { |
|
1004 | 1004 | echo "error : ".$e->getMessage(); |
1005 | 1005 | } |
1006 | 1006 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1007 | 1007 | return $all; |
1008 | 1008 | } |
1009 | 1009 | public function getAllNOTAMtext() { |
1010 | - $query = 'SELECT full_notam FROM notam'; |
|
1010 | + $query = 'SELECT full_notam FROM notam'; |
|
1011 | 1011 | $query_values = array(); |
1012 | 1012 | try { |
1013 | 1013 | $sth = $this->db->prepare($query); |
1014 | 1014 | $sth->execute($query_values); |
1015 | - } catch(PDOException $e) { |
|
1015 | + } catch (PDOException $e) { |
|
1016 | 1016 | echo "error : ".$e->getMessage(); |
1017 | 1017 | } |
1018 | 1018 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1021,13 +1021,13 @@ discard block |
||
1021 | 1021 | public function createNOTAMtextFile($filename) { |
1022 | 1022 | $allnotam_result = $this->getAllNOTAMtext(); |
1023 | 1023 | $notamtext = ''; |
1024 | - foreach($allnotam_result as $notam) { |
|
1024 | + foreach ($allnotam_result as $notam) { |
|
1025 | 1025 | $notamtext .= '%%'."\n"; |
1026 | 1026 | $notamtext .= $notam['full_notam']; |
1027 | 1027 | $notamtext .= "\n".'%%'."\n"; |
1028 | 1028 | } |
1029 | 1029 | //$allnotam = implode('\n%%%%\n',$allnotam_result); |
1030 | - file_put_contents($filename,$notamtext); |
|
1030 | + file_put_contents($filename, $notamtext); |
|
1031 | 1031 | } |
1032 | 1032 | public function parseNOTAMtextFile($filename) { |
1033 | 1033 | $data = file_get_contents($filename); |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | try { |
1049 | 1049 | $sth = $this->db->prepare($query); |
1050 | 1050 | $sth->execute($query_values); |
1051 | - } catch(PDOException $e) { |
|
1051 | + } catch (PDOException $e) { |
|
1052 | 1052 | echo "error : ".$e->getMessage(); |
1053 | 1053 | } |
1054 | 1054 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1057,10 +1057,10 @@ discard block |
||
1057 | 1057 | public function getAllNOTAMbyCoord($coord) { |
1058 | 1058 | global $globalDBdriver; |
1059 | 1059 | if (is_array($coord)) { |
1060 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1061 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1062 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1063 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1060 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1061 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1062 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1063 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1064 | 1064 | if ($minlat > $maxlat) { |
1065 | 1065 | $tmplat = $minlat; |
1066 | 1066 | $minlat = $maxlat; |
@@ -1082,19 +1082,19 @@ discard block |
||
1082 | 1082 | try { |
1083 | 1083 | $sth = $this->db->prepare($query); |
1084 | 1084 | $sth->execute($query_values); |
1085 | - } catch(PDOException $e) { |
|
1085 | + } catch (PDOException $e) { |
|
1086 | 1086 | echo "error : ".$e->getMessage(); |
1087 | 1087 | } |
1088 | 1088 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1089 | 1089 | return $all; |
1090 | 1090 | } |
1091 | - public function getAllNOTAMbyCoordScope($coord,$scope) { |
|
1091 | + public function getAllNOTAMbyCoordScope($coord, $scope) { |
|
1092 | 1092 | global $globalDBdriver; |
1093 | 1093 | if (is_array($coord)) { |
1094 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1095 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1096 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1097 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1094 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1095 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1096 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1097 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1098 | 1098 | } else return array(); |
1099 | 1099 | if ($globalDBdriver == 'mysql') { |
1100 | 1100 | $query = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope'; |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | try { |
1107 | 1107 | $sth = $this->db->prepare($query); |
1108 | 1108 | $sth->execute($query_values); |
1109 | - } catch(PDOException $e) { |
|
1109 | + } catch (PDOException $e) { |
|
1110 | 1110 | echo "error : ".$e->getMessage(); |
1111 | 1111 | } |
1112 | 1112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | try { |
1119 | 1119 | $sth = $this->db->prepare($query); |
1120 | 1120 | $sth->execute($query_values); |
1121 | - } catch(PDOException $e) { |
|
1121 | + } catch (PDOException $e) { |
|
1122 | 1122 | return "error : ".$e->getMessage(); |
1123 | 1123 | } |
1124 | 1124 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1126,13 +1126,13 @@ discard block |
||
1126 | 1126 | else return array(); |
1127 | 1127 | } |
1128 | 1128 | |
1129 | - public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) { |
|
1129 | + public function addNOTAM($ref, $title, $type, $fir, $code, $rules, $scope, $lower_limit, $upper_limit, $center_latitude, $center_longitude, $radius, $date_begin, $date_end, $permanent, $text, $full_notam) { |
|
1130 | 1130 | $query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)"; |
1131 | - $query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam); |
|
1131 | + $query_values = array(':ref' => $ref, ':title' => $title, ':type' => $type, ':fir' => $fir, ':code' => $code, ':rules' => $rules, ':scope' => $scope, ':lower_limit' => $lower_limit, ':upper_limit' => $upper_limit, ':center_latitude' => $center_latitude, ':center_longitude' => $center_longitude, ':radius' => $radius, ':date_begin' => $date_begin, ':date_end' => $date_end, ':permanent' => $permanent, ':text' => $text, ':full_notam' => $full_notam); |
|
1132 | 1132 | try { |
1133 | 1133 | $sth = $this->db->prepare($query); |
1134 | 1134 | $sth->execute($query_values); |
1135 | - } catch(PDOException $e) { |
|
1135 | + } catch (PDOException $e) { |
|
1136 | 1136 | return "error : ".$e->getMessage(); |
1137 | 1137 | } |
1138 | 1138 | } |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | try { |
1144 | 1144 | $sth = $this->db->prepare($query); |
1145 | 1145 | $sth->execute($query_values); |
1146 | - } catch(PDOException $e) { |
|
1146 | + } catch (PDOException $e) { |
|
1147 | 1147 | return "error : ".$e->getMessage(); |
1148 | 1148 | } |
1149 | 1149 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | try { |
1159 | 1159 | $sth = $this->db->prepare($query); |
1160 | 1160 | $sth->execute($query_values); |
1161 | - } catch(PDOException $e) { |
|
1161 | + } catch (PDOException $e) { |
|
1162 | 1162 | return "error : ".$e->getMessage(); |
1163 | 1163 | } |
1164 | 1164 | } |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | try { |
1169 | 1169 | $sth = $this->db->prepare($query); |
1170 | 1170 | $sth->execute($query_values); |
1171 | - } catch(PDOException $e) { |
|
1171 | + } catch (PDOException $e) { |
|
1172 | 1172 | return "error : ".$e->getMessage(); |
1173 | 1173 | } |
1174 | 1174 | } |
@@ -1177,7 +1177,7 @@ discard block |
||
1177 | 1177 | try { |
1178 | 1178 | $sth = $this->db->prepare($query); |
1179 | 1179 | $sth->execute(); |
1180 | - } catch(PDOException $e) { |
|
1180 | + } catch (PDOException $e) { |
|
1181 | 1181 | return "error : ".$e->getMessage(); |
1182 | 1182 | } |
1183 | 1183 | } |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | try { |
1187 | 1187 | $sth = $this->db->prepare($query); |
1188 | 1188 | $sth->execute(); |
1189 | - } catch(PDOException $e) { |
|
1189 | + } catch (PDOException $e) { |
|
1190 | 1190 | return "error : ".$e->getMessage(); |
1191 | 1191 | } |
1192 | 1192 | } |
@@ -1194,14 +1194,14 @@ discard block |
||
1194 | 1194 | public function updateNOTAM() { |
1195 | 1195 | global $globalNOTAMAirports; |
1196 | 1196 | if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) { |
1197 | - foreach (array_chunk($globalNOTAMAirports,10) as $airport) { |
|
1198 | - $airport_icao = implode(',',$airport); |
|
1197 | + foreach (array_chunk($globalNOTAMAirports, 10) as $airport) { |
|
1198 | + $airport_icao = implode(',', $airport); |
|
1199 | 1199 | $alldata = $this->downloadNOTAM($airport_icao); |
1200 | 1200 | if (count($alldata) > 0) { |
1201 | 1201 | foreach ($alldata as $initial_data) { |
1202 | 1202 | $data = $this->parse($initial_data); |
1203 | 1203 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1204 | - if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1204 | + if (count($notamref) == 0) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | } |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | foreach ($alldata as $initial_data) { |
1215 | 1215 | $data = $this->parse($initial_data); |
1216 | 1216 | $notamref = $this->getNOTAMbyRef($data['ref']); |
1217 | - if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1217 | + if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
1218 | 1218 | } |
1219 | 1219 | } |
1220 | 1220 | } |
@@ -1223,12 +1223,12 @@ discard block |
||
1223 | 1223 | global $globalTransaction; |
1224 | 1224 | $Spotter = new Spotter($this->db); |
1225 | 1225 | $allairports = $Spotter->getAllAirportInfo(); |
1226 | - foreach (array_chunk($allairports,20) as $airport) { |
|
1226 | + foreach (array_chunk($allairports, 20) as $airport) { |
|
1227 | 1227 | $airports_icao = array(); |
1228 | - foreach($airport as $icao) { |
|
1228 | + foreach ($airport as $icao) { |
|
1229 | 1229 | if (isset($icao['icao'])) $airports_icao[] = $icao['icao']; |
1230 | 1230 | } |
1231 | - $airport_icao = implode(',',$airports_icao); |
|
1231 | + $airport_icao = implode(',', $airports_icao); |
|
1232 | 1232 | $alldata = $this->downloadNOTAM($airport_icao); |
1233 | 1233 | if ($globalTransaction) $this->db->beginTransaction(); |
1234 | 1234 | if (count($alldata) > 0) { |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | if (count($notamref) == 0) { |
1242 | 1242 | if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']); |
1243 | 1243 | if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']); |
1244 | - elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1244 | + elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'], '', '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
1245 | 1245 | } |
1246 | 1246 | } |
1247 | 1247 | } |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | date_default_timezone_set("UTC"); |
1256 | 1256 | $Common = new Common(); |
1257 | 1257 | //$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
1258 | - $url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
1258 | + $url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs'); |
|
1259 | 1259 | $data = $Common->getData($url); |
1260 | 1260 | preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches); |
1261 | 1261 | //print_r($matches); |
@@ -1272,9 +1272,9 @@ discard block |
||
1272 | 1272 | $result['permanent'] = ''; |
1273 | 1273 | $result['date_begin'] = NULL; |
1274 | 1274 | $result['date_end'] = NULL; |
1275 | - $data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data); |
|
1275 | + $data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data); |
|
1276 | 1276 | //echo $data."\n"; |
1277 | - $data = preg_split('#\s(?=([A-Z]\)\s))#',$data); |
|
1277 | + $data = preg_split('#\s(?=([A-Z]\)\s))#', $data); |
|
1278 | 1278 | //print_r($data); |
1279 | 1279 | $q = false; |
1280 | 1280 | $a = false; |
@@ -1283,9 +1283,9 @@ discard block |
||
1283 | 1283 | $e = false; |
1284 | 1284 | foreach ($data as $line) { |
1285 | 1285 | $line = trim($line); |
1286 | - if (preg_match('#(^|\s)Q\) (.*)#',$line,$matches) && $q === false) { |
|
1287 | - $line = str_replace(' ','',$line); |
|
1288 | - if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#',$line,$matches)) { |
|
1286 | + if (preg_match('#(^|\s)Q\) (.*)#', $line, $matches) && $q === false) { |
|
1287 | + $line = str_replace(' ', '', $line); |
|
1288 | + if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#', $line, $matches)) { |
|
1289 | 1289 | //if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) { |
1290 | 1290 | //print_r($matches); |
1291 | 1291 | $result['fir'] = $matches[1]; |
@@ -1331,9 +1331,9 @@ discard block |
||
1331 | 1331 | elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning'; |
1332 | 1332 | $result['lower_limit'] = $matches[6]; |
1333 | 1333 | $result['upper_limit'] = $matches[7]; |
1334 | - $latitude = $Common->convertDec($matches[8],'latitude'); |
|
1334 | + $latitude = $Common->convertDec($matches[8], 'latitude'); |
|
1335 | 1335 | if ($matches[9] == 'S') $latitude = -$latitude; |
1336 | - $longitude = $Common->convertDec($matches[10],'longitude'); |
|
1336 | + $longitude = $Common->convertDec($matches[10], 'longitude'); |
|
1337 | 1337 | if ($matches[11] == 'W') $longitude = -$longitude; |
1338 | 1338 | $result['latitude'] = $latitude; |
1339 | 1339 | $result['longitude'] = $longitude; |
@@ -1345,24 +1345,24 @@ discard block |
||
1345 | 1345 | echo "Can't parse : ".$line."\n"; |
1346 | 1346 | } |
1347 | 1347 | } |
1348 | - elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) { |
|
1348 | + elseif (preg_match('#(^|\s)A\) (.*)#', $line, $matches) && $a === false) { |
|
1349 | 1349 | $result['icao'] = $matches[2]; |
1350 | 1350 | $a = true; |
1351 | 1351 | } |
1352 | - elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) { |
|
1352 | + elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches) && $b === false) { |
|
1353 | 1353 | if ($matches[1] > 50) $year = '19'.$matches[2]; |
1354 | 1354 | else $year = '20'.$matches[2]; |
1355 | 1355 | $result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
1356 | 1356 | $b = true; |
1357 | 1357 | } |
1358 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) { |
|
1358 | + elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches) && $c === false) { |
|
1359 | 1359 | if ($matches[2] > 50) $year = '19'.$matches[2]; |
1360 | 1360 | else $year = '20'.$matches[2]; |
1361 | 1361 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
1362 | 1362 | $result['permanent'] = 0; |
1363 | 1363 | $c = true; |
1364 | 1364 | } |
1365 | - elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
1365 | + elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches) && $c === false) { |
|
1366 | 1366 | if ($matches[2] > 50) $year = '19'.$matches[2]; |
1367 | 1367 | else $year = '20'.$matches[2]; |
1368 | 1368 | $result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6]; |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | else $result['permanent'] = 0; |
1373 | 1373 | $c = true; |
1374 | 1374 | } |
1375 | - elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) { |
|
1375 | + elseif (preg_match('#(^|\s)C\) (EST|PERM)$#', $line, $matches) && $c === false) { |
|
1376 | 1376 | $result['date_end'] = '2030/12/20 12:00'; |
1377 | 1377 | if ($matches[2] == 'EST') $result['estimated'] = 1; |
1378 | 1378 | else $result['estimated'] = 0; |
@@ -1380,20 +1380,20 @@ discard block |
||
1380 | 1380 | else $result['permanent'] = 0; |
1381 | 1381 | $c = true; |
1382 | 1382 | } |
1383 | - elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) { |
|
1383 | + elseif (preg_match('#(^|\s)E\) (.*)#', $line, $matches) && $e === false) { |
|
1384 | 1384 | $rtext = array(); |
1385 | - $text = explode(' ',$matches[2]); |
|
1385 | + $text = explode(' ', $matches[2]); |
|
1386 | 1386 | foreach ($text as $word) { |
1387 | 1387 | if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]); |
1388 | - elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3); |
|
1388 | + elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3); |
|
1389 | 1389 | else $rtext[] = $word; |
1390 | 1390 | } |
1391 | - $result['text'] = implode(' ',$rtext); |
|
1391 | + $result['text'] = implode(' ', $rtext); |
|
1392 | 1392 | $e = true; |
1393 | 1393 | //} elseif (preg_match('#F\) (.*)#',$line,$matches)) { |
1394 | 1394 | //} elseif (preg_match('#G\) (.*)#',$line,$matches)) { |
1395 | - } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) { |
|
1396 | - $text = explode(' ',$line); |
|
1395 | + } elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) { |
|
1396 | + $text = explode(' ', $line); |
|
1397 | 1397 | $result['ref'] = $text[0]; |
1398 | 1398 | if ($matches[1] == 'NOTAMN') $result['type'] = 'new'; |
1399 | 1399 | if ($matches[1] == 'NOTAMC') { |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | require_once(dirname(__FILE__).'/class.Image.php'); |
5 | 5 | $global_query = "SELECT tracker_output.* FROM tracker_output"; |
6 | 6 | |
7 | -class Tracker{ |
|
7 | +class Tracker { |
|
8 | 8 | public $db; |
9 | 9 | |
10 | 10 | public function __construct($dbc = null) { |
@@ -19,33 +19,33 @@ discard block |
||
19 | 19 | * @return Array the SQL part |
20 | 20 | */ |
21 | 21 | |
22 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
22 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
23 | 23 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
24 | 24 | $filters = array(); |
25 | 25 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
26 | 26 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
27 | 27 | $filters = $globalStatsFilters[$globalFilterName]; |
28 | 28 | } else { |
29 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
29 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | if (isset($filter[0]['source'])) { |
33 | - $filters = array_merge($filters,$filter); |
|
33 | + $filters = array_merge($filters, $filter); |
|
34 | 34 | } |
35 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
36 | 36 | $filter_query_join = ''; |
37 | 37 | $filter_query_where = ''; |
38 | - foreach($filters as $flt) { |
|
38 | + foreach ($filters as $flt) { |
|
39 | 39 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
40 | 40 | if (isset($flt['source'])) { |
41 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
42 | 42 | } else { |
43 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
43 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | } |
47 | 47 | if (isset($filter['source']) && !empty($filter['source'])) { |
48 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
48 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
49 | 49 | } |
50 | 50 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
51 | 51 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
75 | 75 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
76 | 76 | if ($filter_query_where != '') { |
77 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
77 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
78 | 78 | } |
79 | 79 | $filter_query = $filter_query_join.$filter_query_where; |
80 | 80 | return $filter_query; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return Array the spotter information |
90 | 90 | * |
91 | 91 | */ |
92 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
92 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
93 | 93 | { |
94 | 94 | date_default_timezone_set('UTC'); |
95 | 95 | if (!is_string($query)) |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | $sth = $this->db->prepare($query.$limitQuery); |
110 | 110 | $sth->execute($params); |
111 | 111 | } catch (PDOException $e) { |
112 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
112 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
113 | 113 | exit(); |
114 | 114 | } |
115 | 115 | |
116 | 116 | $num_rows = 0; |
117 | 117 | $spotter_array = array(); |
118 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
118 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
119 | 119 | { |
120 | 120 | $num_rows++; |
121 | 121 | $temp_array = array(); |
@@ -171,17 +171,17 @@ discard block |
||
171 | 171 | { |
172 | 172 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
173 | 173 | } else { |
174 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
174 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
175 | 175 | } |
176 | 176 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
177 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
178 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
177 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
178 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
179 | 179 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
180 | 180 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
181 | 181 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
182 | 182 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
183 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
184 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
183 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
184 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
185 | 185 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
186 | 186 | } |
187 | 187 | } |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | { |
219 | 219 | $limit_array = explode(",", $limit); |
220 | 220 | |
221 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
222 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
221 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
222 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
223 | 223 | |
224 | 224 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
225 | 225 | { |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | $orderby_query = " ORDER BY tracker_output.date DESC"; |
237 | 237 | } |
238 | 238 | |
239 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
239 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
240 | 240 | |
241 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
241 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
242 | 242 | |
243 | 243 | return $spotter_array; |
244 | 244 | } |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | if ($id == '') return array(); |
258 | 258 | $additional_query = "tracker_output.famtrackid = :id"; |
259 | 259 | $query_values = array(':id' => $id); |
260 | - $query = $global_query." WHERE ".$additional_query." "; |
|
261 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
260 | + $query = $global_query." WHERE ".$additional_query." "; |
|
261 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
262 | 262 | return $spotter_array; |
263 | 263 | } |
264 | 264 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $query_values = array(); |
278 | 278 | $limit_query = ''; |
279 | 279 | $additional_query = ''; |
280 | - $filter_query = $this->getFilter($filter,true,true); |
|
280 | + $filter_query = $this->getFilter($filter, true, true); |
|
281 | 281 | if ($ident != "") |
282 | 282 | { |
283 | 283 | if (!is_string($ident)) |
@@ -293,8 +293,8 @@ discard block |
||
293 | 293 | { |
294 | 294 | $limit_array = explode(",", $limit); |
295 | 295 | |
296 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
297 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
296 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
297 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
298 | 298 | |
299 | 299 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
300 | 300 | { |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | return $spotter_array; |
319 | 319 | } |
320 | 320 | |
321 | - public function getTrackerDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
321 | + public function getTrackerDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
322 | 322 | { |
323 | 323 | global $global_query, $globalTimezone, $globalDBdriver; |
324 | 324 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $limit_query = ''; |
327 | 327 | $additional_query = ''; |
328 | 328 | |
329 | - $filter_query = $this->getFilter($filter,true,true); |
|
329 | + $filter_query = $this->getFilter($filter, true, true); |
|
330 | 330 | |
331 | 331 | if ($date != "") |
332 | 332 | { |
@@ -352,8 +352,8 @@ discard block |
||
352 | 352 | { |
353 | 353 | $limit_array = explode(",", $limit); |
354 | 354 | |
355 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
356 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
355 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
356 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
357 | 357 | |
358 | 358 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
359 | 359 | { |
@@ -384,11 +384,11 @@ discard block |
||
384 | 384 | * @return Array list of source name |
385 | 385 | * |
386 | 386 | */ |
387 | - public function getAllSourceName($type = '',$filters = array()) |
|
387 | + public function getAllSourceName($type = '', $filters = array()) |
|
388 | 388 | { |
389 | - $filter_query = $this->getFilter($filters,true,true); |
|
389 | + $filter_query = $this->getFilter($filters, true, true); |
|
390 | 390 | $query_values = array(); |
391 | - $query = "SELECT DISTINCT tracker_output.source_name |
|
391 | + $query = "SELECT DISTINCT tracker_output.source_name |
|
392 | 392 | FROM tracker_output".$filter_query." tracker_output.source_name <> ''"; |
393 | 393 | if ($type != '') { |
394 | 394 | $query_values = array(':type' => $type); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $source_array = array(); |
404 | 404 | $temp_array = array(); |
405 | 405 | |
406 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
406 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
407 | 407 | { |
408 | 408 | $temp_array['source_name'] = $row['source_name']; |
409 | 409 | $source_array[] = $temp_array; |
@@ -420,8 +420,8 @@ discard block |
||
420 | 420 | */ |
421 | 421 | public function getAllIdents($filters = array()) |
422 | 422 | { |
423 | - $filter_query = $this->getFilter($filters,true,true); |
|
424 | - $query = "SELECT DISTINCT tracker_output.ident |
|
423 | + $filter_query = $this->getFilter($filters, true, true); |
|
424 | + $query = "SELECT DISTINCT tracker_output.ident |
|
425 | 425 | FROM tracker_output".$filter_query." tracker_output.ident <> '' |
426 | 426 | ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0"; |
427 | 427 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | $ident_array = array(); |
432 | 432 | $temp_array = array(); |
433 | 433 | |
434 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
434 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
435 | 435 | { |
436 | 436 | $temp_array['ident'] = $row['ident']; |
437 | 437 | $ident_array[] = $temp_array; |
@@ -456,12 +456,12 @@ discard block |
||
456 | 456 | } else $offset = '+00:00'; |
457 | 457 | |
458 | 458 | if ($globalDBdriver == 'mysql') { |
459 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
459 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
460 | 460 | FROM tracker_output |
461 | 461 | WHERE tracker_output.date <> '' |
462 | 462 | ORDER BY tracker_output.date ASC LIMIT 0,200"; |
463 | 463 | } else { |
464 | - $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
464 | + $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
465 | 465 | FROM tracker_output |
466 | 466 | WHERE tracker_output.date <> '' |
467 | 467 | ORDER BY tracker_output.date ASC LIMIT 0,200"; |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | $date_array = array(); |
474 | 474 | $temp_array = array(); |
475 | 475 | |
476 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
476 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
477 | 477 | { |
478 | 478 | $temp_array['date'] = $row['date']; |
479 | 479 | |
@@ -492,11 +492,11 @@ discard block |
||
492 | 492 | * @return String success or false |
493 | 493 | * |
494 | 494 | */ |
495 | - public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL) |
|
495 | + public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL) |
|
496 | 496 | { |
497 | 497 | |
498 | 498 | $query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid'; |
499 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
499 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident); |
|
500 | 500 | |
501 | 501 | try { |
502 | 502 | $sth = $this->db->prepare($query); |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '') |
521 | 521 | { |
522 | 522 | $query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid'; |
523 | - $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
523 | + $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
524 | 524 | |
525 | 525 | try { |
526 | 526 | $sth = $this->db->prepare($query); |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * @param String $verticalrate vertival rate of flight |
561 | 561 | * @return String success or false |
562 | 562 | */ |
563 | - public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '') |
|
563 | + public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '') |
|
564 | 564 | { |
565 | 565 | global $globalURL; |
566 | 566 | |
@@ -628,21 +628,21 @@ discard block |
||
628 | 628 | } |
629 | 629 | |
630 | 630 | |
631 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
631 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
632 | 632 | { |
633 | 633 | $date = date("Y-m-d H:i:s", time()); |
634 | 634 | } |
635 | 635 | |
636 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
637 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
638 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
639 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
640 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
641 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
642 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
643 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
644 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
645 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
636 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
637 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
638 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
639 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
640 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
641 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
642 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
643 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
644 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
645 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
646 | 646 | |
647 | 647 | if ($latitude == '' && $longitude == '') { |
648 | 648 | $latitude = 0; |
@@ -650,10 +650,10 @@ discard block |
||
650 | 650 | } |
651 | 651 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
652 | 652 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
653 | - $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
653 | + $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
654 | 654 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
655 | 655 | |
656 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
656 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':comment' => $comment, ':type' => $type); |
|
657 | 657 | |
658 | 658 | try { |
659 | 659 | |
@@ -679,13 +679,13 @@ discard block |
||
679 | 679 | { |
680 | 680 | global $globalDBdriver, $globalTimezone; |
681 | 681 | if ($globalDBdriver == 'mysql') { |
682 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
682 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
683 | 683 | WHERE tracker_output.ident = :ident |
684 | 684 | AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
685 | 685 | AND tracker_output.date < UTC_TIMESTAMP()"; |
686 | 686 | $query_data = array(':ident' => $ident); |
687 | 687 | } else { |
688 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
688 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
689 | 689 | WHERE tracker_output.ident = :ident |
690 | 690 | AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
691 | 691 | AND tracker_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -694,8 +694,8 @@ discard block |
||
694 | 694 | |
695 | 695 | $sth = $this->db->prepare($query); |
696 | 696 | $sth->execute($query_data); |
697 | - $ident_result=''; |
|
698 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
697 | + $ident_result = ''; |
|
698 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
699 | 699 | { |
700 | 700 | $ident_result = $row['ident']; |
701 | 701 | } |
@@ -721,8 +721,8 @@ discard block |
||
721 | 721 | return false; |
722 | 722 | } else { |
723 | 723 | $q_array = explode(" ", $q); |
724 | - foreach ($q_array as $q_item){ |
|
725 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
724 | + foreach ($q_array as $q_item) { |
|
725 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
726 | 726 | $additional_query .= " AND ("; |
727 | 727 | $additional_query .= "(tracker_output.ident like '%".$q_item."%')"; |
728 | 728 | $additional_query .= ")"; |
@@ -730,11 +730,11 @@ discard block |
||
730 | 730 | } |
731 | 731 | } |
732 | 732 | if ($globalDBdriver == 'mysql') { |
733 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
733 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
734 | 734 | WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
735 | 735 | AND tracker_output.date < UTC_TIMESTAMP()"; |
736 | 736 | } else { |
737 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
737 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
738 | 738 | WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
739 | 739 | AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
740 | 740 | } |
@@ -753,16 +753,16 @@ discard block |
||
753 | 753 | * |
754 | 754 | */ |
755 | 755 | |
756 | - public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
756 | + public function countAllTrackerOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
757 | 757 | { |
758 | 758 | global $globalDBdriver, $globalArchive; |
759 | 759 | //$filter_query = $this->getFilter($filters,true,true); |
760 | - $Connection= new Connection($this->db); |
|
760 | + $Connection = new Connection($this->db); |
|
761 | 761 | if (!$Connection->tableExists('countries')) return array(); |
762 | 762 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
763 | 763 | require_once('class.TrackerLive.php'); |
764 | 764 | $TrackerLive = new TrackerLive($this->db); |
765 | - $filter_query = $TrackerLive->getFilter($filters,true,true); |
|
765 | + $filter_query = $TrackerLive->getFilter($filters, true, true); |
|
766 | 766 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
767 | 767 | if ($olderthanmonths > 0) { |
768 | 768 | if ($globalDBdriver == 'mysql') { |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | } else { |
783 | 783 | require_once('class.TrackerArchive.php'); |
784 | 784 | $TrackerArchive = new TrackerArchive($this->db); |
785 | - $filter_query = $TrackerArchive->getFilter($filters,true,true); |
|
785 | + $filter_query = $TrackerArchive->getFilter($filters, true, true); |
|
786 | 786 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
787 | 787 | if ($olderthanmonths > 0) { |
788 | 788 | if ($globalDBdriver == 'mysql') { |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | $flight_array = array(); |
811 | 811 | $temp_array = array(); |
812 | 812 | |
813 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
813 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
814 | 814 | { |
815 | 815 | $temp_array['flight_count'] = $row['nb']; |
816 | 816 | $temp_array['flight_country'] = $row['name']; |
@@ -827,11 +827,11 @@ discard block |
||
827 | 827 | * @return Array the callsign list |
828 | 828 | * |
829 | 829 | */ |
830 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
830 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
831 | 831 | { |
832 | 832 | global $globalDBdriver; |
833 | - $filter_query = $this->getFilter($filters,true,true); |
|
834 | - $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
833 | + $filter_query = $this->getFilter($filters, true, true); |
|
834 | + $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
835 | 835 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
836 | 836 | if ($olderthanmonths > 0) { |
837 | 837 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -845,28 +845,28 @@ discard block |
||
845 | 845 | if ($year != '') { |
846 | 846 | if ($globalDBdriver == 'mysql') { |
847 | 847 | $query .= " AND YEAR(tracker_output.date) = :year"; |
848 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
848 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
849 | 849 | } else { |
850 | 850 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
851 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
851 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
852 | 852 | } |
853 | 853 | } |
854 | 854 | if ($month != '') { |
855 | 855 | if ($globalDBdriver == 'mysql') { |
856 | 856 | $query .= " AND MONTH(tracker_output.date) = :month"; |
857 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
857 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
858 | 858 | } else { |
859 | 859 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
860 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
860 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | if ($day != '') { |
864 | 864 | if ($globalDBdriver == 'mysql') { |
865 | 865 | $query .= " AND DAY(tracker_output.date) = :day"; |
866 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
866 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
867 | 867 | } else { |
868 | 868 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
869 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
869 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
870 | 870 | } |
871 | 871 | } |
872 | 872 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | $callsign_array = array(); |
879 | 879 | $temp_array = array(); |
880 | 880 | |
881 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
881 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
882 | 882 | { |
883 | 883 | $temp_array['callsign_icao'] = $row['ident']; |
884 | 884 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | $date_array = array(); |
931 | 931 | $temp_array = array(); |
932 | 932 | |
933 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
933 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
934 | 934 | { |
935 | 935 | $temp_array['date_name'] = $row['date_name']; |
936 | 936 | $temp_array['date_count'] = $row['date_count']; |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | $datetime = new DateTime(); |
957 | 957 | $offset = $datetime->format('P'); |
958 | 958 | } else $offset = '+00:00'; |
959 | - $filter_query = $this->getFilter($filters,true,true); |
|
959 | + $filter_query = $this->getFilter($filters, true, true); |
|
960 | 960 | if ($globalDBdriver == 'mysql') { |
961 | 961 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
962 | 962 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | $date_array = array(); |
978 | 978 | $temp_array = array(); |
979 | 979 | |
980 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
980 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
981 | 981 | { |
982 | 982 | $temp_array['date_name'] = $row['date_name']; |
983 | 983 | $temp_array['date_count'] = $row['date_count']; |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | $datetime = new DateTime(); |
1003 | 1003 | $offset = $datetime->format('P'); |
1004 | 1004 | } else $offset = '+00:00'; |
1005 | - $filter_query = $this->getFilter($filters,true,true); |
|
1005 | + $filter_query = $this->getFilter($filters, true, true); |
|
1006 | 1006 | if ($globalDBdriver == 'mysql') { |
1007 | 1007 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1008 | 1008 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | $date_array = array(); |
1024 | 1024 | $temp_array = array(); |
1025 | 1025 | |
1026 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1026 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1027 | 1027 | { |
1028 | 1028 | $temp_array['date_name'] = $row['date_name']; |
1029 | 1029 | $temp_array['date_count'] = $row['date_count']; |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | $date_array = array(); |
1071 | 1071 | $temp_array = array(); |
1072 | 1072 | |
1073 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1073 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1074 | 1074 | { |
1075 | 1075 | $temp_array['month_name'] = $row['month_name']; |
1076 | 1076 | $temp_array['year_name'] = $row['year_name']; |
@@ -1099,7 +1099,7 @@ discard block |
||
1099 | 1099 | $datetime = new DateTime(); |
1100 | 1100 | $offset = $datetime->format('P'); |
1101 | 1101 | } else $offset = '+00:00'; |
1102 | - $filter_query = $this->getFilter($filters,true,true); |
|
1102 | + $filter_query = $this->getFilter($filters, true, true); |
|
1103 | 1103 | if ($globalDBdriver == 'mysql') { |
1104 | 1104 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
1105 | 1105 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | $date_array = array(); |
1121 | 1121 | $temp_array = array(); |
1122 | 1122 | |
1123 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1123 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1124 | 1124 | { |
1125 | 1125 | $temp_array['year_name'] = $row['year_name']; |
1126 | 1126 | $temp_array['month_name'] = $row['month_name']; |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | * @return Array the hour list |
1141 | 1141 | * |
1142 | 1142 | */ |
1143 | - public function countAllHours($orderby,$filters = array()) |
|
1143 | + public function countAllHours($orderby, $filters = array()) |
|
1144 | 1144 | { |
1145 | 1145 | global $globalTimezone, $globalDBdriver; |
1146 | 1146 | if ($globalTimezone != '') { |
@@ -1188,7 +1188,7 @@ discard block |
||
1188 | 1188 | $hour_array = array(); |
1189 | 1189 | $temp_array = array(); |
1190 | 1190 | |
1191 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1191 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1192 | 1192 | { |
1193 | 1193 | $temp_array['hour_name'] = $row['hour_name']; |
1194 | 1194 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1210,8 +1210,8 @@ discard block |
||
1210 | 1210 | public function countAllHoursByDate($date, $filters = array()) |
1211 | 1211 | { |
1212 | 1212 | global $globalTimezone, $globalDBdriver; |
1213 | - $filter_query = $this->getFilter($filters,true,true); |
|
1214 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1213 | + $filter_query = $this->getFilter($filters, true, true); |
|
1214 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1215 | 1215 | if ($globalTimezone != '') { |
1216 | 1216 | date_default_timezone_set($globalTimezone); |
1217 | 1217 | $datetime = new DateTime($date); |
@@ -1219,12 +1219,12 @@ discard block |
||
1219 | 1219 | } else $offset = '+00:00'; |
1220 | 1220 | |
1221 | 1221 | if ($globalDBdriver == 'mysql') { |
1222 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1222 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1223 | 1223 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date |
1224 | 1224 | GROUP BY hour_name |
1225 | 1225 | ORDER BY hour_name ASC"; |
1226 | 1226 | } else { |
1227 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1227 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1228 | 1228 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1229 | 1229 | GROUP BY hour_name |
1230 | 1230 | ORDER BY hour_name ASC"; |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | $hour_array = array(); |
1237 | 1237 | $temp_array = array(); |
1238 | 1238 | |
1239 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1239 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1240 | 1240 | { |
1241 | 1241 | $temp_array['hour_name'] = $row['hour_name']; |
1242 | 1242 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1258,8 +1258,8 @@ discard block |
||
1258 | 1258 | public function countAllHoursByIdent($ident, $filters = array()) |
1259 | 1259 | { |
1260 | 1260 | global $globalTimezone, $globalDBdriver; |
1261 | - $filter_query = $this->getFilter($filters,true,true); |
|
1262 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1261 | + $filter_query = $this->getFilter($filters, true, true); |
|
1262 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1263 | 1263 | if ($globalTimezone != '') { |
1264 | 1264 | date_default_timezone_set($globalTimezone); |
1265 | 1265 | $datetime = new DateTime(); |
@@ -1267,12 +1267,12 @@ discard block |
||
1267 | 1267 | } else $offset = '+00:00'; |
1268 | 1268 | |
1269 | 1269 | if ($globalDBdriver == 'mysql') { |
1270 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1270 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1271 | 1271 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
1272 | 1272 | GROUP BY hour_name |
1273 | 1273 | ORDER BY hour_name ASC"; |
1274 | 1274 | } else { |
1275 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1275 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1276 | 1276 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
1277 | 1277 | GROUP BY hour_name |
1278 | 1278 | ORDER BY hour_name ASC"; |
@@ -1280,12 +1280,12 @@ discard block |
||
1280 | 1280 | |
1281 | 1281 | |
1282 | 1282 | $sth = $this->db->prepare($query); |
1283 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1283 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1284 | 1284 | |
1285 | 1285 | $hour_array = array(); |
1286 | 1286 | $temp_array = array(); |
1287 | 1287 | |
1288 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1288 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1289 | 1289 | { |
1290 | 1290 | $temp_array['hour_name'] = $row['hour_name']; |
1291 | 1291 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1304,33 +1304,33 @@ discard block |
||
1304 | 1304 | * @return Integer the number of trackers |
1305 | 1305 | * |
1306 | 1306 | */ |
1307 | - public function countOverallTracker($filters = array(),$year = '',$month = '') |
|
1307 | + public function countOverallTracker($filters = array(), $year = '', $month = '') |
|
1308 | 1308 | { |
1309 | 1309 | global $globalDBdriver; |
1310 | 1310 | //$queryi = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output"; |
1311 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
1311 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
1312 | 1312 | $query_values = array(); |
1313 | 1313 | $query = ''; |
1314 | 1314 | if ($year != '') { |
1315 | 1315 | if ($globalDBdriver == 'mysql') { |
1316 | 1316 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1317 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1317 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1318 | 1318 | } else { |
1319 | 1319 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1320 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1320 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1321 | 1321 | } |
1322 | 1322 | } |
1323 | 1323 | if ($month != '') { |
1324 | 1324 | if ($globalDBdriver == 'mysql') { |
1325 | 1325 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1326 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1326 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1327 | 1327 | } else { |
1328 | 1328 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1329 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1329 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1330 | 1330 | } |
1331 | 1331 | } |
1332 | 1332 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1333 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1333 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1334 | 1334 | |
1335 | 1335 | $sth = $this->db->prepare($queryi); |
1336 | 1336 | $sth->execute($query_values); |
@@ -1343,32 +1343,32 @@ discard block |
||
1343 | 1343 | * @return Integer the number of flights |
1344 | 1344 | * |
1345 | 1345 | */ |
1346 | - public function countOverallTrackerTypes($filters = array(),$year = '',$month = '') |
|
1346 | + public function countOverallTrackerTypes($filters = array(), $year = '', $month = '') |
|
1347 | 1347 | { |
1348 | 1348 | global $globalDBdriver; |
1349 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
1349 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
1350 | 1350 | $query_values = array(); |
1351 | 1351 | $query = ''; |
1352 | 1352 | if ($year != '') { |
1353 | 1353 | if ($globalDBdriver == 'mysql') { |
1354 | 1354 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1355 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1355 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1356 | 1356 | } else { |
1357 | 1357 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1358 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1358 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1359 | 1359 | } |
1360 | 1360 | } |
1361 | 1361 | if ($month != '') { |
1362 | 1362 | if ($globalDBdriver == 'mysql') { |
1363 | 1363 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1364 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1364 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1365 | 1365 | } else { |
1366 | 1366 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1367 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1367 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1368 | 1368 | } |
1369 | 1369 | } |
1370 | 1370 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1371 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1371 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1372 | 1372 | |
1373 | 1373 | $sth = $this->db->prepare($queryi); |
1374 | 1374 | $sth->execute($query_values); |
@@ -1385,7 +1385,7 @@ discard block |
||
1385 | 1385 | public function countAllHoursFromToday($filters = array()) |
1386 | 1386 | { |
1387 | 1387 | global $globalTimezone, $globalDBdriver; |
1388 | - $filter_query = $this->getFilter($filters,true,true); |
|
1388 | + $filter_query = $this->getFilter($filters, true, true); |
|
1389 | 1389 | if ($globalTimezone != '') { |
1390 | 1390 | date_default_timezone_set($globalTimezone); |
1391 | 1391 | $datetime = new DateTime(); |
@@ -1393,12 +1393,12 @@ discard block |
||
1393 | 1393 | } else $offset = '+00:00'; |
1394 | 1394 | |
1395 | 1395 | if ($globalDBdriver == 'mysql') { |
1396 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1396 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1397 | 1397 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE() |
1398 | 1398 | GROUP BY hour_name |
1399 | 1399 | ORDER BY hour_name ASC"; |
1400 | 1400 | } else { |
1401 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1401 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1402 | 1402 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1403 | 1403 | GROUP BY hour_name |
1404 | 1404 | ORDER BY hour_name ASC"; |
@@ -1410,7 +1410,7 @@ discard block |
||
1410 | 1410 | $hour_array = array(); |
1411 | 1411 | $temp_array = array(); |
1412 | 1412 | |
1413 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1413 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1414 | 1414 | { |
1415 | 1415 | $temp_array['hour_name'] = $row['hour_name']; |
1416 | 1416 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1429,9 +1429,9 @@ discard block |
||
1429 | 1429 | */ |
1430 | 1430 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
1431 | 1431 | { |
1432 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
1432 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
1433 | 1433 | |
1434 | - $query = "SELECT tracker_output.tracker_id |
|
1434 | + $query = "SELECT tracker_output.tracker_id |
|
1435 | 1435 | FROM tracker_output |
1436 | 1436 | WHERE tracker_output.famtrackid = '".$famtrackid."'"; |
1437 | 1437 | |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | $sth = $this->db->prepare($query); |
1440 | 1440 | $sth->execute(); |
1441 | 1441 | |
1442 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1442 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1443 | 1443 | { |
1444 | 1444 | return $row['tracker_id']; |
1445 | 1445 | } |
@@ -1464,23 +1464,23 @@ discard block |
||
1464 | 1464 | } |
1465 | 1465 | |
1466 | 1466 | $current_date = date("Y-m-d H:i:s"); |
1467 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1467 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1468 | 1468 | |
1469 | 1469 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1470 | 1470 | |
1471 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1471 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1472 | 1472 | $years = $time_array['years']; |
1473 | 1473 | |
1474 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1474 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1475 | 1475 | $months = $time_array['months']; |
1476 | 1476 | |
1477 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1477 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1478 | 1478 | $days = $time_array['days']; |
1479 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1479 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1480 | 1480 | $hours = $time_array['hours']; |
1481 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1481 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1482 | 1482 | $minutes = $time_array['minutes']; |
1483 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1483 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1484 | 1484 | |
1485 | 1485 | return $time_array; |
1486 | 1486 | } |
@@ -1503,63 +1503,63 @@ discard block |
||
1503 | 1503 | $temp_array['direction_degree'] = $direction; |
1504 | 1504 | $temp_array['direction_shortname'] = "N"; |
1505 | 1505 | $temp_array['direction_fullname'] = "North"; |
1506 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1506 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1507 | 1507 | $temp_array['direction_degree'] = $direction; |
1508 | 1508 | $temp_array['direction_shortname'] = "NNE"; |
1509 | 1509 | $temp_array['direction_fullname'] = "North-Northeast"; |
1510 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1510 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1511 | 1511 | $temp_array['direction_degree'] = $direction; |
1512 | 1512 | $temp_array['direction_shortname'] = "NE"; |
1513 | 1513 | $temp_array['direction_fullname'] = "Northeast"; |
1514 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1514 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1515 | 1515 | $temp_array['direction_degree'] = $direction; |
1516 | 1516 | $temp_array['direction_shortname'] = "ENE"; |
1517 | 1517 | $temp_array['direction_fullname'] = "East-Northeast"; |
1518 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1518 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1519 | 1519 | $temp_array['direction_degree'] = $direction; |
1520 | 1520 | $temp_array['direction_shortname'] = "E"; |
1521 | 1521 | $temp_array['direction_fullname'] = "East"; |
1522 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1522 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1523 | 1523 | $temp_array['direction_degree'] = $direction; |
1524 | 1524 | $temp_array['direction_shortname'] = "ESE"; |
1525 | 1525 | $temp_array['direction_fullname'] = "East-Southeast"; |
1526 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1526 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1527 | 1527 | $temp_array['direction_degree'] = $direction; |
1528 | 1528 | $temp_array['direction_shortname'] = "SE"; |
1529 | 1529 | $temp_array['direction_fullname'] = "Southeast"; |
1530 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1530 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1531 | 1531 | $temp_array['direction_degree'] = $direction; |
1532 | 1532 | $temp_array['direction_shortname'] = "SSE"; |
1533 | 1533 | $temp_array['direction_fullname'] = "South-Southeast"; |
1534 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1534 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1535 | 1535 | $temp_array['direction_degree'] = $direction; |
1536 | 1536 | $temp_array['direction_shortname'] = "S"; |
1537 | 1537 | $temp_array['direction_fullname'] = "South"; |
1538 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1538 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1539 | 1539 | $temp_array['direction_degree'] = $direction; |
1540 | 1540 | $temp_array['direction_shortname'] = "SSW"; |
1541 | 1541 | $temp_array['direction_fullname'] = "South-Southwest"; |
1542 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1542 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1543 | 1543 | $temp_array['direction_degree'] = $direction; |
1544 | 1544 | $temp_array['direction_shortname'] = "SW"; |
1545 | 1545 | $temp_array['direction_fullname'] = "Southwest"; |
1546 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1546 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1547 | 1547 | $temp_array['direction_degree'] = $direction; |
1548 | 1548 | $temp_array['direction_shortname'] = "WSW"; |
1549 | 1549 | $temp_array['direction_fullname'] = "West-Southwest"; |
1550 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1550 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1551 | 1551 | $temp_array['direction_degree'] = $direction; |
1552 | 1552 | $temp_array['direction_shortname'] = "W"; |
1553 | 1553 | $temp_array['direction_fullname'] = "West"; |
1554 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1554 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1555 | 1555 | $temp_array['direction_degree'] = $direction; |
1556 | 1556 | $temp_array['direction_shortname'] = "WNW"; |
1557 | 1557 | $temp_array['direction_fullname'] = "West-Northwest"; |
1558 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1558 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1559 | 1559 | $temp_array['direction_degree'] = $direction; |
1560 | 1560 | $temp_array['direction_shortname'] = "NW"; |
1561 | 1561 | $temp_array['direction_fullname'] = "Northwest"; |
1562 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1562 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1563 | 1563 | $temp_array['direction_degree'] = $direction; |
1564 | 1564 | $temp_array['direction_shortname'] = "NNW"; |
1565 | 1565 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1576,11 +1576,11 @@ discard block |
||
1576 | 1576 | * @param Float $longitude longitute of the flight |
1577 | 1577 | * @return String the countrie |
1578 | 1578 | */ |
1579 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1579 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1580 | 1580 | { |
1581 | 1581 | global $globalDBdriver, $globalDebug; |
1582 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1583 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1582 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1583 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1584 | 1584 | |
1585 | 1585 | $Connection = new Connection($this->db); |
1586 | 1586 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1620,7 +1620,7 @@ discard block |
||
1620 | 1620 | public function getCountryFromISO2($iso2) |
1621 | 1621 | { |
1622 | 1622 | global $globalDBdriver, $globalDebug; |
1623 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1623 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1624 | 1624 | |
1625 | 1625 | $Connection = new Connection($this->db); |
1626 | 1626 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1649,11 +1649,11 @@ discard block |
||
1649 | 1649 | * @return Array the vessel type list |
1650 | 1650 | * |
1651 | 1651 | */ |
1652 | - public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1652 | + public function countAllTrackerTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1653 | 1653 | { |
1654 | 1654 | global $globalDBdriver; |
1655 | - $filter_query = $this->getFilter($filters,true,true); |
|
1656 | - $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
1655 | + $filter_query = $this->getFilter($filters, true, true); |
|
1656 | + $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
1657 | 1657 | FROM tracker_output ".$filter_query." tracker_output.type <> ''"; |
1658 | 1658 | if ($olderthanmonths > 0) { |
1659 | 1659 | if ($globalDBdriver == 'mysql') { |
@@ -1673,28 +1673,28 @@ discard block |
||
1673 | 1673 | if ($year != '') { |
1674 | 1674 | if ($globalDBdriver == 'mysql') { |
1675 | 1675 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1676 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1676 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1677 | 1677 | } else { |
1678 | 1678 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1679 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1679 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1680 | 1680 | } |
1681 | 1681 | } |
1682 | 1682 | if ($month != '') { |
1683 | 1683 | if ($globalDBdriver == 'mysql') { |
1684 | 1684 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1685 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1685 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1686 | 1686 | } else { |
1687 | 1687 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1688 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1688 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1689 | 1689 | } |
1690 | 1690 | } |
1691 | 1691 | if ($day != '') { |
1692 | 1692 | if ($globalDBdriver == 'mysql') { |
1693 | 1693 | $query .= " AND DAY(tracker_output.date) = :day"; |
1694 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1694 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1695 | 1695 | } else { |
1696 | 1696 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
1697 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1697 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1698 | 1698 | } |
1699 | 1699 | } |
1700 | 1700 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
@@ -1703,7 +1703,7 @@ discard block |
||
1703 | 1703 | $sth->execute($query_values); |
1704 | 1704 | $tracker_array = array(); |
1705 | 1705 | $temp_array = array(); |
1706 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1706 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1707 | 1707 | { |
1708 | 1708 | $temp_array['tracker_type'] = $row['tracker_type']; |
1709 | 1709 | $temp_array['tracker_type_count'] = $row['tracker_type_count']; |
@@ -1738,7 +1738,7 @@ discard block |
||
1738 | 1738 | |
1739 | 1739 | $bitly_data = json_decode($bitly_data); |
1740 | 1740 | $bitly_url = ''; |
1741 | - if ($bitly_data->status_txt = "OK"){ |
|
1741 | + if ($bitly_data->status_txt = "OK") { |
|
1742 | 1742 | $bitly_url = $bitly_data->data->url; |
1743 | 1743 | } |
1744 | 1744 | |
@@ -1748,7 +1748,7 @@ discard block |
||
1748 | 1748 | |
1749 | 1749 | public function getOrderBy() |
1750 | 1750 | { |
1751 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_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")); |
|
1751 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_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")); |
|
1752 | 1752 | |
1753 | 1753 | return $orderby; |
1754 | 1754 |
@@ -55,23 +55,23 @@ discard block |
||
55 | 55 | $min = true; |
56 | 56 | $allhistory = false; |
57 | 57 | $filter['source'] = array(); |
58 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
59 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
60 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
61 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
62 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
63 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
64 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
58 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
59 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
60 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
61 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
62 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
63 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
64 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
65 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
66 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
67 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
68 | 68 | |
69 | 69 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
70 | 70 | $min = true; |
71 | 71 | } else $min = false; |
72 | 72 | |
73 | 73 | if (isset($_GET['ident'])) { |
74 | - $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
|
74 | + $ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING)); |
|
75 | 75 | if ($tracker) { |
76 | 76 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident); |
77 | 77 | } elseif ($marine) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | $allhistory = true; |
87 | 87 | } elseif (isset($_GET['flightaware_id'])) { |
88 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
88 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
89 | 89 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
90 | 90 | if (empty($spotter_array)) { |
91 | 91 | $from_archive = true; |
@@ -93,44 +93,44 @@ discard block |
||
93 | 93 | } |
94 | 94 | $allhistory = true; |
95 | 95 | } elseif (isset($_GET['famtrack_id'])) { |
96 | - $famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING)); |
|
96 | + $famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING)); |
|
97 | 97 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id); |
98 | 98 | $allhistory = true; |
99 | 99 | } elseif (isset($_GET['fammarine_id'])) { |
100 | - $fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING)); |
|
100 | + $fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING)); |
|
101 | 101 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id); |
102 | 102 | $allhistory = true; |
103 | 103 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && 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,17 +142,17 @@ 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 ($usecoord) { |
154 | 154 | if (isset($_GET['archive'])) { |
155 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
155 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
156 | 156 | } else { |
157 | 157 | if ($tracker) { |
158 | 158 | $flightcnt = $TrackerLive->getLiveTrackerCount($filter); |
@@ -165,7 +165,7 @@ 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 | |
170 | 170 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
171 | 171 | else $usenextlatlon = true; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | if (!empty($spotter_array) && is_array($spotter_array)) |
183 | 183 | { |
184 | 184 | $output .= '"features": ['; |
185 | - foreach($spotter_array as $spotter_item) |
|
185 | + foreach ($spotter_array as $spotter_item) |
|
186 | 186 | { |
187 | 187 | $j++; |
188 | 188 | date_default_timezone_set('UTC'); |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | */ |
239 | 239 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
240 | 240 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
241 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
242 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
241 | + if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
242 | + else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
243 | 243 | //" |
244 | 244 | } else { |
245 | 245 | if ($compress) $output .= '"c": "NA",'; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
249 | 249 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
250 | 250 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
251 | - $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
|
251 | + $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",'; |
|
252 | 252 | } elseif (isset($spotter_item['aircraft_type'])) { |
253 | 253 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
254 | 254 | } elseif (!$min) { |
@@ -389,16 +389,16 @@ discard block |
||
389 | 389 | else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
390 | 390 | |
391 | 391 | if (isset($archivespeed)) { |
392 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
392 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed); |
|
393 | 393 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
394 | 394 | } elseif ($usenextlatlon) { |
395 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
395 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']); |
|
396 | 396 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
397 | 397 | } |
398 | 398 | |
399 | 399 | if (!$min) $output .= '"image": "'.$image.'",'; |
400 | 400 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
401 | - $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
|
401 | + $output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; |
|
402 | 402 | } |
403 | 403 | if (isset($spotter_item['image_source_website'])) { |
404 | 404 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
421 | 421 | } |
422 | 422 | if (isset($spotter_item['acars'])) { |
423 | - $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
|
423 | + $output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; |
|
424 | 424 | } |
425 | 425 | // type when not aircraft ? |
426 | 426 | if (isset($spotter_item['type'])) { |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | |
499 | 499 | } |
500 | 500 | */ |
501 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
|
501 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING); |
|
502 | 502 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
503 | 503 | |
504 | 504 | if ( |
@@ -506,11 +506,11 @@ discard block |
||
506 | 506 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
507 | 507 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
508 | 508 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
509 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
509 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
510 | 510 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
511 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
511 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id'])) |
|
512 | 512 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
513 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
513 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid'])) |
|
514 | 514 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
515 | 515 | ) { |
516 | 516 | if ($tracker) { |
@@ -547,9 +547,9 @@ discard block |
||
547 | 547 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
548 | 548 | } |
549 | 549 | $output_history .= '['; |
550 | - $output_history .= $spotter_history['longitude'].', '; |
|
551 | - $output_history .= $spotter_history['latitude'].', '; |
|
552 | - $output_history .= $spotter_history['altitude']*30.48; |
|
550 | + $output_history .= $spotter_history['longitude'].', '; |
|
551 | + $output_history .= $spotter_history['latitude'].', '; |
|
552 | + $output_history .= $spotter_history['altitude']*30.48; |
|
553 | 553 | $output_history .= '],'; |
554 | 554 | /* |
555 | 555 | if ($from_archive === false) { |
@@ -567,8 +567,8 @@ discard block |
||
567 | 567 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
568 | 568 | } else $d = true; |
569 | 569 | $output_history .= '['; |
570 | - $output_history .= $spotter_history['longitude'].', '; |
|
571 | - $output_history .= $spotter_history['latitude']; |
|
570 | + $output_history .= $spotter_history['longitude'].', '; |
|
571 | + $output_history .= $spotter_history['latitude']; |
|
572 | 572 | $output_history .= '],'; |
573 | 573 | /* |
574 | 574 | if ($from_archive === false) { |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | |
585 | 585 | if ($from_archive === false) { |
586 | 586 | $output_historyd = '['; |
587 | - $output_historyd .= $spotter_item['longitude'].', '; |
|
588 | - $output_historyd .= $spotter_item['latitude']; |
|
589 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
587 | + $output_historyd .= $spotter_item['longitude'].', '; |
|
588 | + $output_historyd .= $spotter_item['latitude']; |
|
589 | + if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
590 | 590 | $output_historyd .= '],'; |
591 | 591 | //$output_history = $output_historyd.$output_history; |
592 | 592 | $output_history = $output_history.$output_historyd; |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | } |
601 | 601 | } |
602 | 602 | |
603 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
603 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
604 | 604 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
605 | 605 | && (isset($spotter_item['departure_airport']) |
606 | 606 | && $spotter_item['departure_airport'] != 'NA' |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | |
635 | 635 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
636 | 636 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
637 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
637 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
638 | 638 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
639 | 639 | && (isset($spotter_item['arrival_airport']) |
640 | 640 | && $spotter_item['arrival_airport'] != 'NA' |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | $output = substr($output, 0, -1); |
666 | 666 | $output .= ']'; |
667 | 667 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
668 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
|
668 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",'; |
|
669 | 669 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
670 | 670 | $output .= '"fc": "'.$j.'"'; |
671 | 671 | } else { |