@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | default: |
42 | 42 | throw new \Exception("bad resolution can be only one of 1,3"); |
43 | 43 | } |
44 | - register_shutdown_function(function () { |
|
44 | + register_shutdown_function(function() { |
|
45 | 45 | $this->closeAllFiles(); |
46 | 46 | }); |
47 | 47 | } |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | |
56 | 56 | private function getElevationAtPosition($fileName, $row, $column) { |
57 | 57 | if (!array_key_exists($fileName, $this->openedFiles)) { |
58 | - if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName)) { |
|
58 | + if (!file_exists($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName)) { |
|
59 | 59 | throw new \Exception("File '{$fileName}' not exists."); |
60 | 60 | } |
61 | - $file = fopen($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName, "r"); |
|
61 | + $file = fopen($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName, "r"); |
|
62 | 62 | if ($file === false) { |
63 | 63 | throw new \Exception("Cant open file '{$fileName}' for reading."); |
64 | 64 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | throw new \Exception("Not implemented yet"); |
73 | 73 | } |
74 | 74 | $aRow = $this->measPerDeg - $row; |
75 | - $position = ($this->measPerDeg * ($aRow - 1)) + $column; |
|
75 | + $position = ($this->measPerDeg*($aRow - 1)) + $column; |
|
76 | 76 | $position *= 2; |
77 | 77 | fseek($file, $position); |
78 | 78 | $short = fread($file, 2); |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | $latSec = $this->getSec($lat); |
101 | 101 | $lonSec = $this->getSec($lon); |
102 | 102 | |
103 | - $Xn = round($latSec / $this->resolution, 3); |
|
104 | - $Yn = round($lonSec / $this->resolution, 3); |
|
103 | + $Xn = round($latSec/$this->resolution, 3); |
|
104 | + $Yn = round($lonSec/$this->resolution, 3); |
|
105 | 105 | |
106 | 106 | $a1 = round($Xn); |
107 | 107 | $a2 = round($Yn); |
@@ -133,55 +133,55 @@ discard block |
||
133 | 133 | $b3 = $this->getElevationAtPosition($fName, $b1, $b2); |
134 | 134 | $c3 = $this->getElevationAtPosition($fName, $c1, $c2); |
135 | 135 | |
136 | - $n1 = ($c2 - $a2) * ($b3 - $a3) - ($c3 - $a3) * ($b2 - $a2); |
|
137 | - $n2 = ($c3 - $a3) * ($b1 - $a1) - ($c1 - $a1) * ($b3 - $a3); |
|
138 | - $n3 = ($c1 - $a1) * ($b2 - $a2) - ($c2 - $a2) * ($b1 - $a1); |
|
136 | + $n1 = ($c2 - $a2)*($b3 - $a3) - ($c3 - $a3)*($b2 - $a2); |
|
137 | + $n2 = ($c3 - $a3)*($b1 - $a1) - ($c1 - $a1)*($b3 - $a3); |
|
138 | + $n3 = ($c1 - $a1)*($b2 - $a2) - ($c2 - $a2)*($b1 - $a1); |
|
139 | 139 | |
140 | - $d = -$n1 * $a1 - $n2 * $a2 - $n3 * $a3; |
|
141 | - $zN = (-$n1 * $Xn - $n2 * $Yn - $d) / $n3; |
|
140 | + $d = -$n1*$a1 - $n2*$a2 - $n3*$a3; |
|
141 | + $zN = (-$n1*$Xn - $n2*$Yn - $d)/$n3; |
|
142 | 142 | |
143 | 143 | return $zN; |
144 | 144 | } |
145 | 145 | |
146 | 146 | private function getDeg($deg, $numPrefix) { |
147 | 147 | $deg = abs($deg); |
148 | - $d = floor($deg); // round degrees |
|
148 | + $d = floor($deg); // round degrees |
|
149 | 149 | if ($numPrefix >= 3) { |
150 | 150 | if ($d < 100) { |
151 | - $d = '0' . $d; |
|
151 | + $d = '0'.$d; |
|
152 | 152 | } |
153 | 153 | } // pad with leading zeros |
154 | 154 | if ($d < 10) { |
155 | - $d = '0' . $d; |
|
155 | + $d = '0'.$d; |
|
156 | 156 | } |
157 | 157 | return $d; |
158 | 158 | } |
159 | 159 | |
160 | 160 | private function getSec($deg) { |
161 | 161 | $deg = abs($deg); |
162 | - $sec = round($deg * 3600, 4); |
|
163 | - $m = fmod(floor($sec / 60), 60); |
|
162 | + $sec = round($deg*3600, 4); |
|
163 | + $m = fmod(floor($sec/60), 60); |
|
164 | 164 | $s = round(fmod($sec, 60), 4); |
165 | - return ($m * 60) + $s; |
|
165 | + return ($m*60) + $s; |
|
166 | 166 | } |
167 | 167 | |
168 | - public function download($lat,$lon, $debug = false) { |
|
168 | + public function download($lat, $lon, $debug = false) { |
|
169 | 169 | $N = $this->getDeg($lat, 2); |
170 | 170 | $E = $this->getDeg($lon, 3); |
171 | - $fileName = "N{$N}E{$E}.hgt"; |
|
172 | - if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName)) { |
|
171 | + $fileName = "N{$N}E{$E}.hgt"; |
|
172 | + if (!file_exists($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName)) { |
|
173 | 173 | $Common = new Common(); |
174 | 174 | if ($debug) echo 'Downloading '.$fileName.'.gz ...'; |
175 | - $Common->download('https://s3.amazonaws.com/elevation-tiles-prod/skadi/N'.$N.'/'.$fileName.'.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz'); |
|
176 | - if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz')) { |
|
175 | + $Common->download('https://s3.amazonaws.com/elevation-tiles-prod/skadi/N'.$N.'/'.$fileName.'.gz', $this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz'); |
|
176 | + if (!file_exists($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz')) { |
|
177 | 177 | if ($debug) echo "File '{$fileName}.gz' not exists."; |
178 | 178 | return false; |
179 | 179 | } |
180 | 180 | if ($debug) echo 'Done'."\n"; |
181 | 181 | if ($debug) echo 'Decompress '.$fileName.' ....'; |
182 | - $Common->gunzip($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName); |
|
182 | + $Common->gunzip($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz', $this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName); |
|
183 | 183 | if ($debug) echo 'Done'."\n"; |
184 | - unlink($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz'); |
|
184 | + unlink($this->htgFilesDestination.DIRECTORY_SEPARATOR.$fileName.'.gz'); |
|
185 | 185 | } |
186 | 186 | return true; |
187 | 187 | } |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | try { |
195 | 195 | $sth = $db->prepare($query); |
196 | 196 | $sth->execute($query_values); |
197 | - } catch(PDOException $e) { |
|
197 | + } catch (PDOException $e) { |
|
198 | 198 | return "error : ".$e->getMessage(); |
199 | 199 | } |
200 | 200 | while ($data = $sth->fetch(PDO::FETCH_ASSOC)) { |
201 | - $this->download($data['latitude'],$data['longitude'],true); |
|
201 | + $this->download($data['latitude'], $data['longitude'], true); |
|
202 | 202 | } |
203 | 203 | $db = $Connection->db; |
204 | 204 | $query = 'SELECT latitude, longitude FROM tracker_output WHERE latitude <> 0 AND longitude <> 0 ORDER BY date DESC LIMIT 100'; |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | try { |
207 | 207 | $sth = $db->prepare($query); |
208 | 208 | $sth->execute($query_values); |
209 | - } catch(PDOException $e) { |
|
209 | + } catch (PDOException $e) { |
|
210 | 210 | return "error : ".$e->getMessage(); |
211 | 211 | } |
212 | 212 | while ($data = $sth->fetch(PDO::FETCH_ASSOC)) { |
213 | - $this->download($data['latitude'],$data['longitude'],true); |
|
213 | + $this->download($data['latitude'], $data['longitude'], true); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | } |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | * @param Array $headers header to submit with the form |
15 | 15 | * @return String the result |
16 | 16 | */ |
17 | - public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') { |
|
17 | + public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') { |
|
18 | 18 | global $globalProxy, $globalForceIPv4; |
19 | 19 | $ch = curl_init(); |
20 | 20 | curl_setopt($ch, CURLOPT_URL, $url); |
21 | 21 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
22 | - if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
|
22 | + if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) { |
|
23 | 23 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
24 | 24 | } |
25 | 25 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
30 | 30 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
31 | 31 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
32 | - curl_setopt($ch,CURLOPT_ENCODING , "gzip"); |
|
32 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
33 | 33 | //curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
34 | 34 | // curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0'); |
35 | 35 | if ($useragent == '') { |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | } |
40 | 40 | if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
41 | 41 | else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
42 | - curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
|
42 | + curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback")); |
|
43 | 43 | if ($type == 'post') { |
44 | 44 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
45 | 45 | if (is_array($data)) { |
46 | 46 | curl_setopt($ch, CURLOPT_POST, count($data)); |
47 | 47 | $data_string = ''; |
48 | - foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
48 | + foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
49 | 49 | rtrim($data_string, '&'); |
50 | 50 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); |
51 | 51 | } else { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | if ($cookie != '') { |
59 | 59 | if (is_array($cookie)) { |
60 | - curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';')); |
|
60 | + curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';')); |
|
61 | 61 | } else { |
62 | 62 | curl_setopt($ch, CURLOPT_COOKIE, $cookie); |
63 | 63 | } |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | $info = curl_getinfo($ch); |
70 | 70 | //var_dump($info); |
71 | 71 | curl_close($ch); |
72 | - if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) { |
|
72 | + if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) { |
|
73 | 73 | echo "Cloudflare Detected\n"; |
74 | 74 | require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php'); |
75 | 75 | $useragent = UAgent::random(); |
76 | 76 | cloudflare::useUserAgent($useragent); |
77 | 77 | if ($clearanceCookie = cloudflare::bypass($url)) { |
78 | - return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent); |
|
78 | + return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent); |
|
79 | 79 | } |
80 | 80 | } else { |
81 | 81 | return $result; |
@@ -106,20 +106,20 @@ discard block |
||
106 | 106 | fclose($fp); |
107 | 107 | } |
108 | 108 | |
109 | - public static function gunzip($in_file,$out_file_name = '') { |
|
109 | + public static function gunzip($in_file, $out_file_name = '') { |
|
110 | 110 | //echo $in_file.' -> '.$out_file_name."\n"; |
111 | 111 | $buffer_size = 4096; // read 4kb at a time |
112 | 112 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
113 | 113 | if ($in_file != '' && file_exists($in_file)) { |
114 | 114 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
115 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
116 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
115 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
116 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
117 | 117 | else { |
118 | 118 | echo 'gzopen not available'; |
119 | 119 | die; |
120 | 120 | } |
121 | 121 | $out_file = fopen($out_file_name, 'wb'); |
122 | - while(!gzeof($file)) { |
|
122 | + while (!gzeof($file)) { |
|
123 | 123 | fwrite($out_file, gzread($file, $buffer_size)); |
124 | 124 | } |
125 | 125 | fclose($out_file); |
@@ -127,19 +127,19 @@ discard block |
||
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | - public static function bunzip2($in_file,$out_file_name = '') { |
|
130 | + public static function bunzip2($in_file, $out_file_name = '') { |
|
131 | 131 | //echo $in_file.' -> '.$out_file_name."\n"; |
132 | 132 | $buffer_size = 4096; // read 4kb at a time |
133 | 133 | if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
134 | 134 | if ($in_file != '' && file_exists($in_file)) { |
135 | 135 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
136 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
136 | + if (function_exists('bzopen')) $file = bzopen($in_file, 'rb'); |
|
137 | 137 | else { |
138 | 138 | echo 'bzopen not available'; |
139 | 139 | die; |
140 | 140 | } |
141 | 141 | $out_file = fopen($out_file_name, 'wb'); |
142 | - while(!feof($file)) { |
|
142 | + while (!feof($file)) { |
|
143 | 143 | fwrite($out_file, bzread($file, $buffer_size)); |
144 | 144 | } |
145 | 145 | fclose($out_file); |
@@ -157,27 +157,27 @@ discard block |
||
157 | 157 | if ($data == '') return array(); |
158 | 158 | $html = str_get_html($data); |
159 | 159 | if ($html === false) return array(); |
160 | - $tabledata=array(); |
|
161 | - foreach($html->find('tr') as $element) |
|
160 | + $tabledata = array(); |
|
161 | + foreach ($html->find('tr') as $element) |
|
162 | 162 | { |
163 | 163 | $td = array(); |
164 | - foreach( $element->find('th') as $row) |
|
164 | + foreach ($element->find('th') as $row) |
|
165 | 165 | { |
166 | 166 | $td [] = trim($row->plaintext); |
167 | 167 | } |
168 | - $td=array_filter($td); |
|
168 | + $td = array_filter($td); |
|
169 | 169 | $tabledata[] = $td; |
170 | 170 | |
171 | 171 | $td = array(); |
172 | 172 | $tdi = array(); |
173 | - foreach( $element->find('td') as $row) |
|
173 | + foreach ($element->find('td') as $row) |
|
174 | 174 | { |
175 | 175 | $td [] = trim($row->plaintext); |
176 | 176 | $tdi [] = trim($row->innertext); |
177 | 177 | } |
178 | - $td=array_filter($td); |
|
179 | - $tdi=array_filter($tdi); |
|
180 | - $tabledata[]=array_merge($td,$tdi); |
|
178 | + $td = array_filter($td); |
|
179 | + $tdi = array_filter($tdi); |
|
180 | + $tabledata[] = array_merge($td, $tdi); |
|
181 | 181 | } |
182 | 182 | $html->clear(); |
183 | 183 | unset($html); |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | public function text2array($data) { |
193 | 193 | $html = str_get_html($data); |
194 | 194 | if ($html === false) return array(); |
195 | - $tabledata=array(); |
|
196 | - foreach($html->find('p') as $element) |
|
195 | + $tabledata = array(); |
|
196 | + foreach ($html->find('p') as $element) |
|
197 | 197 | { |
198 | 198 | $tabledata [] = trim($element->plaintext); |
199 | 199 | } |
@@ -213,11 +213,11 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
215 | 215 | if ($lat == $latc && $lon == $lonc) return 0; |
216 | - $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
|
216 | + $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515; |
|
217 | 217 | if ($unit == "km") { |
218 | - return round($dist * 1.609344); |
|
218 | + return round($dist*1.609344); |
|
219 | 219 | } elseif ($unit == "m") { |
220 | - return round($dist * 1.609344 * 1000); |
|
220 | + return round($dist*1.609344*1000); |
|
221 | 221 | } elseif ($unit == "mile" || $unit == "mi") { |
222 | 222 | return round($dist); |
223 | 223 | } elseif ($unit == "nm") { |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @param float $distance distance covered |
234 | 234 | * @return whether distance is realistic |
235 | 235 | */ |
236 | - public function withinThreshold ($timeDifference, $distance) { |
|
236 | + public function withinThreshold($timeDifference, $distance) { |
|
237 | 237 | $x = abs($timeDifference); |
238 | 238 | $d = abs($distance); |
239 | 239 | if ($x == 0 || $d == 0) return true; |
@@ -249,12 +249,12 @@ discard block |
||
249 | 249 | return ($array !== array_values($array)); |
250 | 250 | } |
251 | 251 | |
252 | - public function isInteger($input){ |
|
252 | + public function isInteger($input) { |
|
253 | 253 | return(ctype_digit(strval($input))); |
254 | 254 | } |
255 | 255 | |
256 | 256 | |
257 | - public function convertDec($dms,$latlong) { |
|
257 | + public function convertDec($dms, $latlong) { |
|
258 | 258 | if ($latlong == 'latitude') { |
259 | 259 | $deg = substr($dms, 0, 2); |
260 | 260 | $min = substr($dms, 2, 4); |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | $deg = substr($dms, 0, 3); |
263 | 263 | $min = substr($dms, 3, 5); |
264 | 264 | } |
265 | - return $deg+(($min*60)/3600); |
|
265 | + return $deg + (($min*60)/3600); |
|
266 | 266 | } |
267 | 267 | |
268 | - public function convertDM($coord,$latlong) { |
|
268 | + public function convertDM($coord, $latlong) { |
|
269 | 269 | if ($latlong == 'latitude') { |
270 | 270 | if ($coord < 0) $NSEW = 'S'; |
271 | 271 | else $NSEW = 'N'; |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | } |
276 | 276 | $coord = abs($coord); |
277 | 277 | $deg = floor($coord); |
278 | - $coord = ($coord-$deg)*60; |
|
278 | + $coord = ($coord - $deg)*60; |
|
279 | 279 | $min = $coord; |
280 | - return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW); |
|
280 | + return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | public function xcopy($source, $dest) |
290 | 290 | { |
291 | 291 | $files = glob($source.'*.*'); |
292 | - foreach($files as $file){ |
|
293 | - $file_to_go = str_replace($source,$dest,$file); |
|
292 | + foreach ($files as $file) { |
|
293 | + $file_to_go = str_replace($source, $dest, $file); |
|
294 | 294 | copy($file, $file_to_go); |
295 | 295 | } |
296 | 296 | return true; |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | * @param String $url url to check |
302 | 302 | * @return bool Return true on succes false on failure |
303 | 303 | */ |
304 | - public function urlexist($url){ |
|
305 | - $headers=get_headers($url); |
|
306 | - return stripos($headers[0],"200 OK")?true:false; |
|
304 | + public function urlexist($url) { |
|
305 | + $headers = get_headers($url); |
|
306 | + return stripos($headers[0], "200 OK") ? true : false; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | public function hex2str($hex) { |
315 | 315 | $str = ''; |
316 | 316 | $hexln = strlen($hex); |
317 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
317 | + for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2))); |
|
318 | 318 | return $str; |
319 | 319 | } |
320 | 320 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @return String Return result |
325 | 325 | */ |
326 | 326 | public function hex2rgb($hex) { |
327 | - $hex = str_replace('#','',$hex); |
|
327 | + $hex = str_replace('#', '', $hex); |
|
328 | 328 | return sscanf($hex, "%02x%02x%02x"); |
329 | 329 | } |
330 | 330 | |
@@ -332,33 +332,33 @@ discard block |
||
332 | 332 | //difference in longitudinal coordinates |
333 | 333 | $dLon = deg2rad($lon2) - deg2rad($lon1); |
334 | 334 | //difference in the phi of latitudinal coordinates |
335 | - $dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4)); |
|
335 | + $dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4)); |
|
336 | 336 | //we need to recalculate $dLon if it is greater than pi |
337 | - if(abs($dLon) > pi()) { |
|
338 | - if($dLon > 0) { |
|
339 | - $dLon = (2 * pi() - $dLon) * -1; |
|
337 | + if (abs($dLon) > pi()) { |
|
338 | + if ($dLon > 0) { |
|
339 | + $dLon = (2*pi() - $dLon)*-1; |
|
340 | 340 | } else { |
341 | - $dLon = 2 * pi() + $dLon; |
|
341 | + $dLon = 2*pi() + $dLon; |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | //return the angle, normalized |
345 | - return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360; |
|
345 | + return (rad2deg(atan2($dLon, $dPhi)) + 360)%360; |
|
346 | 346 | } |
347 | 347 | |
348 | - public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.2) { |
|
348 | + public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.2) { |
|
349 | 349 | //$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1); |
350 | - $a = -($lon2-$lon1); |
|
350 | + $a = -($lon2 - $lon1); |
|
351 | 351 | $b = $lat2 - $lat1; |
352 | - $c = -($a*$lat1+$b*$lon1); |
|
353 | - $d = $a*$lat3+$b*$lon3+$c; |
|
352 | + $c = -($a*$lat1 + $b*$lon1); |
|
353 | + $d = $a*$lat3 + $b*$lon3 + $c; |
|
354 | 354 | if ($d > -$approx && $d < $approx) return true; |
355 | 355 | else return false; |
356 | 356 | } |
357 | 357 | |
358 | 358 | public function array_merge_noappend() { |
359 | 359 | $output = array(); |
360 | - foreach(func_get_args() as $array) { |
|
361 | - foreach($array as $key => $value) { |
|
360 | + foreach (func_get_args() as $array) { |
|
361 | + foreach ($array as $key => $value) { |
|
362 | 362 | $output[$key] = isset($output[$key]) ? |
363 | 363 | array_merge($output[$key], $value) : $value; |
364 | 364 | } |
@@ -422,34 +422,34 @@ discard block |
||
422 | 422 | return $result; |
423 | 423 | } |
424 | 424 | |
425 | - public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){ |
|
425 | + public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) { |
|
426 | 426 | global $globalMapRefresh; |
427 | 427 | $distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000; |
428 | 428 | $r = 6378; |
429 | 429 | $latitude = deg2rad($latitude); |
430 | 430 | $longitude = deg2rad($longitude); |
431 | 431 | $bearing = deg2rad($heading); |
432 | - $latitude2 = asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) ); |
|
433 | - $longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) ); |
|
434 | - return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.','')); |
|
432 | + $latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing))); |
|
433 | + $longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2))); |
|
434 | + return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', '')); |
|
435 | 435 | } |
436 | 436 | |
437 | - public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) { |
|
437 | + public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) { |
|
438 | 438 | // distance in meter |
439 | 439 | $R = 6378.14; |
440 | - $latitude1 = $latitude * (M_PI/180); |
|
441 | - $longitude1 = $longitude * (M_PI/180); |
|
442 | - $brng = $bearing * (M_PI/180); |
|
440 | + $latitude1 = $latitude*(M_PI/180); |
|
441 | + $longitude1 = $longitude*(M_PI/180); |
|
442 | + $brng = $bearing*(M_PI/180); |
|
443 | 443 | $d = $distance; |
444 | 444 | |
445 | 445 | $latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng)); |
446 | - $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2)); |
|
446 | + $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2)); |
|
447 | 447 | |
448 | - $latitude2 = $latitude2 * (180/M_PI); |
|
449 | - $longitude2 = $longitude2 * (180/M_PI); |
|
448 | + $latitude2 = $latitude2*(180/M_PI); |
|
449 | + $longitude2 = $longitude2*(180/M_PI); |
|
450 | 450 | |
451 | - $flat = round ($latitude2,6); |
|
452 | - $flong = round ($longitude2,6); |
|
451 | + $flat = round($latitude2, 6); |
|
452 | + $flong = round($longitude2, 6); |
|
453 | 453 | /* |
454 | 454 | $dx = $distance*cos($bearing); |
455 | 455 | $dy = $distance*sin($bearing); |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | $flong = $longitude + $dlong; |
459 | 459 | $flat = $latitude + $dlat; |
460 | 460 | */ |
461 | - return array('latitude' => $flat,'longitude' => $flong); |
|
461 | + return array('latitude' => $flat, 'longitude' => $flong); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -472,14 +472,14 @@ discard block |
||
472 | 472 | * @param integer $level GZIP compression level (default: 9) |
473 | 473 | * @return string New filename (with .gz appended) if success, or false if operation fails |
474 | 474 | */ |
475 | - public function gzCompressFile($source, $level = 9){ |
|
476 | - $dest = $source . '.gz'; |
|
477 | - $mode = 'wb' . $level; |
|
475 | + public function gzCompressFile($source, $level = 9) { |
|
476 | + $dest = $source.'.gz'; |
|
477 | + $mode = 'wb'.$level; |
|
478 | 478 | $error = false; |
479 | 479 | if ($fp_out = gzopen($dest, $mode)) { |
480 | - if ($fp_in = fopen($source,'rb')) { |
|
480 | + if ($fp_in = fopen($source, 'rb')) { |
|
481 | 481 | while (!feof($fp_in)) |
482 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
482 | + gzwrite($fp_out, fread($fp_in, 1024*512)); |
|
483 | 483 | fclose($fp_in); |
484 | 484 | } else { |
485 | 485 | $error = true; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | } |
496 | 496 | |
497 | 497 | public function remove_accents($string) { |
498 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
498 | + if (!preg_match('/[\x80-\xff]/', $string)) return $string; |
|
499 | 499 | $chars = array( |
500 | 500 | // Decompositions for Latin-1 Supplement |
501 | 501 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
553 | 553 | chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
554 | 554 | chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
555 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
555 | + chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij', |
|
556 | 556 | chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
557 | 557 | chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
558 | 558 | chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
@@ -568,13 +568,13 @@ discard block |
||
568 | 568 | chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
569 | 569 | chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
570 | 570 | chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
571 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
572 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
573 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
574 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
575 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
576 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
577 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
571 | + chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', |
|
572 | + chr(197).chr(148) => 'R', chr(197).chr(149) => 'r', |
|
573 | + chr(197).chr(150) => 'R', chr(197).chr(151) => 'r', |
|
574 | + chr(197).chr(152) => 'R', chr(197).chr(153) => 'r', |
|
575 | + chr(197).chr(154) => 'S', chr(197).chr(155) => 's', |
|
576 | + chr(197).chr(156) => 'S', chr(197).chr(157) => 's', |
|
577 | + chr(197).chr(158) => 'S', chr(197).chr(159) => 's', |
|
578 | 578 | chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
579 | 579 | chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
580 | 580 | chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) { |
609 | 609 | if (is_numeric($string[$i]) && $concat_flag) { |
610 | 610 | $int .= $string[$i]; |
611 | - } elseif(!$concat && $concat_flag && strlen($int) > 0) { |
|
611 | + } elseif (!$concat && $concat_flag && strlen($int) > 0) { |
|
612 | 612 | $concat_flag = false; |
613 | 613 | } |
614 | 614 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * Translated to PHP of GeographicLib/src/Geoid.cpp |
12 | 12 | * by Ycarus <[email protected]> in 2017 |
13 | 13 | */ |
14 | -class GeoidHeight { |
|
14 | +class GeoidHeight { |
|
15 | 15 | private $c0 = 240; |
16 | 16 | private $c3 = [[9, -18, -88, 0, 96, 90, 0, 0, -60, -20], [-9, 18, 8, 0, -96, 30, 0, 0, 60, -20], [9, -88, -18, 90, 96, 0, -20, -60, 0, 0], [186, -42, -42, -150, -96, -150, 60, 60, 60, 60], [54, 162, -78, 30, -24, -90, -60, 60, -60, 60], [-9, -32, 18, 30, 24, 0, 20, -60, 0, 0], [-9, 8, 18, 30, -96, 0, -20, 60, 0, 0], [54, -78, 162, -90, -24, 30, 60, -60, 60, -60], [-54, 78, 78, 90, 144, 90, -60, -60, -60, -60], [9, -8, -18, -30, -24, 0, 20, 60, 0, 0], [-9, 18, -32, 0, 24, 30, 0, 0, -60, 20], [9, -18, -8, 0, -24, -30, 0, 0, 60, 20]]; |
17 | 17 | private $c0n = 372; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | private $v10 = null; |
35 | 35 | private $v11 = null; |
36 | 36 | |
37 | - public function __construct($name='') { |
|
37 | + public function __construct($name = '') { |
|
38 | 38 | global $globalGeoidSource; |
39 | 39 | //if ($name == '') $name = dirname(__FILE__).'/../install/tmp/egm2008-1.pgm'; |
40 | 40 | if ($name == '') { |
@@ -42,35 +42,35 @@ discard block |
||
42 | 42 | else $name = dirname(__FILE__).'/../data/egm96-15.pgm'; |
43 | 43 | } |
44 | 44 | |
45 | - $f = @fopen($name,"r"); |
|
45 | + $f = @fopen($name, "r"); |
|
46 | 46 | if ($f === FALSE) { |
47 | 47 | throw new Exception("Can't open ".$name); |
48 | 48 | } |
49 | - $line = fgets($f,4096); |
|
49 | + $line = fgets($f, 4096); |
|
50 | 50 | if (trim($line) != 'P5') { |
51 | 51 | throw new Exception('No PGM header'); |
52 | 52 | } |
53 | 53 | $headerlen = strlen($line); |
54 | 54 | while (true) { |
55 | - $line = fgets($f,4096); |
|
55 | + $line = fgets($f, 4096); |
|
56 | 56 | if ((strlen($line) == 0)) { |
57 | 57 | throw new Exception('EOF before end of file header'); |
58 | 58 | } |
59 | 59 | $headerlen += strlen($line); |
60 | - if (strpos($line,'# Offset ') !== FALSE) { |
|
60 | + if (strpos($line, '# Offset ') !== FALSE) { |
|
61 | 61 | $this->offset = substr($line, 9); |
62 | - } else if (strpos($line,'# Scale ') !== FALSE) { |
|
62 | + } else if (strpos($line, '# Scale ') !== FALSE) { |
|
63 | 63 | $this->scale = substr($line, 8); |
64 | - } else if ((strpos($line,'#') === FALSE)) { |
|
65 | - list($this->width, $this->height) = preg_split('/\s+/',$line); |
|
64 | + } else if ((strpos($line, '#') === FALSE)) { |
|
65 | + list($this->width, $this->height) = preg_split('/\s+/', $line); |
|
66 | 66 | break; |
67 | 67 | } |
68 | 68 | } |
69 | - $line = fgets($f,4096); |
|
69 | + $line = fgets($f, 4096); |
|
70 | 70 | $headerlen += strlen($line); |
71 | - $levels = (int)$line; |
|
72 | - $this->width = (int)$this->width; |
|
73 | - $this->height = (int)$this->height; |
|
71 | + $levels = (int) $line; |
|
72 | + $this->width = (int) $this->width; |
|
73 | + $this->height = (int) $this->height; |
|
74 | 74 | if (($levels != 65535)) { |
75 | 75 | throw new Exception('PGM file must have 65535 gray levels ('.$levels.')'); |
76 | 76 | } |
@@ -85,42 +85,42 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | $fullsize = filesize($name); |
88 | - if ((($fullsize - $headerlen) != (($this->width * $this->height) * 2))) { |
|
88 | + if ((($fullsize - $headerlen) != (($this->width*$this->height)*2))) { |
|
89 | 89 | throw new Exception('File has the wrong length'); |
90 | 90 | } |
91 | 91 | |
92 | 92 | $this->headerlen = $headerlen; |
93 | - $this->raw= $f; |
|
94 | - $this->rlonres = ($this->width / 360.0); |
|
95 | - $this->rlatres = (($this->height - 1) / 180.0); |
|
93 | + $this->raw = $f; |
|
94 | + $this->rlonres = ($this->width/360.0); |
|
95 | + $this->rlatres = (($this->height - 1)/180.0); |
|
96 | 96 | } |
97 | 97 | |
98 | - private function _rawval($ix,$iy) { |
|
98 | + private function _rawval($ix, $iy) { |
|
99 | 99 | if (($iy < 0)) { |
100 | 100 | $iy = -$iy; |
101 | - $ix += ($this->width / 2); |
|
101 | + $ix += ($this->width/2); |
|
102 | 102 | } else if (($iy >= $this->height)) { |
103 | - $iy = ((2 * ($this->height - 1)) - $iy); |
|
104 | - $ix += ($this->width / 2); |
|
103 | + $iy = ((2*($this->height - 1)) - $iy); |
|
104 | + $ix += ($this->width/2); |
|
105 | 105 | } |
106 | 106 | if (($ix < 0)) { |
107 | 107 | $ix += $this->width; |
108 | 108 | } else if (($ix >= $this->width)) { |
109 | 109 | $ix -= $this->width; |
110 | 110 | } |
111 | - $k = ((($iy * $this->width) + $ix) * 2) + $this->headerlen; |
|
112 | - fseek($this->raw,$k); |
|
113 | - return unpack('n',fread($this->raw,2))[1]; |
|
111 | + $k = ((($iy*$this->width) + $ix)*2) + $this->headerlen; |
|
112 | + fseek($this->raw, $k); |
|
113 | + return unpack('n', fread($this->raw, 2))[1]; |
|
114 | 114 | } |
115 | 115 | |
116 | - public function get($lat,$lon,$cubic=true) { |
|
116 | + public function get($lat, $lon, $cubic = true) { |
|
117 | 117 | if (($lon < 0)) { |
118 | 118 | $lon += 360; |
119 | 119 | } |
120 | - $fy = ((90 - $lat) * $this->rlatres); |
|
121 | - $fx = ($lon * $this->rlonres); |
|
122 | - $iy = (int)$fy; |
|
123 | - $ix = (int)$fx; |
|
120 | + $fy = ((90 - $lat)*$this->rlatres); |
|
121 | + $fx = ($lon*$this->rlonres); |
|
122 | + $iy = (int) $fy; |
|
123 | + $ix = (int) $fx; |
|
124 | 124 | $fx -= $ix; |
125 | 125 | $fy -= $iy; |
126 | 126 | $t = array(); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $c3x = $this->c3; |
148 | 148 | $c0x = $this->c0; |
149 | 149 | } |
150 | - for ($i = 0; $i < 10;++$i) { |
|
150 | + for ($i = 0; $i < 10; ++$i) { |
|
151 | 151 | $t[$i] = 0; |
152 | 152 | for ($j = 0; $j < 12; ++$j) { |
153 | 153 | $t[$i] += $v[$j]*$c3x[$j][$i]; |
@@ -158,13 +158,13 @@ discard block |
||
158 | 158 | $this->t = $t; |
159 | 159 | } else $t = $this->t; |
160 | 160 | if (!($cubic)) { |
161 | - $a = (((1 - $fx) * $this->v00) + ($fx * $this->v01)); |
|
162 | - $b = (((1 - $fx) * $this->v10) + ($fx * $this->v11)); |
|
163 | - $h = (((1 - $fy) * $a) + ($fy * $b)); |
|
161 | + $a = (((1 - $fx)*$this->v00) + ($fx*$this->v01)); |
|
162 | + $b = (((1 - $fx)*$this->v10) + ($fx*$this->v11)); |
|
163 | + $h = (((1 - $fy)*$a) + ($fy*$b)); |
|
164 | 164 | } else { |
165 | - $h = (($t[0] + ($fx * ($t[1] + ($fx * ($t[3] + ($fx * $t[6])))))) + ($fy * (($t[2] + ($fx * ($t[4] + ($fx * $t[7])))) + ($fy * (($t[5] + ($fx * $t[8])) + ($fy * $t[9])))))); |
|
165 | + $h = (($t[0] + ($fx*($t[1] + ($fx*($t[3] + ($fx*$t[6])))))) + ($fy*(($t[2] + ($fx*($t[4] + ($fx*$t[7])))) + ($fy*(($t[5] + ($fx*$t[8])) + ($fy*$t[9])))))); |
|
166 | 166 | } |
167 | - return ((float)$this->offset + ((float)$this->scale * (float)$h)); |
|
167 | + return ((float) $this->offset + ((float) $this->scale*(float) $h)); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | /* |
@@ -55,23 +55,23 @@ discard block |
||
55 | 55 | $min = true; |
56 | 56 | $allhistory = false; |
57 | 57 | $filter['source'] = array(); |
58 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
59 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
60 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
61 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
62 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
63 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
64 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
58 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
59 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
60 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
61 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
62 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
63 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
64 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
65 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
66 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
67 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
68 | 68 | |
69 | 69 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
70 | 70 | $min = true; |
71 | 71 | } else $min = false; |
72 | 72 | |
73 | 73 | if (isset($_GET['ident'])) { |
74 | - $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
|
74 | + $ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING)); |
|
75 | 75 | if ($tracker) { |
76 | 76 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident); |
77 | 77 | } elseif ($marine) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | $allhistory = true; |
87 | 87 | } elseif (isset($_GET['flightaware_id'])) { |
88 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
88 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
89 | 89 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
90 | 90 | if (empty($spotter_array)) { |
91 | 91 | $from_archive = true; |
@@ -93,44 +93,44 @@ discard block |
||
93 | 93 | } |
94 | 94 | $allhistory = true; |
95 | 95 | } elseif (isset($_GET['famtrack_id'])) { |
96 | - $famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING)); |
|
96 | + $famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING)); |
|
97 | 97 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id); |
98 | 98 | $allhistory = true; |
99 | 99 | } elseif (isset($_GET['fammarine_id'])) { |
100 | - $fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING)); |
|
100 | + $fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING)); |
|
101 | 101 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id); |
102 | 102 | $allhistory = true; |
103 | 103 | } elseif (isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) { |
104 | 104 | //} elseif (isset($_GET['coord'])) { |
105 | 105 | $usecoord = true; |
106 | - $coord = explode(',',$_GET['coord']); |
|
106 | + $coord = explode(',', $_GET['coord']); |
|
107 | 107 | if ($tracker) { |
108 | - $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter); |
|
108 | + $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord, $filter); |
|
109 | 109 | } elseif ($marine) { |
110 | - $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter); |
|
110 | + $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord, $filter); |
|
111 | 111 | } else { |
112 | - $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter); |
|
112 | + $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter); |
|
113 | 113 | } |
114 | 114 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) { |
115 | 115 | $usecoord = true; |
116 | - $coord = explode(',',$_GET['coord']); |
|
116 | + $coord = explode(',', $_GET['coord']); |
|
117 | 117 | if ($tracker) { |
118 | - $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
|
118 | + $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter); |
|
119 | 119 | } elseif ($marine) { |
120 | - $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter); |
|
120 | + $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter); |
|
121 | 121 | } else { |
122 | - $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter); |
|
122 | + $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter); |
|
123 | 123 | } |
124 | 124 | } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) { |
125 | 125 | $from_archive = true; |
126 | 126 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
127 | 127 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
128 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
129 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
130 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
131 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
132 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
133 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
128 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
129 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
130 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
131 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
132 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
133 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
134 | 134 | } elseif ($min) { |
135 | 135 | if ($tracker) { |
136 | 136 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter); |
@@ -142,18 +142,18 @@ discard block |
||
142 | 142 | # $min = true; |
143 | 143 | } else { |
144 | 144 | if ($tracker) { |
145 | - $spotter_array = $TrackerLive->getLiveTrackerData('','',$filter); |
|
145 | + $spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter); |
|
146 | 146 | } elseif ($marine) { |
147 | - $spotter_array = $marineLive->getLiveMarineData('','',$filter); |
|
147 | + $spotter_array = $marineLive->getLiveMarineData('', '', $filter); |
|
148 | 148 | } else { |
149 | - $spotter_array = $SpotterLive->getLiveSpotterData('','',$filter); |
|
149 | + $spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | if (!empty($spotter_array) || $usecoord) { |
154 | 154 | if ($usecoord) { |
155 | 155 | if (isset($_GET['archive'])) { |
156 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
156 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
157 | 157 | } else { |
158 | 158 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
159 | 159 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | if ($flightcnt == '') $flightcnt = 0; |
162 | 162 | } else $flightcnt = 0; |
163 | 163 | |
164 | -$sqltime = round(microtime(true)-$begintime,2); |
|
164 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
165 | 165 | |
166 | 166 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
167 | 167 | else $usenextlatlon = true; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | if (!empty($spotter_array) && is_array($spotter_array)) |
179 | 179 | { |
180 | 180 | $output .= '"features": ['; |
181 | - foreach($spotter_array as $spotter_item) |
|
181 | + foreach ($spotter_array as $spotter_item) |
|
182 | 182 | { |
183 | 183 | $j++; |
184 | 184 | date_default_timezone_set('UTC'); |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | */ |
235 | 235 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
236 | 236 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
237 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
238 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
237 | + if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
238 | + else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
239 | 239 | //" |
240 | 240 | } else { |
241 | 241 | if ($compress) $output .= '"c": "NA",'; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
245 | 245 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
246 | 246 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
247 | - $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
|
247 | + $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",'; |
|
248 | 248 | } elseif (isset($spotter_item['aircraft_type'])) { |
249 | 249 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
250 | 250 | } elseif (!$min) { |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
386 | 386 | |
387 | 387 | if (isset($archivespeed)) { |
388 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
388 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed); |
|
389 | 389 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
390 | 390 | } elseif ($usenextlatlon) { |
391 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
391 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']); |
|
392 | 392 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
393 | 393 | } |
394 | 394 | |
395 | 395 | if (!$min) $output .= '"image": "'.$image.'",'; |
396 | 396 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
397 | - $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
|
397 | + $output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; |
|
398 | 398 | } |
399 | 399 | if (isset($spotter_item['image_source_website'])) { |
400 | 400 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
417 | 417 | } |
418 | 418 | if (isset($spotter_item['acars'])) { |
419 | - $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
|
419 | + $output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; |
|
420 | 420 | } |
421 | 421 | // type when not aircraft ? |
422 | 422 | if (isset($spotter_item['type'])) { |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | |
495 | 495 | } |
496 | 496 | */ |
497 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
|
497 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING); |
|
498 | 498 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
499 | 499 | |
500 | 500 | if ( |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
503 | 503 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
504 | 504 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
505 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
505 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
506 | 506 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
507 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
507 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id'])) |
|
508 | 508 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
509 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
509 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid'])) |
|
510 | 510 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
511 | 511 | ) { |
512 | 512 | if ($tracker) { |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
544 | 544 | } |
545 | 545 | $output_history .= '['; |
546 | - $output_history .= $spotter_history['longitude'].', '; |
|
547 | - $output_history .= $spotter_history['latitude'].', '; |
|
548 | - $output_history .= $spotter_history['altitude']*30.48; |
|
546 | + $output_history .= $spotter_history['longitude'].', '; |
|
547 | + $output_history .= $spotter_history['latitude'].', '; |
|
548 | + $output_history .= $spotter_history['altitude']*30.48; |
|
549 | 549 | $output_history .= '],'; |
550 | 550 | /* |
551 | 551 | if ($from_archive === false) { |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
564 | 564 | } else $d = true; |
565 | 565 | $output_history .= '['; |
566 | - $output_history .= $spotter_history['longitude'].', '; |
|
567 | - $output_history .= $spotter_history['latitude']; |
|
566 | + $output_history .= $spotter_history['longitude'].', '; |
|
567 | + $output_history .= $spotter_history['latitude']; |
|
568 | 568 | $output_history .= '],'; |
569 | 569 | /* |
570 | 570 | if ($from_archive === false) { |
@@ -580,9 +580,9 @@ discard block |
||
580 | 580 | |
581 | 581 | if ($from_archive === false) { |
582 | 582 | $output_historyd = '['; |
583 | - $output_historyd .= $spotter_item['longitude'].', '; |
|
584 | - $output_historyd .= $spotter_item['latitude']; |
|
585 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
583 | + $output_historyd .= $spotter_item['longitude'].', '; |
|
584 | + $output_historyd .= $spotter_item['latitude']; |
|
585 | + if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
586 | 586 | $output_historyd .= '],'; |
587 | 587 | //$output_history = $output_historyd.$output_history; |
588 | 588 | $output_history = $output_history.$output_historyd; |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | } |
597 | 597 | } |
598 | 598 | |
599 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
599 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
600 | 600 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
601 | 601 | && (isset($spotter_item['departure_airport']) |
602 | 602 | && $spotter_item['departure_airport'] != 'NA' |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | |
631 | 631 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
632 | 632 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
633 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
633 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
634 | 634 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
635 | 635 | && (isset($spotter_item['arrival_airport']) |
636 | 636 | && $spotter_item['arrival_airport'] != 'NA' |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | $output = substr($output, 0, -1); |
662 | 662 | $output .= ']'; |
663 | 663 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
664 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
|
664 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",'; |
|
665 | 665 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
666 | 666 | $output .= '"fc": "'.$j.'"'; |
667 | 667 | } else { |
@@ -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(); |
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') { |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | try { |
15 | 15 | $sth = $Connection->db->prepare($query); |
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch (PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | 19 | } |
20 | 20 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | try { |
51 | 51 | $sth = $Connection->db->prepare($query); |
52 | 52 | $sth->execute(); |
53 | - } catch(PDOException $e) { |
|
53 | + } catch (PDOException $e) { |
|
54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
55 | 55 | } |
56 | 56 | // Copy schedules data to routes table |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $sth = $Connection->db->prepare($query); |
62 | 62 | $sth->execute(); |
63 | - } catch(PDOException $e) { |
|
63 | + } catch (PDOException $e) { |
|
64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; |
65 | 65 | } |
66 | 66 | // Add source column |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | try { |
69 | 69 | $sth = $Connection->db->prepare($query); |
70 | 70 | $sth->execute(); |
71 | - } catch(PDOException $e) { |
|
71 | + } catch (PDOException $e) { |
|
72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
73 | 73 | } |
74 | 74 | // Delete unused column |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | try { |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
81 | 81 | } |
82 | 82 | // Add ModeS column |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | try { |
85 | 85 | $sth = $Connection->db->prepare($query); |
86 | 86 | $sth->execute(); |
87 | - } catch(PDOException $e) { |
|
87 | + } catch (PDOException $e) { |
|
88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
89 | 89 | } |
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | 91 | try { |
92 | 92 | $sth = $Connection->db->prepare($query); |
93 | 93 | $sth->execute(); |
94 | - } catch(PDOException $e) { |
|
94 | + } catch (PDOException $e) { |
|
95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
96 | 96 | } |
97 | 97 | // Add auto_increment for aircraft_modes |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | try { |
100 | 100 | $sth = $Connection->db->prepare($query); |
101 | 101 | $sth->execute(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
104 | 104 | } |
105 | 105 | $error = ''; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | try { |
111 | 111 | $sth = $Connection->db->prepare($query); |
112 | 112 | $sth->execute(); |
113 | - } catch(PDOException $e) { |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
115 | 115 | } |
116 | 116 | return $error; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | try { |
124 | 124 | $sth = $Connection->db->prepare($query); |
125 | 125 | $sth->execute(); |
126 | - } catch(PDOException $e) { |
|
126 | + } catch (PDOException $e) { |
|
127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
128 | 128 | } |
129 | 129 | $error = ''; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | try { |
135 | 135 | $sth = $Connection->db->prepare($query); |
136 | 136 | $sth->execute(); |
137 | - } catch(PDOException $e) { |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
139 | 139 | } |
140 | 140 | return $error; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | try { |
148 | 148 | $sth = $Connection->db->prepare($query); |
149 | 149 | $sth->execute(); |
150 | - } catch(PDOException $e) { |
|
150 | + } catch (PDOException $e) { |
|
151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
152 | 152 | } |
153 | 153 | // Add image_source_website column to spotter_image |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | try { |
156 | 156 | $sth = $Connection->db->prepare($query); |
157 | 157 | $sth->execute(); |
158 | - } catch(PDOException $e) { |
|
158 | + } catch (PDOException $e) { |
|
159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
160 | 160 | } |
161 | 161 | $error = ''; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $Connection->db->prepare($query); |
166 | 166 | $sth->execute(); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
169 | 169 | } |
170 | 170 | return $error; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | try { |
183 | 183 | $sth = $Connection->db->prepare($query); |
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch (PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | 187 | } |
188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $Connection->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
201 | 201 | } |
202 | 202 | // Add aircraft_shadow column to aircraft |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | try { |
205 | 205 | $sth = $Connection->db->prepare($query); |
206 | 206 | $sth->execute(); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
209 | 209 | } |
210 | 210 | // Add aircraft_shadow column to spotter_live |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $Connection->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
217 | 217 | } |
218 | 218 | $error = ''; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | try { |
226 | 226 | $sth = $Connection->db->prepare($query); |
227 | 227 | $sth->execute(); |
228 | - } catch(PDOException $e) { |
|
228 | + } catch (PDOException $e) { |
|
229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
230 | 230 | } |
231 | 231 | return $error; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | 235 | $Connection = new Connection(); |
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
236 | + if (!$Connection->indexExists('spotter_output', 'flightaware_id')) { |
|
237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | 255 | } |
256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
270 | 270 | } |
271 | 271 | return $error; |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | 276 | $Connection = new Connection(); |
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | 279 | try { |
280 | 280 | $sth = $Connection->db->prepare($query); |
281 | 281 | $sth->execute(); |
282 | - } catch(PDOException $e) { |
|
282 | + } catch (PDOException $e) { |
|
283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
284 | 284 | } |
285 | 285 | if ($globalDBdriver == 'mysql') { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | try { |
288 | 288 | $sth = $Connection->db->prepare($query); |
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch (PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | 292 | } |
293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | 301 | } else { |
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | 303 | } |
304 | 304 | } else { |
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | 306 | } |
307 | 307 | try { |
308 | 308 | $sth = $Connection->db->prepare($query); |
309 | 309 | $sth->execute(); |
310 | - } catch(PDOException $e) { |
|
310 | + } catch (PDOException $e) { |
|
311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
312 | 312 | } |
313 | 313 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
325 | 325 | } |
326 | 326 | return $error; |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | try { |
340 | 340 | $sth = $Connection->db->prepare($query); |
341 | 341 | $sth->execute(); |
342 | - } catch(PDOException $e) { |
|
342 | + } catch (PDOException $e) { |
|
343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; |
344 | 344 | } |
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | 346 | try { |
347 | 347 | $sth = $Connection->db->prepare($query); |
348 | 348 | $sth->execute(); |
349 | - } catch(PDOException $e) { |
|
349 | + } catch (PDOException $e) { |
|
350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
351 | 351 | } |
352 | 352 | return $error; |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | 356 | $Connection = new Connection(); |
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | 359 | try { |
360 | 360 | $sth = $Connection->db->prepare($query); |
361 | 361 | $sth->execute(); |
362 | - } catch(PDOException $e) { |
|
362 | + } catch (PDOException $e) { |
|
363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
364 | 364 | } |
365 | 365 | $error = ''; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $sth = $Connection->db->prepare($query); |
373 | 373 | $sth->execute(); |
374 | - } catch(PDOException $e) { |
|
374 | + } catch (PDOException $e) { |
|
375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
376 | 376 | } |
377 | 377 | return $error; |
@@ -379,11 +379,11 @@ discard block |
||
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | 381 | $Connection = new Connection(); |
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
382 | + $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | 383 | try { |
384 | 384 | $sth = $Connection->db->prepare($query); |
385 | 385 | $sth->execute(); |
386 | - } catch(PDOException $e) { |
|
386 | + } catch (PDOException $e) { |
|
387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
388 | 388 | } |
389 | 389 | $error = ''; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | try { |
402 | 402 | $sth = $Connection->db->prepare($query); |
403 | 403 | $sth->execute(); |
404 | - } catch(PDOException $e) { |
|
404 | + } catch (PDOException $e) { |
|
405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
406 | 406 | } |
407 | 407 | return $error; |
@@ -410,18 +410,18 @@ discard block |
||
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | 412 | $Connection = new Connection(); |
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
413 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | 414 | try { |
415 | 415 | $sth = $Connection->db->prepare($query); |
416 | 416 | $sth->execute(); |
417 | - } catch(PDOException $e) { |
|
417 | + } catch (PDOException $e) { |
|
418 | 418 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
419 | 419 | } |
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
420 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | 421 | try { |
422 | 422 | $sth = $Connection->db->prepare($query); |
423 | 423 | $sth->execute(); |
424 | - } catch(PDOException $e) { |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
426 | 426 | } |
427 | 427 | if ($globalDBdriver == 'mysql') { |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | try { |
430 | 430 | $sth = $Connection->db->prepare($query); |
431 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
432 | + } catch (PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | 434 | } |
435 | 435 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -441,15 +441,15 @@ discard block |
||
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | 443 | } else { |
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
444 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | 445 | } |
446 | 446 | } else { |
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
447 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | 448 | } |
449 | 449 | try { |
450 | 450 | $sth = $Connection->db->prepare($query); |
451 | 451 | $sth->execute(); |
452 | - } catch(PDOException $e) { |
|
452 | + } catch (PDOException $e) { |
|
453 | 453 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
454 | 454 | } |
455 | 455 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | try { |
460 | 460 | $sth = $Connection->db->prepare($query); |
461 | 461 | $sth->execute(); |
462 | - } catch(PDOException $e) { |
|
462 | + } catch (PDOException $e) { |
|
463 | 463 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
464 | 464 | } |
465 | 465 | return $error; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $Connection->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
492 | 492 | } |
493 | 493 | return $error; |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | 497 | $Connection = new Connection(); |
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) { |
|
499 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch (PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | 505 | } |
506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | try { |
510 | 510 | $sth = $Connection->db->prepare($query); |
511 | 511 | $sth->execute(); |
512 | - } catch(PDOException $e) { |
|
512 | + } catch (PDOException $e) { |
|
513 | 513 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
514 | 514 | } |
515 | 515 | return $error; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $Connection->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
532 | 532 | } |
533 | 533 | return $error; |
@@ -538,11 +538,11 @@ discard block |
||
538 | 538 | $Connection = new Connection(); |
539 | 539 | $error = ''; |
540 | 540 | // Add tables |
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
541 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | 542 | try { |
543 | 543 | $sth = $Connection->db->prepare($query); |
544 | 544 | $sth->execute(); |
545 | - } catch(PDOException $e) { |
|
545 | + } catch (PDOException $e) { |
|
546 | 546 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 547 | } |
548 | 548 | if ($error != '') return $error; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | try { |
551 | 551 | $sth = $Connection->db->prepare($query); |
552 | 552 | $sth->execute(); |
553 | - } catch(PDOException $e) { |
|
553 | + } catch (PDOException $e) { |
|
554 | 554 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
555 | 555 | } |
556 | 556 | return $error; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | try { |
572 | 572 | $sth = $Connection->db->prepare($query); |
573 | 573 | $sth->execute(); |
574 | - } catch(PDOException $e) { |
|
574 | + } catch (PDOException $e) { |
|
575 | 575 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
576 | 576 | } |
577 | 577 | return $error; |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | try { |
590 | 590 | $sth = $Connection->db->prepare($query); |
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
594 | 594 | } |
595 | 595 | return $error; |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | $Connection = new Connection(); |
599 | 599 | $error = ''; |
600 | 600 | // Modify stats_airport table |
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
601 | + if (!$Connection->checkColumnName('stats_airport', 'airport_name')) { |
|
602 | 602 | $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
603 | 603 | try { |
604 | 604 | $sth = $Connection->db->prepare($query); |
605 | 605 | $sth->execute(); |
606 | - } catch(PDOException $e) { |
|
606 | + } catch (PDOException $e) { |
|
607 | 607 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 608 | } |
609 | 609 | } |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | try { |
613 | 613 | $sth = $Connection->db->prepare($query); |
614 | 614 | $sth->execute(); |
615 | - } catch(PDOException $e) { |
|
615 | + } catch (PDOException $e) { |
|
616 | 616 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
617 | 617 | } |
618 | 618 | return $error; |
@@ -629,73 +629,73 @@ discard block |
||
629 | 629 | try { |
630 | 630 | $sth = $Connection->db->prepare($query); |
631 | 631 | $sth->execute(); |
632 | - } catch(PDOException $e) { |
|
632 | + } catch (PDOException $e) { |
|
633 | 633 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
634 | 634 | } |
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | 636 | try { |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
641 | 641 | } |
642 | - if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
|
642 | + if (!$Connection->checkColumnName('spotter_archive', 'over_country')) { |
|
643 | 643 | // Add column over_country |
644 | 644 | $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
645 | 645 | try { |
646 | 646 | $sth = $Connection->db->prepare($query); |
647 | 647 | $sth->execute(); |
648 | - } catch(PDOException $e) { |
|
648 | + } catch (PDOException $e) { |
|
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
650 | 650 | } |
651 | 651 | } |
652 | - if (!$Connection->checkColumnName('spotter_live','over_country')) { |
|
652 | + if (!$Connection->checkColumnName('spotter_live', 'over_country')) { |
|
653 | 653 | // Add column over_country |
654 | 654 | $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
655 | 655 | try { |
656 | 656 | $sth = $Connection->db->prepare($query); |
657 | 657 | $sth->execute(); |
658 | - } catch(PDOException $e) { |
|
658 | + } catch (PDOException $e) { |
|
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
660 | 660 | } |
661 | 661 | } |
662 | - if (!$Connection->checkColumnName('spotter_output','source_name')) { |
|
662 | + if (!$Connection->checkColumnName('spotter_output', 'source_name')) { |
|
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | 664 | $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | - } catch(PDOException $e) { |
|
668 | + } catch (PDOException $e) { |
|
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | 670 | } |
671 | 671 | } |
672 | - if (!$Connection->checkColumnName('spotter_live','source_name')) { |
|
672 | + if (!$Connection->checkColumnName('spotter_live', 'source_name')) { |
|
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | 674 | $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | - } catch(PDOException $e) { |
|
678 | + } catch (PDOException $e) { |
|
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | 680 | } |
681 | 681 | } |
682 | - if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
|
682 | + if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) { |
|
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | 684 | $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | - } catch(PDOException $e) { |
|
688 | + } catch (PDOException $e) { |
|
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | 690 | } |
691 | 691 | } |
692 | - if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
|
692 | + if (!$Connection->checkColumnName('spotter_archive', 'source_name')) { |
|
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | 694 | $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | - } catch(PDOException $e) { |
|
698 | + } catch (PDOException $e) { |
|
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 700 | } |
701 | 701 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | try { |
705 | 705 | $sth = $Connection->db->prepare($query); |
706 | 706 | $sth->execute(); |
707 | - } catch(PDOException $e) { |
|
707 | + } catch (PDOException $e) { |
|
708 | 708 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
709 | 709 | } |
710 | 710 | return $error; |
@@ -719,13 +719,13 @@ discard block |
||
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | - if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
|
722 | + if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) { |
|
723 | 723 | // Add column over_country |
724 | 724 | $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
725 | 725 | try { |
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | - } catch(PDOException $e) { |
|
728 | + } catch (PDOException $e) { |
|
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 730 | } |
731 | 731 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | try { |
742 | 742 | $sth = $Connection->db->prepare($query); |
743 | 743 | $sth->execute(); |
744 | - } catch(PDOException $e) { |
|
744 | + } catch (PDOException $e) { |
|
745 | 745 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
746 | 746 | } |
747 | 747 | return $error; |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | private static function update_from_21() { |
751 | 751 | $Connection = new Connection(); |
752 | 752 | $error = ''; |
753 | - if (!$Connection->checkColumnName('stats_airport','stats_type')) { |
|
753 | + if (!$Connection->checkColumnName('stats_airport', 'stats_type')) { |
|
754 | 754 | // Rename type to stats_type |
755 | 755 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
756 | 756 | try { |
757 | 757 | $sth = $Connection->db->prepare($query); |
758 | 758 | $sth->execute(); |
759 | - } catch(PDOException $e) { |
|
759 | + } catch (PDOException $e) { |
|
760 | 760 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 761 | } |
762 | 762 | if ($error != '') return $error; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | try { |
766 | 766 | $sth = $Connection->db->prepare($query); |
767 | 767 | $sth->execute(); |
768 | - } catch(PDOException $e) { |
|
768 | + } catch (PDOException $e) { |
|
769 | 769 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
770 | 770 | } |
771 | 771 | return $error; |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | try { |
789 | 789 | $sth = $Connection->db->prepare($query); |
790 | 790 | $sth->execute(); |
791 | - } catch(PDOException $e) { |
|
791 | + } catch (PDOException $e) { |
|
792 | 792 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
793 | 793 | } |
794 | 794 | return $error; |
@@ -815,17 +815,17 @@ discard block |
||
815 | 815 | try { |
816 | 816 | $sth = $Connection->db->prepare($query); |
817 | 817 | $sth->execute(); |
818 | - } catch(PDOException $e) { |
|
818 | + } catch (PDOException $e) { |
|
819 | 819 | return "error (create index on spotter_archive) : ".$e->getMessage()."\n"; |
820 | 820 | } |
821 | 821 | } |
822 | - if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
|
822 | + if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) { |
|
823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
824 | 824 | $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
825 | 825 | try { |
826 | 826 | $sth = $Connection->db->prepare($query); |
827 | 827 | $sth->execute(); |
828 | - } catch(PDOException $e) { |
|
828 | + } catch (PDOException $e) { |
|
829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
830 | 830 | } |
831 | 831 | } |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | try { |
835 | 835 | $sth = $Connection->db->prepare($query); |
836 | 836 | $sth->execute(); |
837 | - } catch(PDOException $e) { |
|
837 | + } catch (PDOException $e) { |
|
838 | 838 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
839 | 839 | } |
840 | 840 | return $error; |
@@ -850,23 +850,23 @@ discard block |
||
850 | 850 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 851 | } |
852 | 852 | if ($error != '') return 'Import airlines.sql : '.$error; |
853 | - if (!$Connection->checkColumnName('airlines','forsource')) { |
|
853 | + if (!$Connection->checkColumnName('airlines', 'forsource')) { |
|
854 | 854 | // Add forsource to airlines |
855 | 855 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
856 | 856 | try { |
857 | 857 | $sth = $Connection->db->prepare($query); |
858 | 858 | $sth->execute(); |
859 | - } catch(PDOException $e) { |
|
859 | + } catch (PDOException $e) { |
|
860 | 860 | return "error (add forsource column) : ".$e->getMessage()."\n"; |
861 | 861 | } |
862 | 862 | } |
863 | - if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) { |
|
863 | + if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) { |
|
864 | 864 | // Add forsource to airlines |
865 | 865 | $query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
866 | 866 | try { |
867 | 867 | $sth = $Connection->db->prepare($query); |
868 | 868 | $sth->execute(); |
869 | - } catch(PDOException $e) { |
|
869 | + } catch (PDOException $e) { |
|
870 | 870 | return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n"; |
871 | 871 | } |
872 | 872 | // Add unique key |
@@ -878,17 +878,17 @@ discard block |
||
878 | 878 | try { |
879 | 879 | $sth = $Connection->db->prepare($query); |
880 | 880 | $sth->execute(); |
881 | - } catch(PDOException $e) { |
|
881 | + } catch (PDOException $e) { |
|
882 | 882 | return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n"; |
883 | 883 | } |
884 | 884 | } |
885 | - if (!$Connection->checkColumnName('stats_airport','stats_airline')) { |
|
885 | + if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) { |
|
886 | 886 | // Add forsource to airlines |
887 | 887 | $query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
888 | 888 | try { |
889 | 889 | $sth = $Connection->db->prepare($query); |
890 | 890 | $sth->execute(); |
891 | - } catch(PDOException $e) { |
|
891 | + } catch (PDOException $e) { |
|
892 | 892 | return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n"; |
893 | 893 | } |
894 | 894 | // Add unique key |
@@ -900,17 +900,17 @@ discard block |
||
900 | 900 | try { |
901 | 901 | $sth = $Connection->db->prepare($query); |
902 | 902 | $sth->execute(); |
903 | - } catch(PDOException $e) { |
|
903 | + } catch (PDOException $e) { |
|
904 | 904 | return "error (add unique key in stats_airport) : ".$e->getMessage()."\n"; |
905 | 905 | } |
906 | 906 | } |
907 | - if (!$Connection->checkColumnName('stats_country','stats_airline')) { |
|
907 | + if (!$Connection->checkColumnName('stats_country', 'stats_airline')) { |
|
908 | 908 | // Add forsource to airlines |
909 | 909 | $query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
910 | 910 | try { |
911 | 911 | $sth = $Connection->db->prepare($query); |
912 | 912 | $sth->execute(); |
913 | - } catch(PDOException $e) { |
|
913 | + } catch (PDOException $e) { |
|
914 | 914 | return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n"; |
915 | 915 | } |
916 | 916 | // Add unique key |
@@ -922,36 +922,36 @@ discard block |
||
922 | 922 | try { |
923 | 923 | $sth = $Connection->db->prepare($query); |
924 | 924 | $sth->execute(); |
925 | - } catch(PDOException $e) { |
|
925 | + } catch (PDOException $e) { |
|
926 | 926 | return "error (add unique key in stats_airline) : ".$e->getMessage()."\n"; |
927 | 927 | } |
928 | 928 | } |
929 | - if (!$Connection->checkColumnName('stats_flight','stats_airline')) { |
|
929 | + if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) { |
|
930 | 930 | // Add forsource to airlines |
931 | 931 | $query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
932 | 932 | try { |
933 | 933 | $sth = $Connection->db->prepare($query); |
934 | 934 | $sth->execute(); |
935 | - } catch(PDOException $e) { |
|
935 | + } catch (PDOException $e) { |
|
936 | 936 | return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n"; |
937 | 937 | } |
938 | 938 | } |
939 | - if (!$Connection->checkColumnName('stats','stats_airline')) { |
|
939 | + if (!$Connection->checkColumnName('stats', 'stats_airline')) { |
|
940 | 940 | // Add forsource to airlines |
941 | 941 | $query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
942 | 942 | try { |
943 | 943 | $sth = $Connection->db->prepare($query); |
944 | 944 | $sth->execute(); |
945 | - } catch(PDOException $e) { |
|
945 | + } catch (PDOException $e) { |
|
946 | 946 | return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n"; |
947 | 947 | } |
948 | - if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) { |
|
948 | + if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) { |
|
949 | 949 | // Add unique key |
950 | 950 | $query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);"; |
951 | 951 | try { |
952 | 952 | $sth = $Connection->db->prepare($query); |
953 | 953 | $sth->execute(); |
954 | - } catch(PDOException $e) { |
|
954 | + } catch (PDOException $e) { |
|
955 | 955 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
956 | 956 | } |
957 | 957 | } else { |
@@ -964,18 +964,18 @@ discard block |
||
964 | 964 | try { |
965 | 965 | $sth = $Connection->db->prepare($query); |
966 | 966 | $sth->execute(); |
967 | - } catch(PDOException $e) { |
|
967 | + } catch (PDOException $e) { |
|
968 | 968 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
969 | 969 | } |
970 | 970 | } |
971 | 971 | } |
972 | - if (!$Connection->checkColumnName('stats_registration','stats_airline')) { |
|
972 | + if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) { |
|
973 | 973 | // Add forsource to airlines |
974 | 974 | $query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
975 | 975 | try { |
976 | 976 | $sth = $Connection->db->prepare($query); |
977 | 977 | $sth->execute(); |
978 | - } catch(PDOException $e) { |
|
978 | + } catch (PDOException $e) { |
|
979 | 979 | return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n"; |
980 | 980 | } |
981 | 981 | // Add unique key |
@@ -987,17 +987,17 @@ discard block |
||
987 | 987 | try { |
988 | 988 | $sth = $Connection->db->prepare($query); |
989 | 989 | $sth->execute(); |
990 | - } catch(PDOException $e) { |
|
990 | + } catch (PDOException $e) { |
|
991 | 991 | return "error (add unique key in stats_registration) : ".$e->getMessage()."\n"; |
992 | 992 | } |
993 | 993 | } |
994 | - if (!$Connection->checkColumnName('stats_callsign','filter_name')) { |
|
994 | + if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) { |
|
995 | 995 | // Add forsource to airlines |
996 | 996 | $query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
997 | 997 | try { |
998 | 998 | $sth = $Connection->db->prepare($query); |
999 | 999 | $sth->execute(); |
1000 | - } catch(PDOException $e) { |
|
1000 | + } catch (PDOException $e) { |
|
1001 | 1001 | return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n"; |
1002 | 1002 | } |
1003 | 1003 | // Add unique key |
@@ -1009,17 +1009,17 @@ discard block |
||
1009 | 1009 | try { |
1010 | 1010 | $sth = $Connection->db->prepare($query); |
1011 | 1011 | $sth->execute(); |
1012 | - } catch(PDOException $e) { |
|
1012 | + } catch (PDOException $e) { |
|
1013 | 1013 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1014 | 1014 | } |
1015 | 1015 | } |
1016 | - if (!$Connection->checkColumnName('stats_airline','filter_name')) { |
|
1016 | + if (!$Connection->checkColumnName('stats_airline', 'filter_name')) { |
|
1017 | 1017 | // Add forsource to airlines |
1018 | 1018 | $query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1019 | 1019 | try { |
1020 | 1020 | $sth = $Connection->db->prepare($query); |
1021 | 1021 | $sth->execute(); |
1022 | - } catch(PDOException $e) { |
|
1022 | + } catch (PDOException $e) { |
|
1023 | 1023 | return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n"; |
1024 | 1024 | } |
1025 | 1025 | // Add unique key |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | try { |
1032 | 1032 | $sth = $Connection->db->prepare($query); |
1033 | 1033 | $sth->execute(); |
1034 | - } catch(PDOException $e) { |
|
1034 | + } catch (PDOException $e) { |
|
1035 | 1035 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1036 | 1036 | } |
1037 | 1037 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | try { |
1041 | 1041 | $sth = $Connection->db->prepare($query); |
1042 | 1042 | $sth->execute(); |
1043 | - } catch(PDOException $e) { |
|
1043 | + } catch (PDOException $e) { |
|
1044 | 1044 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1045 | 1045 | } |
1046 | 1046 | return $error; |
@@ -1050,13 +1050,13 @@ discard block |
||
1050 | 1050 | global $globalDBdriver; |
1051 | 1051 | $Connection = new Connection(); |
1052 | 1052 | $error = ''; |
1053 | - if (!$Connection->checkColumnName('stats_owner','stats_airline')) { |
|
1053 | + if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) { |
|
1054 | 1054 | // Add forsource to airlines |
1055 | 1055 | $query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1056 | 1056 | try { |
1057 | 1057 | $sth = $Connection->db->prepare($query); |
1058 | 1058 | $sth->execute(); |
1059 | - } catch(PDOException $e) { |
|
1059 | + } catch (PDOException $e) { |
|
1060 | 1060 | return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n"; |
1061 | 1061 | } |
1062 | 1062 | // Add unique key |
@@ -1068,17 +1068,17 @@ discard block |
||
1068 | 1068 | try { |
1069 | 1069 | $sth = $Connection->db->prepare($query); |
1070 | 1070 | $sth->execute(); |
1071 | - } catch(PDOException $e) { |
|
1071 | + } catch (PDOException $e) { |
|
1072 | 1072 | return "error (add unique key in stats_owner) : ".$e->getMessage()."\n"; |
1073 | 1073 | } |
1074 | 1074 | } |
1075 | - if (!$Connection->checkColumnName('stats_pilot','stats_airline')) { |
|
1075 | + if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) { |
|
1076 | 1076 | // Add forsource to airlines |
1077 | 1077 | $query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1078 | 1078 | try { |
1079 | 1079 | $sth = $Connection->db->prepare($query); |
1080 | 1080 | $sth->execute(); |
1081 | - } catch(PDOException $e) { |
|
1081 | + } catch (PDOException $e) { |
|
1082 | 1082 | return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n"; |
1083 | 1083 | } |
1084 | 1084 | // Add unique key |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | try { |
1091 | 1091 | $sth = $Connection->db->prepare($query); |
1092 | 1092 | $sth->execute(); |
1093 | - } catch(PDOException $e) { |
|
1093 | + } catch (PDOException $e) { |
|
1094 | 1094 | return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1095 | 1095 | } |
1096 | 1096 | } |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | try { |
1099 | 1099 | $sth = $Connection->db->prepare($query); |
1100 | 1100 | $sth->execute(); |
1101 | - } catch(PDOException $e) { |
|
1101 | + } catch (PDOException $e) { |
|
1102 | 1102 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1103 | 1103 | } |
1104 | 1104 | return $error; |
@@ -1108,12 +1108,12 @@ discard block |
||
1108 | 1108 | global $globalDBdriver; |
1109 | 1109 | $Connection = new Connection(); |
1110 | 1110 | $error = ''; |
1111 | - if (!$Connection->checkColumnName('atc','format_source')) { |
|
1111 | + if (!$Connection->checkColumnName('atc', 'format_source')) { |
|
1112 | 1112 | $query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL"; |
1113 | 1113 | try { |
1114 | 1114 | $sth = $Connection->db->prepare($query); |
1115 | 1115 | $sth->execute(); |
1116 | - } catch(PDOException $e) { |
|
1116 | + } catch (PDOException $e) { |
|
1117 | 1117 | return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n"; |
1118 | 1118 | } |
1119 | 1119 | } |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | try { |
1122 | 1122 | $sth = $Connection->db->prepare($query); |
1123 | 1123 | $sth->execute(); |
1124 | - } catch(PDOException $e) { |
|
1124 | + } catch (PDOException $e) { |
|
1125 | 1125 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1126 | 1126 | } |
1127 | 1127 | return $error; |
@@ -1131,13 +1131,13 @@ discard block |
||
1131 | 1131 | global $globalDBdriver; |
1132 | 1132 | $Connection = new Connection(); |
1133 | 1133 | $error = ''; |
1134 | - if (!$Connection->checkColumnName('stats_pilot','format_source')) { |
|
1134 | + if (!$Connection->checkColumnName('stats_pilot', 'format_source')) { |
|
1135 | 1135 | // Add forsource to airlines |
1136 | 1136 | $query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''"; |
1137 | 1137 | try { |
1138 | 1138 | $sth = $Connection->db->prepare($query); |
1139 | 1139 | $sth->execute(); |
1140 | - } catch(PDOException $e) { |
|
1140 | + } catch (PDOException $e) { |
|
1141 | 1141 | return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n"; |
1142 | 1142 | } |
1143 | 1143 | // Add unique key |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | try { |
1150 | 1150 | $sth = $Connection->db->prepare($query); |
1151 | 1151 | $sth->execute(); |
1152 | - } catch(PDOException $e) { |
|
1152 | + } catch (PDOException $e) { |
|
1153 | 1153 | return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1154 | 1154 | } |
1155 | 1155 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | try { |
1158 | 1158 | $sth = $Connection->db->prepare($query); |
1159 | 1159 | $sth->execute(); |
1160 | - } catch(PDOException $e) { |
|
1160 | + } catch (PDOException $e) { |
|
1161 | 1161 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1162 | 1162 | } |
1163 | 1163 | return $error; |
@@ -1167,23 +1167,23 @@ discard block |
||
1167 | 1167 | global $globalDBdriver; |
1168 | 1168 | $Connection = new Connection(); |
1169 | 1169 | $error = ''; |
1170 | - if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) { |
|
1170 | + if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) { |
|
1171 | 1171 | // Add unique key |
1172 | 1172 | $query = "alter table spotter_live add index(latitude,longitude)"; |
1173 | 1173 | try { |
1174 | 1174 | $sth = $Connection->db->prepare($query); |
1175 | 1175 | $sth->execute(); |
1176 | - } catch(PDOException $e) { |
|
1176 | + } catch (PDOException $e) { |
|
1177 | 1177 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; |
1178 | 1178 | } |
1179 | 1179 | } |
1180 | - if (!$Connection->checkColumnName('aircraft','mfr')) { |
|
1180 | + if (!$Connection->checkColumnName('aircraft', 'mfr')) { |
|
1181 | 1181 | // Add mfr to aircraft |
1182 | 1182 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; |
1183 | 1183 | try { |
1184 | 1184 | $sth = $Connection->db->prepare($query); |
1185 | 1185 | $sth->execute(); |
1186 | - } catch(PDOException $e) { |
|
1186 | + } catch (PDOException $e) { |
|
1187 | 1187 | return "error (add mfr column in aircraft) : ".$e->getMessage()."\n"; |
1188 | 1188 | } |
1189 | 1189 | } |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | try { |
1200 | 1200 | $sth = $Connection->db->prepare($query); |
1201 | 1201 | $sth->execute(); |
1202 | - } catch(PDOException $e) { |
|
1202 | + } catch (PDOException $e) { |
|
1203 | 1203 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1204 | 1204 | } |
1205 | 1205 | return $error; |
@@ -1209,13 +1209,13 @@ discard block |
||
1209 | 1209 | global $globalDBdriver; |
1210 | 1210 | $Connection = new Connection(); |
1211 | 1211 | $error = ''; |
1212 | - if ($Connection->checkColumnName('aircraft','mfr')) { |
|
1212 | + if ($Connection->checkColumnName('aircraft', 'mfr')) { |
|
1213 | 1213 | // drop mfr to aircraft |
1214 | 1214 | $query = "ALTER TABLE aircraft DROP COLUMN mfr"; |
1215 | 1215 | try { |
1216 | 1216 | $sth = $Connection->db->prepare($query); |
1217 | 1217 | $sth->execute(); |
1218 | - } catch(PDOException $e) { |
|
1218 | + } catch (PDOException $e) { |
|
1219 | 1219 | return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n"; |
1220 | 1220 | } |
1221 | 1221 | } |
@@ -1231,7 +1231,7 @@ discard block |
||
1231 | 1231 | try { |
1232 | 1232 | $sth = $Connection->db->prepare($query); |
1233 | 1233 | $sth->execute(); |
1234 | - } catch(PDOException $e) { |
|
1234 | + } catch (PDOException $e) { |
|
1235 | 1235 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1236 | 1236 | } |
1237 | 1237 | return $error; |
@@ -1241,33 +1241,33 @@ discard block |
||
1241 | 1241 | global $globalDBdriver; |
1242 | 1242 | $Connection = new Connection(); |
1243 | 1243 | $error = ''; |
1244 | - if (!$Connection->indexExists('notam','ref_idx')) { |
|
1244 | + if (!$Connection->indexExists('notam', 'ref_idx')) { |
|
1245 | 1245 | // Add index key |
1246 | 1246 | $query = "create index ref_idx on notam (ref)"; |
1247 | 1247 | try { |
1248 | 1248 | $sth = $Connection->db->prepare($query); |
1249 | 1249 | $sth->execute(); |
1250 | - } catch(PDOException $e) { |
|
1250 | + } catch (PDOException $e) { |
|
1251 | 1251 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; |
1252 | 1252 | } |
1253 | 1253 | } |
1254 | - if (!$Connection->indexExists('accidents','registration_idx')) { |
|
1254 | + if (!$Connection->indexExists('accidents', 'registration_idx')) { |
|
1255 | 1255 | // Add index key |
1256 | 1256 | $query = "create index registration_idx on accidents (registration)"; |
1257 | 1257 | try { |
1258 | 1258 | $sth = $Connection->db->prepare($query); |
1259 | 1259 | $sth->execute(); |
1260 | - } catch(PDOException $e) { |
|
1260 | + } catch (PDOException $e) { |
|
1261 | 1261 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; |
1262 | 1262 | } |
1263 | 1263 | } |
1264 | - if (!$Connection->indexExists('accidents','rdts')) { |
|
1264 | + if (!$Connection->indexExists('accidents', 'rdts')) { |
|
1265 | 1265 | // Add index key |
1266 | 1266 | $query = "create index rdts on accidents (registration,date,type,source)"; |
1267 | 1267 | try { |
1268 | 1268 | $sth = $Connection->db->prepare($query); |
1269 | 1269 | $sth->execute(); |
1270 | - } catch(PDOException $e) { |
|
1270 | + } catch (PDOException $e) { |
|
1271 | 1271 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; |
1272 | 1272 | } |
1273 | 1273 | } |
@@ -1276,7 +1276,7 @@ discard block |
||
1276 | 1276 | try { |
1277 | 1277 | $sth = $Connection->db->prepare($query); |
1278 | 1278 | $sth->execute(); |
1279 | - } catch(PDOException $e) { |
|
1279 | + } catch (PDOException $e) { |
|
1280 | 1280 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1281 | 1281 | } |
1282 | 1282 | return $error; |
@@ -1286,23 +1286,23 @@ discard block |
||
1286 | 1286 | global $globalDBdriver; |
1287 | 1287 | $Connection = new Connection(); |
1288 | 1288 | $error = ''; |
1289 | - if (!$Connection->checkColumnName('accidents','airline_name')) { |
|
1289 | + if (!$Connection->checkColumnName('accidents', 'airline_name')) { |
|
1290 | 1290 | // Add airline_name to accidents |
1291 | 1291 | $query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL"; |
1292 | 1292 | try { |
1293 | 1293 | $sth = $Connection->db->prepare($query); |
1294 | 1294 | $sth->execute(); |
1295 | - } catch(PDOException $e) { |
|
1295 | + } catch (PDOException $e) { |
|
1296 | 1296 | return "error (add airline_name column in accidents) : ".$e->getMessage()."\n"; |
1297 | 1297 | } |
1298 | 1298 | } |
1299 | - if (!$Connection->checkColumnName('accidents','airline_icao')) { |
|
1299 | + if (!$Connection->checkColumnName('accidents', 'airline_icao')) { |
|
1300 | 1300 | // Add airline_icao to accidents |
1301 | 1301 | $query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL"; |
1302 | 1302 | try { |
1303 | 1303 | $sth = $Connection->db->prepare($query); |
1304 | 1304 | $sth->execute(); |
1305 | - } catch(PDOException $e) { |
|
1305 | + } catch (PDOException $e) { |
|
1306 | 1306 | return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n"; |
1307 | 1307 | } |
1308 | 1308 | } |
@@ -1310,7 +1310,7 @@ discard block |
||
1310 | 1310 | try { |
1311 | 1311 | $sth = $Connection->db->prepare($query); |
1312 | 1312 | $sth->execute(); |
1313 | - } catch(PDOException $e) { |
|
1313 | + } catch (PDOException $e) { |
|
1314 | 1314 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1315 | 1315 | } |
1316 | 1316 | return $error; |
@@ -1320,13 +1320,13 @@ discard block |
||
1320 | 1320 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1321 | 1321 | $Connection = new Connection(); |
1322 | 1322 | $error = ''; |
1323 | - if (!$Connection->checkColumnName('airlines','alliance')) { |
|
1323 | + if (!$Connection->checkColumnName('airlines', 'alliance')) { |
|
1324 | 1324 | // Add alliance to airlines |
1325 | 1325 | $query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL"; |
1326 | 1326 | try { |
1327 | 1327 | $sth = $Connection->db->prepare($query); |
1328 | 1328 | $sth->execute(); |
1329 | - } catch(PDOException $e) { |
|
1329 | + } catch (PDOException $e) { |
|
1330 | 1330 | return "error (add alliance column in airlines) : ".$e->getMessage()."\n"; |
1331 | 1331 | } |
1332 | 1332 | } |
@@ -1353,7 +1353,7 @@ discard block |
||
1353 | 1353 | try { |
1354 | 1354 | $sth = $Connection->db->prepare($query); |
1355 | 1355 | $sth->execute(); |
1356 | - } catch(PDOException $e) { |
|
1356 | + } catch (PDOException $e) { |
|
1357 | 1357 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1358 | 1358 | } |
1359 | 1359 | return $error; |
@@ -1363,13 +1363,13 @@ discard block |
||
1363 | 1363 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1364 | 1364 | $Connection = new Connection(); |
1365 | 1365 | $error = ''; |
1366 | - if (!$Connection->checkColumnName('airlines','ban_eu')) { |
|
1366 | + if (!$Connection->checkColumnName('airlines', 'ban_eu')) { |
|
1367 | 1367 | // Add ban_eu to airlines |
1368 | 1368 | $query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'"; |
1369 | 1369 | try { |
1370 | 1370 | $sth = $Connection->db->prepare($query); |
1371 | 1371 | $sth->execute(); |
1372 | - } catch(PDOException $e) { |
|
1372 | + } catch (PDOException $e) { |
|
1373 | 1373 | return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n"; |
1374 | 1374 | } |
1375 | 1375 | } |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | try { |
1378 | 1378 | $sth = $Connection->db->prepare($query); |
1379 | 1379 | $sth->execute(); |
1380 | - } catch(PDOException $e) { |
|
1380 | + } catch (PDOException $e) { |
|
1381 | 1381 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1382 | 1382 | } |
1383 | 1383 | return $error; |
@@ -1388,19 +1388,19 @@ discard block |
||
1388 | 1388 | $Connection = new Connection(); |
1389 | 1389 | $error = ''; |
1390 | 1390 | if ($globalDBdriver == 'mysql') { |
1391 | - if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') { |
|
1391 | + if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') { |
|
1392 | 1392 | $query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL"; |
1393 | 1393 | try { |
1394 | 1394 | $sth = $Connection->db->prepare($query); |
1395 | 1395 | $sth->execute(); |
1396 | - } catch(PDOException $e) { |
|
1396 | + } catch (PDOException $e) { |
|
1397 | 1397 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; |
1398 | 1398 | } |
1399 | 1399 | $query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()"; |
1400 | 1400 | try { |
1401 | 1401 | $sth = $Connection->db->prepare($query); |
1402 | 1402 | $sth->execute(); |
1403 | - } catch(PDOException $e) { |
|
1403 | + } catch (PDOException $e) { |
|
1404 | 1404 | return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n"; |
1405 | 1405 | } |
1406 | 1406 | |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | try { |
1409 | 1409 | $sth = $Connection->db->prepare($query); |
1410 | 1410 | $sth->execute(); |
1411 | - } catch(PDOException $e) { |
|
1411 | + } catch (PDOException $e) { |
|
1412 | 1412 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; |
1413 | 1413 | } |
1414 | 1414 | /*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150"; |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | try { |
1460 | 1460 | $sth = $Connection->db->prepare($query); |
1461 | 1461 | $sth->execute(); |
1462 | - } catch(PDOException $e) { |
|
1462 | + } catch (PDOException $e) { |
|
1463 | 1463 | return "error (fix date) : ".$e->getMessage()."\n"; |
1464 | 1464 | } |
1465 | 1465 | } |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | try { |
1545 | 1545 | $sth = $Connection->db->prepare($query); |
1546 | 1546 | $sth->execute(); |
1547 | - } catch(PDOException $e) { |
|
1547 | + } catch (PDOException $e) { |
|
1548 | 1548 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1549 | 1549 | } |
1550 | 1550 | return $error; |
@@ -1553,13 +1553,13 @@ discard block |
||
1553 | 1553 | global $globalDBdriver; |
1554 | 1554 | $Connection = new Connection(); |
1555 | 1555 | $error = ''; |
1556 | - if (!$Connection->indexExists('accidents','type')) { |
|
1556 | + if (!$Connection->indexExists('accidents', 'type')) { |
|
1557 | 1557 | // Add index key |
1558 | 1558 | $query = "create index type on accidents (type,date)"; |
1559 | 1559 | try { |
1560 | 1560 | $sth = $Connection->db->prepare($query); |
1561 | 1561 | $sth->execute(); |
1562 | - } catch(PDOException $e) { |
|
1562 | + } catch (PDOException $e) { |
|
1563 | 1563 | return "error (add index type on accidents) : ".$e->getMessage()."\n"; |
1564 | 1564 | } |
1565 | 1565 | } |
@@ -1567,7 +1567,7 @@ discard block |
||
1567 | 1567 | try { |
1568 | 1568 | $sth = $Connection->db->prepare($query); |
1569 | 1569 | $sth->execute(); |
1570 | - } catch(PDOException $e) { |
|
1570 | + } catch (PDOException $e) { |
|
1571 | 1571 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1572 | 1572 | } |
1573 | 1573 | return $error; |
@@ -1577,12 +1577,12 @@ discard block |
||
1577 | 1577 | global $globalDBdriver; |
1578 | 1578 | $Connection = new Connection(); |
1579 | 1579 | $error = ''; |
1580 | - if (!$Connection->checkColumnName('aircraft_modes','source_type')) { |
|
1580 | + if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) { |
|
1581 | 1581 | $query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'"; |
1582 | 1582 | try { |
1583 | 1583 | $sth = $Connection->db->prepare($query); |
1584 | 1584 | $sth->execute(); |
1585 | - } catch(PDOException $e) { |
|
1585 | + } catch (PDOException $e) { |
|
1586 | 1586 | return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n"; |
1587 | 1587 | } |
1588 | 1588 | } |
@@ -1648,7 +1648,7 @@ discard block |
||
1648 | 1648 | try { |
1649 | 1649 | $sth = $Connection->db->prepare($query); |
1650 | 1650 | $sth->execute(); |
1651 | - } catch(PDOException $e) { |
|
1651 | + } catch (PDOException $e) { |
|
1652 | 1652 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1653 | 1653 | } |
1654 | 1654 | return $error; |
@@ -1700,7 +1700,7 @@ discard block |
||
1700 | 1700 | try { |
1701 | 1701 | $sth = $Connection->db->prepare($query); |
1702 | 1702 | $sth->execute(); |
1703 | - } catch(PDOException $e) { |
|
1703 | + } catch (PDOException $e) { |
|
1704 | 1704 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
1705 | 1705 | } |
1706 | 1706 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1709,18 +1709,18 @@ discard block |
||
1709 | 1709 | try { |
1710 | 1710 | $sth = $Connection->db->prepare($query); |
1711 | 1711 | $sth->execute(); |
1712 | - } catch(PDOException $e) { |
|
1712 | + } catch (PDOException $e) { |
|
1713 | 1713 | return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n"; |
1714 | 1714 | } |
1715 | 1715 | } |
1716 | 1716 | } |
1717 | - if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) { |
|
1717 | + if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) { |
|
1718 | 1718 | // Add index key |
1719 | 1719 | $query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)"; |
1720 | 1720 | try { |
1721 | 1721 | $sth = $Connection->db->prepare($query); |
1722 | 1722 | $sth->execute(); |
1723 | - } catch(PDOException $e) { |
|
1723 | + } catch (PDOException $e) { |
|
1724 | 1724 | return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n"; |
1725 | 1725 | } |
1726 | 1726 | } |
@@ -1728,7 +1728,7 @@ discard block |
||
1728 | 1728 | try { |
1729 | 1729 | $sth = $Connection->db->prepare($query); |
1730 | 1730 | $sth->execute(); |
1731 | - } catch(PDOException $e) { |
|
1731 | + } catch (PDOException $e) { |
|
1732 | 1732 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1733 | 1733 | } |
1734 | 1734 | return $error; |
@@ -1739,148 +1739,148 @@ discard block |
||
1739 | 1739 | $Connection = new Connection(); |
1740 | 1740 | $error = ''; |
1741 | 1741 | if ($globalDBdriver == 'mysql') { |
1742 | - if (!$Connection->checkColumnName('marine_output','type_id')) { |
|
1742 | + if (!$Connection->checkColumnName('marine_output', 'type_id')) { |
|
1743 | 1743 | $query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL"; |
1744 | 1744 | try { |
1745 | 1745 | $sth = $Connection->db->prepare($query); |
1746 | 1746 | $sth->execute(); |
1747 | - } catch(PDOException $e) { |
|
1747 | + } catch (PDOException $e) { |
|
1748 | 1748 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; |
1749 | 1749 | } |
1750 | 1750 | } |
1751 | - if (!$Connection->checkColumnName('marine_live','type_id')) { |
|
1751 | + if (!$Connection->checkColumnName('marine_live', 'type_id')) { |
|
1752 | 1752 | $query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL"; |
1753 | 1753 | try { |
1754 | 1754 | $sth = $Connection->db->prepare($query); |
1755 | 1755 | $sth->execute(); |
1756 | - } catch(PDOException $e) { |
|
1756 | + } catch (PDOException $e) { |
|
1757 | 1757 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; |
1758 | 1758 | } |
1759 | 1759 | } |
1760 | - if (!$Connection->checkColumnName('marine_archive','type_id')) { |
|
1760 | + if (!$Connection->checkColumnName('marine_archive', 'type_id')) { |
|
1761 | 1761 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL"; |
1762 | 1762 | try { |
1763 | 1763 | $sth = $Connection->db->prepare($query); |
1764 | 1764 | $sth->execute(); |
1765 | - } catch(PDOException $e) { |
|
1765 | + } catch (PDOException $e) { |
|
1766 | 1766 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; |
1767 | 1767 | } |
1768 | 1768 | } |
1769 | - if (!$Connection->checkColumnName('marine_archive_output','type_id')) { |
|
1769 | + if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { |
|
1770 | 1770 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL"; |
1771 | 1771 | try { |
1772 | 1772 | $sth = $Connection->db->prepare($query); |
1773 | 1773 | $sth->execute(); |
1774 | - } catch(PDOException $e) { |
|
1774 | + } catch (PDOException $e) { |
|
1775 | 1775 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1776 | 1776 | } |
1777 | 1777 | } |
1778 | - if (!$Connection->checkColumnName('marine_output','status_id')) { |
|
1778 | + if (!$Connection->checkColumnName('marine_output', 'status_id')) { |
|
1779 | 1779 | $query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL"; |
1780 | 1780 | try { |
1781 | 1781 | $sth = $Connection->db->prepare($query); |
1782 | 1782 | $sth->execute(); |
1783 | - } catch(PDOException $e) { |
|
1783 | + } catch (PDOException $e) { |
|
1784 | 1784 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; |
1785 | 1785 | } |
1786 | 1786 | } |
1787 | - if (!$Connection->checkColumnName('marine_live','status_id')) { |
|
1787 | + if (!$Connection->checkColumnName('marine_live', 'status_id')) { |
|
1788 | 1788 | $query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL"; |
1789 | 1789 | try { |
1790 | 1790 | $sth = $Connection->db->prepare($query); |
1791 | 1791 | $sth->execute(); |
1792 | - } catch(PDOException $e) { |
|
1792 | + } catch (PDOException $e) { |
|
1793 | 1793 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; |
1794 | 1794 | } |
1795 | 1795 | } |
1796 | - if (!$Connection->checkColumnName('marine_archive','status_id')) { |
|
1796 | + if (!$Connection->checkColumnName('marine_archive', 'status_id')) { |
|
1797 | 1797 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL"; |
1798 | 1798 | try { |
1799 | 1799 | $sth = $Connection->db->prepare($query); |
1800 | 1800 | $sth->execute(); |
1801 | - } catch(PDOException $e) { |
|
1801 | + } catch (PDOException $e) { |
|
1802 | 1802 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; |
1803 | 1803 | } |
1804 | 1804 | } |
1805 | - if (!$Connection->checkColumnName('marine_archive_output','status_id')) { |
|
1805 | + if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { |
|
1806 | 1806 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL"; |
1807 | 1807 | try { |
1808 | 1808 | $sth = $Connection->db->prepare($query); |
1809 | 1809 | $sth->execute(); |
1810 | - } catch(PDOException $e) { |
|
1810 | + } catch (PDOException $e) { |
|
1811 | 1811 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1812 | 1812 | } |
1813 | 1813 | } |
1814 | 1814 | } else { |
1815 | - if (!$Connection->checkColumnName('marine_output','type_id')) { |
|
1815 | + if (!$Connection->checkColumnName('marine_output', 'type_id')) { |
|
1816 | 1816 | $query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL"; |
1817 | 1817 | try { |
1818 | 1818 | $sth = $Connection->db->prepare($query); |
1819 | 1819 | $sth->execute(); |
1820 | - } catch(PDOException $e) { |
|
1820 | + } catch (PDOException $e) { |
|
1821 | 1821 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; |
1822 | 1822 | } |
1823 | 1823 | } |
1824 | - if (!$Connection->checkColumnName('marine_live','type_id')) { |
|
1824 | + if (!$Connection->checkColumnName('marine_live', 'type_id')) { |
|
1825 | 1825 | $query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL"; |
1826 | 1826 | try { |
1827 | 1827 | $sth = $Connection->db->prepare($query); |
1828 | 1828 | $sth->execute(); |
1829 | - } catch(PDOException $e) { |
|
1829 | + } catch (PDOException $e) { |
|
1830 | 1830 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; |
1831 | 1831 | } |
1832 | 1832 | } |
1833 | - if (!$Connection->checkColumnName('marine_archive','type_id')) { |
|
1833 | + if (!$Connection->checkColumnName('marine_archive', 'type_id')) { |
|
1834 | 1834 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL"; |
1835 | 1835 | try { |
1836 | 1836 | $sth = $Connection->db->prepare($query); |
1837 | 1837 | $sth->execute(); |
1838 | - } catch(PDOException $e) { |
|
1838 | + } catch (PDOException $e) { |
|
1839 | 1839 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; |
1840 | 1840 | } |
1841 | 1841 | } |
1842 | - if (!$Connection->checkColumnName('marine_archive_output','type_id')) { |
|
1842 | + if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { |
|
1843 | 1843 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL"; |
1844 | 1844 | try { |
1845 | 1845 | $sth = $Connection->db->prepare($query); |
1846 | 1846 | $sth->execute(); |
1847 | - } catch(PDOException $e) { |
|
1847 | + } catch (PDOException $e) { |
|
1848 | 1848 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1849 | 1849 | } |
1850 | 1850 | } |
1851 | - if (!$Connection->checkColumnName('marine_output','status_id')) { |
|
1851 | + if (!$Connection->checkColumnName('marine_output', 'status_id')) { |
|
1852 | 1852 | $query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL"; |
1853 | 1853 | try { |
1854 | 1854 | $sth = $Connection->db->prepare($query); |
1855 | 1855 | $sth->execute(); |
1856 | - } catch(PDOException $e) { |
|
1856 | + } catch (PDOException $e) { |
|
1857 | 1857 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; |
1858 | 1858 | } |
1859 | 1859 | } |
1860 | - if (!$Connection->checkColumnName('marine_live','status_id')) { |
|
1860 | + if (!$Connection->checkColumnName('marine_live', 'status_id')) { |
|
1861 | 1861 | $query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL"; |
1862 | 1862 | try { |
1863 | 1863 | $sth = $Connection->db->prepare($query); |
1864 | 1864 | $sth->execute(); |
1865 | - } catch(PDOException $e) { |
|
1865 | + } catch (PDOException $e) { |
|
1866 | 1866 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; |
1867 | 1867 | } |
1868 | 1868 | } |
1869 | - if (!$Connection->checkColumnName('marine_archive','status_id')) { |
|
1869 | + if (!$Connection->checkColumnName('marine_archive', 'status_id')) { |
|
1870 | 1870 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL"; |
1871 | 1871 | try { |
1872 | 1872 | $sth = $Connection->db->prepare($query); |
1873 | 1873 | $sth->execute(); |
1874 | - } catch(PDOException $e) { |
|
1874 | + } catch (PDOException $e) { |
|
1875 | 1875 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; |
1876 | 1876 | } |
1877 | 1877 | } |
1878 | - if (!$Connection->checkColumnName('marine_archive_output','status_id')) { |
|
1878 | + if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { |
|
1879 | 1879 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL"; |
1880 | 1880 | try { |
1881 | 1881 | $sth = $Connection->db->prepare($query); |
1882 | 1882 | $sth->execute(); |
1883 | - } catch(PDOException $e) { |
|
1883 | + } catch (PDOException $e) { |
|
1884 | 1884 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1885 | 1885 | } |
1886 | 1886 | } |
@@ -1889,7 +1889,7 @@ discard block |
||
1889 | 1889 | try { |
1890 | 1890 | $sth = $Connection->db->prepare($query); |
1891 | 1891 | $sth->execute(); |
1892 | - } catch(PDOException $e) { |
|
1892 | + } catch (PDOException $e) { |
|
1893 | 1893 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1894 | 1894 | } |
1895 | 1895 | return $error; |
@@ -1904,14 +1904,14 @@ discard block |
||
1904 | 1904 | try { |
1905 | 1905 | $sth = $Connection->db->prepare($query); |
1906 | 1906 | $sth->execute(); |
1907 | - } catch(PDOException $e) { |
|
1907 | + } catch (PDOException $e) { |
|
1908 | 1908 | return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n"; |
1909 | 1909 | } |
1910 | 1910 | $query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL"; |
1911 | 1911 | try { |
1912 | 1912 | $sth = $Connection->db->prepare($query); |
1913 | 1913 | $sth->execute(); |
1914 | - } catch(PDOException $e) { |
|
1914 | + } catch (PDOException $e) { |
|
1915 | 1915 | return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n"; |
1916 | 1916 | } |
1917 | 1917 | } else { |
@@ -1919,14 +1919,14 @@ discard block |
||
1919 | 1919 | try { |
1920 | 1920 | $sth = $Connection->db->prepare($query); |
1921 | 1921 | $sth->execute(); |
1922 | - } catch(PDOException $e) { |
|
1922 | + } catch (PDOException $e) { |
|
1923 | 1923 | return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n"; |
1924 | 1924 | } |
1925 | 1925 | $query = "alter table marine_identity alter column mmsi type varchar(255)"; |
1926 | 1926 | try { |
1927 | 1927 | $sth = $Connection->db->prepare($query); |
1928 | 1928 | $sth->execute(); |
1929 | - } catch(PDOException $e) { |
|
1929 | + } catch (PDOException $e) { |
|
1930 | 1930 | return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n"; |
1931 | 1931 | } |
1932 | 1932 | } |
@@ -1934,7 +1934,7 @@ discard block |
||
1934 | 1934 | try { |
1935 | 1935 | $sth = $Connection->db->prepare($query); |
1936 | 1936 | $sth->execute(); |
1937 | - } catch(PDOException $e) { |
|
1937 | + } catch (PDOException $e) { |
|
1938 | 1938 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1939 | 1939 | } |
1940 | 1940 | return $error; |
@@ -1944,32 +1944,32 @@ discard block |
||
1944 | 1944 | global $globalDBdriver; |
1945 | 1945 | $Connection = new Connection(); |
1946 | 1946 | $error = ''; |
1947 | - if (!$Connection->checkColumnName('source_location','last_seen')) { |
|
1947 | + if (!$Connection->checkColumnName('source_location', 'last_seen')) { |
|
1948 | 1948 | $query = "ALTER TABLE source_location ADD COLUMN last_seen timestamp NULL DEFAULT NULL"; |
1949 | 1949 | try { |
1950 | 1950 | $sth = $Connection->db->prepare($query); |
1951 | 1951 | $sth->execute(); |
1952 | - } catch(PDOException $e) { |
|
1952 | + } catch (PDOException $e) { |
|
1953 | 1953 | return "error (add column last_seen in source_location) : ".$e->getMessage()."\n"; |
1954 | 1954 | } |
1955 | 1955 | } |
1956 | 1956 | if ($globalDBdriver == 'mysql') { |
1957 | - if (!$Connection->checkColumnName('source_location','location_id')) { |
|
1957 | + if (!$Connection->checkColumnName('source_location', 'location_id')) { |
|
1958 | 1958 | $query = "ALTER TABLE source_location ADD COLUMN location_id int(11) DEFAULT NULL"; |
1959 | 1959 | try { |
1960 | 1960 | $sth = $Connection->db->prepare($query); |
1961 | 1961 | $sth->execute(); |
1962 | - } catch(PDOException $e) { |
|
1962 | + } catch (PDOException $e) { |
|
1963 | 1963 | return "error (add column location_id in source_location) : ".$e->getMessage()."\n"; |
1964 | 1964 | } |
1965 | 1965 | } |
1966 | 1966 | } else { |
1967 | - if (!$Connection->checkColumnName('source_location','location_id')) { |
|
1967 | + if (!$Connection->checkColumnName('source_location', 'location_id')) { |
|
1968 | 1968 | $query = "ALTER TABLE source_location ADD COLUMN location_id integer DEFAULT NULL"; |
1969 | 1969 | try { |
1970 | 1970 | $sth = $Connection->db->prepare($query); |
1971 | 1971 | $sth->execute(); |
1972 | - } catch(PDOException $e) { |
|
1972 | + } catch (PDOException $e) { |
|
1973 | 1973 | return "error (add column location_id in source_location) : ".$e->getMessage()."\n"; |
1974 | 1974 | } |
1975 | 1975 | } |
@@ -1978,7 +1978,7 @@ discard block |
||
1978 | 1978 | try { |
1979 | 1979 | $sth = $Connection->db->prepare($query); |
1980 | 1980 | $sth->execute(); |
1981 | - } catch(PDOException $e) { |
|
1981 | + } catch (PDOException $e) { |
|
1982 | 1982 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1983 | 1983 | } |
1984 | 1984 | return $error; |
@@ -1988,12 +1988,12 @@ discard block |
||
1988 | 1988 | global $globalDBdriver; |
1989 | 1989 | $Connection = new Connection(); |
1990 | 1990 | $error = ''; |
1991 | - if (!$Connection->checkColumnName('source_location','description')) { |
|
1991 | + if (!$Connection->checkColumnName('source_location', 'description')) { |
|
1992 | 1992 | $query = "ALTER TABLE source_location ADD COLUMN description text DEFAULT NULL"; |
1993 | 1993 | try { |
1994 | 1994 | $sth = $Connection->db->prepare($query); |
1995 | 1995 | $sth->execute(); |
1996 | - } catch(PDOException $e) { |
|
1996 | + } catch (PDOException $e) { |
|
1997 | 1997 | return "error (add column description in source_location) : ".$e->getMessage()."\n"; |
1998 | 1998 | } |
1999 | 1999 | } |
@@ -2001,7 +2001,7 @@ discard block |
||
2001 | 2001 | try { |
2002 | 2002 | $sth = $Connection->db->prepare($query); |
2003 | 2003 | $sth->execute(); |
2004 | - } catch(PDOException $e) { |
|
2004 | + } catch (PDOException $e) { |
|
2005 | 2005 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2006 | 2006 | } |
2007 | 2007 | return $error; |
@@ -2011,39 +2011,39 @@ discard block |
||
2011 | 2011 | global $globalDBdriver; |
2012 | 2012 | $Connection = new Connection(); |
2013 | 2013 | $error = ''; |
2014 | - if (!$Connection->checkColumnName('spotter_live','real_altitude')) { |
|
2014 | + if (!$Connection->checkColumnName('spotter_live', 'real_altitude')) { |
|
2015 | 2015 | $query = "ALTER TABLE spotter_live ADD COLUMN real_altitude float DEFAULT NULL"; |
2016 | 2016 | try { |
2017 | 2017 | $sth = $Connection->db->prepare($query); |
2018 | 2018 | $sth->execute(); |
2019 | - } catch(PDOException $e) { |
|
2019 | + } catch (PDOException $e) { |
|
2020 | 2020 | return "error (add column real_altitude in spotter_live) : ".$e->getMessage()."\n"; |
2021 | 2021 | } |
2022 | 2022 | } |
2023 | - if (!$Connection->checkColumnName('spotter_output','real_altitude')) { |
|
2023 | + if (!$Connection->checkColumnName('spotter_output', 'real_altitude')) { |
|
2024 | 2024 | $query = "ALTER TABLE spotter_output ADD COLUMN real_altitude float DEFAULT NULL"; |
2025 | 2025 | try { |
2026 | 2026 | $sth = $Connection->db->prepare($query); |
2027 | 2027 | $sth->execute(); |
2028 | - } catch(PDOException $e) { |
|
2028 | + } catch (PDOException $e) { |
|
2029 | 2029 | return "error (add column real_altitude in spotter_output) : ".$e->getMessage()."\n"; |
2030 | 2030 | } |
2031 | 2031 | } |
2032 | - if (!$Connection->checkColumnName('spotter_archive_output','real_altitude')) { |
|
2032 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_altitude')) { |
|
2033 | 2033 | $query = "ALTER TABLE spotter_archive_output ADD COLUMN real_altitude float DEFAULT NULL"; |
2034 | 2034 | try { |
2035 | 2035 | $sth = $Connection->db->prepare($query); |
2036 | 2036 | $sth->execute(); |
2037 | - } catch(PDOException $e) { |
|
2037 | + } catch (PDOException $e) { |
|
2038 | 2038 | return "error (add column real_altitude in spotter_archive_output) : ".$e->getMessage()."\n"; |
2039 | 2039 | } |
2040 | 2040 | } |
2041 | - if (!$Connection->checkColumnName('spotter_archive','real_altitude')) { |
|
2041 | + if (!$Connection->checkColumnName('spotter_archive', 'real_altitude')) { |
|
2042 | 2042 | $query = "ALTER TABLE spotter_archive ADD COLUMN real_altitude float DEFAULT NULL"; |
2043 | 2043 | try { |
2044 | 2044 | $sth = $Connection->db->prepare($query); |
2045 | 2045 | $sth->execute(); |
2046 | - } catch(PDOException $e) { |
|
2046 | + } catch (PDOException $e) { |
|
2047 | 2047 | return "error (add column real_altitude in spotter_archive) : ".$e->getMessage()."\n"; |
2048 | 2048 | } |
2049 | 2049 | } |
@@ -2051,7 +2051,7 @@ discard block |
||
2051 | 2051 | try { |
2052 | 2052 | $sth = $Connection->db->prepare($query); |
2053 | 2053 | $sth->execute(); |
2054 | - } catch(PDOException $e) { |
|
2054 | + } catch (PDOException $e) { |
|
2055 | 2055 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2056 | 2056 | } |
2057 | 2057 | return $error; |
@@ -2073,14 +2073,14 @@ discard block |
||
2073 | 2073 | try { |
2074 | 2074 | $sth = $Connection->db->prepare($query); |
2075 | 2075 | $sth->execute(); |
2076 | - } catch(PDOException $e) { |
|
2076 | + } catch (PDOException $e) { |
|
2077 | 2077 | return "error (modify column altitude in tracker_*) : ".$e->getMessage()."\n"; |
2078 | 2078 | } |
2079 | 2079 | $query = "UPDATE config SET value = '44' WHERE name = 'schema_version'"; |
2080 | 2080 | try { |
2081 | 2081 | $sth = $Connection->db->prepare($query); |
2082 | 2082 | $sth->execute(); |
2083 | - } catch(PDOException $e) { |
|
2083 | + } catch (PDOException $e) { |
|
2084 | 2084 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2085 | 2085 | } |
2086 | 2086 | return $error; |
@@ -2121,7 +2121,7 @@ discard block |
||
2121 | 2121 | try { |
2122 | 2122 | $sth = $Connection->db->prepare($query); |
2123 | 2123 | $sth->execute(); |
2124 | - } catch(PDOException $e) { |
|
2124 | + } catch (PDOException $e) { |
|
2125 | 2125 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2126 | 2126 | } |
2127 | 2127 | return $error; |
@@ -2144,7 +2144,7 @@ discard block |
||
2144 | 2144 | try { |
2145 | 2145 | $sth = $Connection->db->prepare($query); |
2146 | 2146 | $sth->execute(); |
2147 | - } catch(PDOException $e) { |
|
2147 | + } catch (PDOException $e) { |
|
2148 | 2148 | return "error : ".$e->getMessage()."\n"; |
2149 | 2149 | } |
2150 | 2150 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | |
4 | -class Connection{ |
|
4 | +class Connection { |
|
5 | 5 | public $db = null; |
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 45; |
8 | 8 | |
9 | - public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
|
9 | + public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { |
|
10 | 10 | global $globalDBdriver, $globalNoDB; |
11 | 11 | if (isset($globalNoDB) && $globalNoDB === TRUE) { |
12 | 12 | $this->db = null; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | if ($user === null && $pass === null) { |
17 | 17 | $this->createDBConnection(); |
18 | 18 | } else { |
19 | - $this->createDBConnection(null,$user,$pass); |
|
19 | + $this->createDBConnection(null, $user, $pass); |
|
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $this->createDBConnection($dbname); |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | while (true) { |
101 | 101 | try { |
102 | 102 | if ($globalDBSdriver == 'mysql') { |
103 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
103 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
104 | 104 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
105 | 105 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
106 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
107 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
108 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
109 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
110 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
106 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
107 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); |
|
108 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
109 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
110 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
111 | 111 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
112 | 112 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
113 | 113 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -117,19 +117,19 @@ discard block |
||
117 | 117 | $this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); |
118 | 118 | //$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); |
119 | 119 | } else { |
120 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
120 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
121 | 121 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
122 | 122 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
123 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
124 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
125 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
126 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
127 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
123 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
124 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
125 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
126 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
127 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
128 | 128 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
129 | 129 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
130 | 130 | } |
131 | 131 | break; |
132 | - } catch(PDOException $e) { |
|
132 | + } catch (PDOException $e) { |
|
133 | 133 | $i++; |
134 | 134 | if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
135 | 135 | //exit; |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | try { |
154 | 154 | //$Connection = new Connection(); |
155 | 155 | $results = $this->db->query($query); |
156 | - } catch(PDOException $e) { |
|
156 | + } catch (PDOException $e) { |
|
157 | 157 | return false; |
158 | 158 | } |
159 | - if($results->rowCount()>0) { |
|
159 | + if ($results->rowCount() > 0) { |
|
160 | 160 | return true; |
161 | 161 | } |
162 | 162 | else return false; |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | return false; |
178 | 178 | } |
179 | 179 | |
180 | - } catch(PDOException $e) { |
|
181 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
180 | + } catch (PDOException $e) { |
|
181 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
182 | 182 | throw $e; |
183 | 183 | } |
184 | 184 | //echo 'error ! '.$e->getMessage(); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | /* |
191 | 191 | * Check if index exist |
192 | 192 | */ |
193 | - public function indexExists($table,$index) |
|
193 | + public function indexExists($table, $index) |
|
194 | 194 | { |
195 | 195 | global $globalDBdriver, $globalDBname; |
196 | 196 | if ($globalDBdriver == 'mysql') { |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | try { |
202 | 202 | //$Connection = new Connection(); |
203 | 203 | $results = $this->db->query($query); |
204 | - } catch(PDOException $e) { |
|
204 | + } catch (PDOException $e) { |
|
205 | 205 | return false; |
206 | 206 | } |
207 | 207 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
208 | - if($nb[0]['nb'] > 0) { |
|
208 | + if ($nb[0]['nb'] > 0) { |
|
209 | 209 | return true; |
210 | 210 | } |
211 | 211 | else return false; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
221 | 221 | try { |
222 | 222 | $results = $this->db->query($query); |
223 | - } catch(PDOException $e) { |
|
223 | + } catch (PDOException $e) { |
|
224 | 224 | return "error : ".$e->getMessage()."\n"; |
225 | 225 | } |
226 | 226 | $columns = array(); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | return $columns; |
233 | 233 | } |
234 | 234 | |
235 | - public function getColumnType($table,$column) { |
|
235 | + public function getColumnType($table, $column) { |
|
236 | 236 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
237 | 237 | $tomet = $select->getColumnMeta(0); |
238 | 238 | return $tomet['native_type']; |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * Check if a column name exist in a table |
243 | 243 | * @return Boolean column exist or not |
244 | 244 | */ |
245 | - public function checkColumnName($table,$name) |
|
245 | + public function checkColumnName($table, $name) |
|
246 | 246 | { |
247 | 247 | global $globalDBdriver, $globalDBname; |
248 | 248 | if ($globalDBdriver == 'mysql') { |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | } |
253 | 253 | try { |
254 | 254 | $sth = $this->db()->prepare($query); |
255 | - $sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); |
|
256 | - } catch(PDOException $e) { |
|
255 | + $sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); |
|
256 | + } catch (PDOException $e) { |
|
257 | 257 | echo "error : ".$e->getMessage()."\n"; |
258 | 258 | } |
259 | 259 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | try { |
293 | 293 | $sth = $this->db->prepare($query); |
294 | 294 | $sth->execute(); |
295 | - } catch(PDOException $e) { |
|
295 | + } catch (PDOException $e) { |
|
296 | 296 | return "error : ".$e->getMessage()."\n"; |
297 | 297 | } |
298 | 298 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $globalLongitudeMin = '1.0'; //the minimum longitude (east) |
43 | 43 | |
44 | 44 | $globalCenterLatitude = '46.38'; //the latitude center of your coverage area |
45 | -$globalCenterLongitude = '5.29';//the longitude center of your coverage area |
|
45 | +$globalCenterLongitude = '5.29'; //the longitude center of your coverage area |
|
46 | 46 | |
47 | 47 | $globalLiveZoom = '9'; //default zoom on Live Map |
48 | 48 | $globalAirportZoom = '7'; //default zoom to begin to display airports icons |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $globalACARS = FALSE; |
152 | 152 | $globalACARSHost = '0.0.0.0'; // Local IP to listen |
153 | 153 | $globalACARSPort = '9999'; |
154 | -$globalACARSArchive = array('10','80','81','82','3F'); // labels of messages to archive |
|
154 | +$globalACARSArchive = array('10', '80', '81', '82', '3F'); // labels of messages to archive |
|
155 | 155 | $globalACARSArchiveKeepMonths = '0'; |
156 | 156 | |
157 | 157 | //APRS configuration (for glidernet) |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | //Check by aircraft ICAO if image is not found by registration |
249 | 249 | $globalAircraftImageCheckICAO = TRUE; |
250 | 250 | //Sources for Aircraft image |
251 | -$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters','customsources'); |
|
251 | +$globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters', 'customsources'); |
|
252 | 252 | // Custom source configuration {registration} will be replaced by aircraft registration (exif get copyright from exif data for each pic) |
253 | 253 | // example of config : $globalAircraftImageCustomSources = array('thumbnail' => 'http://pics.myurl.com/thumbnail/{registration}.jpg','original' => 'http://myurl/original/{registration}.jpg','source_website' => 'https://www.myurl.com', 'source' => 'customsite', 'copyright' => 'myself','exif' => true); |
254 | 254 | // ************************ |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | //Retrieve Image from externals sources |
258 | 258 | $globalMarineImageFetch = TRUE; |
259 | 259 | //Sources for Marine image |
260 | -$globalMarineImageSources = array('wikimedia','flickr','deviantart','bing','customsources'); |
|
260 | +$globalMarineImageSources = array('wikimedia', 'flickr', 'deviantart', 'bing', 'customsources'); |
|
261 | 261 | // Custom source configuration {mmsi} will be replaced by vessel mmsi, {name} by it's name (exif get copyright from exif data for each pic) |
262 | 262 | // example of config : $globalMarineImageCustomSources = array('thumbnail' => 'http://pics.myurl.com/thumbnail/{name}.jpg','original' => 'http://myurl/original/{name}.jpg','source_website' => 'https://www.myurl.com', 'source' => 'customsite', 'copyright' => 'myself','exif' => true); |
263 | 263 | // ************************ |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | //Retrieve schedules from externals sources (set to FALSE for IVAO or if $globalFork = FALSE) |
266 | 266 | $globalSchedulesFetch = TRUE; |
267 | 267 | //Sources for airline schedule if not official airline site |
268 | -$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
268 | +$globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware'); |
|
269 | 269 | |
270 | 270 | //Retrieve translation from external sources (set to FALSE for IVAO) |
271 | 271 | $globalTranslationFetch = TRUE; |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | $this->db = $Connection->db(); |
19 | 19 | } |
20 | 20 | |
21 | - public function addLastStatsUpdate($type,$stats_date) { |
|
21 | + public function addLastStatsUpdate($type, $stats_date) { |
|
22 | 22 | $query = "DELETE FROM config WHERE name = :type; |
23 | 23 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
24 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | + $query_values = array('type' => $type, ':stats_date' => $stats_date); |
|
25 | 25 | try { |
26 | 26 | $sth = $this->db->prepare($query); |
27 | 27 | $sth->execute($query_values); |
28 | - } catch(PDOException $e) { |
|
28 | + } catch (PDOException $e) { |
|
29 | 29 | return "error : ".$e->getMessage(); |
30 | 30 | } |
31 | 31 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | try { |
36 | 36 | $sth = $this->db->prepare($query); |
37 | 37 | $sth->execute(array(':type' => $type)); |
38 | - } catch(PDOException $e) { |
|
38 | + } catch (PDOException $e) { |
|
39 | 39 | echo "error : ".$e->getMessage(); |
40 | 40 | } |
41 | 41 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | try { |
56 | 56 | $sth = $this->db->prepare($query); |
57 | 57 | $sth->execute(array(':filter_name' => $filter_name)); |
58 | - } catch(PDOException $e) { |
|
58 | + } catch (PDOException $e) { |
|
59 | 59 | return "error : ".$e->getMessage(); |
60 | 60 | } |
61 | 61 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | try { |
69 | 69 | $sth = $this->db->prepare($query); |
70 | 70 | $sth->execute(); |
71 | - } catch(PDOException $e) { |
|
71 | + } catch (PDOException $e) { |
|
72 | 72 | return "error : ".$e->getMessage(); |
73 | 73 | } |
74 | 74 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | try { |
77 | 77 | $sth = $this->db->prepare($query); |
78 | 78 | $sth->execute(array(':filter_name' => $filter_name)); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error : ".$e->getMessage(); |
81 | 81 | } |
82 | 82 | } |
@@ -86,69 +86,69 @@ discard block |
||
86 | 86 | try { |
87 | 87 | $sth = $this->db->prepare($query); |
88 | 88 | $sth->execute(array(':filter_name' => $filter_name)); |
89 | - } catch(PDOException $e) { |
|
89 | + } catch (PDOException $e) { |
|
90 | 90 | echo "error : ".$e->getMessage(); |
91 | 91 | } |
92 | 92 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
93 | 93 | return $all; |
94 | 94 | } |
95 | - public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
|
95 | + public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { |
|
96 | 96 | if ($filter_name == '') $filter_name = $this->filter_name; |
97 | 97 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
98 | 98 | try { |
99 | 99 | $sth = $this->db->prepare($query); |
100 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
101 | - } catch(PDOException $e) { |
|
100 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
101 | + } catch (PDOException $e) { |
|
102 | 102 | echo "error : ".$e->getMessage(); |
103 | 103 | } |
104 | 104 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
105 | 105 | return $all; |
106 | 106 | } |
107 | - public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
|
107 | + public function getAllManufacturers($stats_airline = '', $filter_name = '') { |
|
108 | 108 | if ($filter_name == '') $filter_name = $this->filter_name; |
109 | 109 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
110 | 110 | try { |
111 | 111 | $sth = $this->db->prepare($query); |
112 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
113 | - } catch(PDOException $e) { |
|
112 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | echo "error : ".$e->getMessage(); |
115 | 115 | } |
116 | 116 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
117 | 117 | return $all; |
118 | 118 | } |
119 | - public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
119 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
120 | 120 | if ($filter_name == '') $filter_name = $this->filter_name; |
121 | 121 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
122 | 122 | try { |
123 | 123 | $sth = $this->db->prepare($query); |
124 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
125 | - } catch(PDOException $e) { |
|
124 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
125 | + } catch (PDOException $e) { |
|
126 | 126 | echo "error : ".$e->getMessage(); |
127 | 127 | } |
128 | 128 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
129 | 129 | return $all; |
130 | 130 | } |
131 | 131 | |
132 | - public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
|
132 | + public function getAllOwnerNames($stats_airline = '', $filter_name = '') { |
|
133 | 133 | if ($filter_name == '') $filter_name = $this->filter_name; |
134 | 134 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
135 | 135 | try { |
136 | 136 | $sth = $this->db->prepare($query); |
137 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
138 | - } catch(PDOException $e) { |
|
137 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
138 | + } catch (PDOException $e) { |
|
139 | 139 | echo "error : ".$e->getMessage(); |
140 | 140 | } |
141 | 141 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
142 | 142 | return $all; |
143 | 143 | } |
144 | 144 | |
145 | - public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
|
145 | + public function getAllPilotNames($stats_airline = '', $filter_name = '') { |
|
146 | 146 | if ($filter_name == '') $filter_name = $this->filter_name; |
147 | 147 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
148 | 148 | try { |
149 | 149 | $sth = $this->db->prepare($query); |
150 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
151 | - } catch(PDOException $e) { |
|
150 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
151 | + } catch (PDOException $e) { |
|
152 | 152 | echo "error : ".$e->getMessage(); |
153 | 153 | } |
154 | 154 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | |
159 | - public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
159 | + public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
160 | 160 | global $globalStatsFilters; |
161 | 161 | if ($filter_name == '') $filter_name = $this->filter_name; |
162 | 162 | if ($year == '' && $month == '') { |
@@ -164,24 +164,24 @@ discard block |
||
164 | 164 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
165 | 165 | try { |
166 | 166 | $sth = $this->db->prepare($query); |
167 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
168 | - } catch(PDOException $e) { |
|
167 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
168 | + } catch (PDOException $e) { |
|
169 | 169 | echo "error : ".$e->getMessage(); |
170 | 170 | } |
171 | 171 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
172 | 172 | } else $all = array(); |
173 | 173 | if (empty($all)) { |
174 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
174 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
175 | 175 | if ($filter_name != '') { |
176 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
176 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
177 | 177 | } |
178 | 178 | $Spotter = new Spotter($this->db); |
179 | 179 | //$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
180 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
180 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters); |
|
181 | 181 | } |
182 | 182 | return $all; |
183 | 183 | } |
184 | - public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
|
184 | + public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') { |
|
185 | 185 | global $globalStatsFilters; |
186 | 186 | if ($filter_name == '') $filter_name = $this->filter_name; |
187 | 187 | if ($year == '' && $month == '') { |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | try { |
191 | 191 | $sth = $this->db->prepare($query); |
192 | 192 | $sth->execute(array(':filter_name' => $filter_name)); |
193 | - } catch(PDOException $e) { |
|
193 | + } catch (PDOException $e) { |
|
194 | 194 | echo "error : ".$e->getMessage(); |
195 | 195 | } |
196 | 196 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -198,16 +198,16 @@ discard block |
||
198 | 198 | if (empty($all)) { |
199 | 199 | $Spotter = new Spotter($this->db); |
200 | 200 | $filters = array(); |
201 | - $filters = array('year' => $year,'month' => $month); |
|
201 | + $filters = array('year' => $year, 'month' => $month); |
|
202 | 202 | if ($filter_name != '') { |
203 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
203 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
204 | 204 | } |
205 | 205 | //$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
206 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
206 | + $all = $Spotter->countAllAirlineCountries($limit, $filters); |
|
207 | 207 | } |
208 | 208 | return $all; |
209 | 209 | } |
210 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
210 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
211 | 211 | global $globalStatsFilters; |
212 | 212 | if ($filter_name == '') $filter_name = $this->filter_name; |
213 | 213 | if ($year == '' && $month == '') { |
@@ -215,16 +215,16 @@ discard block |
||
215 | 215 | else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
216 | 216 | try { |
217 | 217 | $sth = $this->db->prepare($query); |
218 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
219 | - } catch(PDOException $e) { |
|
218 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
219 | + } catch (PDOException $e) { |
|
220 | 220 | echo "error : ".$e->getMessage(); |
221 | 221 | } |
222 | 222 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
223 | 223 | } else $all = array(); |
224 | 224 | if (empty($all)) { |
225 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
225 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
226 | 226 | if ($filter_name != '') { |
227 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
227 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
228 | 228 | } |
229 | 229 | $Spotter = new Spotter($this->db); |
230 | 230 | //$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month); |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | return $all; |
234 | 234 | } |
235 | 235 | |
236 | - public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
236 | + public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
237 | 237 | global $globalStatsFilters; |
238 | 238 | if ($filter_name == '') $filter_name = $this->filter_name; |
239 | 239 | if ($year == '' && $month == '') { |
@@ -241,20 +241,20 @@ discard block |
||
241 | 241 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC"; |
242 | 242 | try { |
243 | 243 | $sth = $this->db->prepare($query); |
244 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
245 | - } catch(PDOException $e) { |
|
244 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
245 | + } catch (PDOException $e) { |
|
246 | 246 | echo "error : ".$e->getMessage(); |
247 | 247 | } |
248 | 248 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
249 | 249 | } else $all = array(); |
250 | 250 | if (empty($all)) { |
251 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
251 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
252 | 252 | if ($filter_name != '') { |
253 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
253 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
254 | 254 | } |
255 | 255 | $Spotter = new Spotter($this->db); |
256 | 256 | //$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month); |
257 | - $all = $Spotter->countAllArrivalCountries($limit,$filters); |
|
257 | + $all = $Spotter->countAllArrivalCountries($limit, $filters); |
|
258 | 258 | } |
259 | 259 | return $all; |
260 | 260 | } |
@@ -265,15 +265,15 @@ discard block |
||
265 | 265 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC"; |
266 | 266 | try { |
267 | 267 | $sth = $this->db->prepare($query); |
268 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
269 | - } catch(PDOException $e) { |
|
268 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
269 | + } catch (PDOException $e) { |
|
270 | 270 | echo "error : ".$e->getMessage(); |
271 | 271 | } |
272 | 272 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
273 | 273 | if (empty($all)) { |
274 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
274 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
275 | 275 | if ($filter_name != '') { |
276 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
276 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
277 | 277 | } |
278 | 278 | $Spotter = new Spotter($this->db); |
279 | 279 | //$all = $Spotter->countAllDepartureCountries($filters,$year,$month); |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | return $all; |
283 | 283 | } |
284 | 284 | |
285 | - public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
|
285 | + public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') { |
|
286 | 286 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
287 | 287 | if ($filter_name == '') $filter_name = $this->filter_name; |
288 | 288 | if ($year == '' && $month == '') { |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | if (isset($forsource)) { |
292 | 292 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
293 | 293 | else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
294 | - $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
|
294 | + $query_values = array(':filter_name' => $filter_name, ':forsource' => $forsource); |
|
295 | 295 | } else { |
296 | 296 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
297 | 297 | else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | try { |
301 | 301 | $sth = $this->db->prepare($query); |
302 | 302 | $sth->execute($query_values); |
303 | - } catch(PDOException $e) { |
|
303 | + } catch (PDOException $e) { |
|
304 | 304 | echo "error : ".$e->getMessage(); |
305 | 305 | } |
306 | 306 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -308,16 +308,16 @@ discard block |
||
308 | 308 | if (empty($all)) { |
309 | 309 | $Spotter = new Spotter($this->db); |
310 | 310 | $filters = array(); |
311 | - $filters = array('year' => $year,'month' => $month); |
|
311 | + $filters = array('year' => $year, 'month' => $month); |
|
312 | 312 | if ($filter_name != '') { |
313 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
313 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
314 | 314 | } |
315 | 315 | //$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
316 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
316 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters); |
|
317 | 317 | } |
318 | 318 | return $all; |
319 | 319 | } |
320 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
320 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
321 | 321 | global $globalStatsFilters; |
322 | 322 | if ($filter_name == '') $filter_name = $this->filter_name; |
323 | 323 | if ($year == '' && $month == '') { |
@@ -325,24 +325,24 @@ discard block |
||
325 | 325 | else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
326 | 326 | try { |
327 | 327 | $sth = $this->db->prepare($query); |
328 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
329 | - } catch(PDOException $e) { |
|
328 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
329 | + } catch (PDOException $e) { |
|
330 | 330 | echo "error : ".$e->getMessage(); |
331 | 331 | } |
332 | 332 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
333 | 333 | } else $all = array(); |
334 | 334 | if (empty($all)) { |
335 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
335 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
336 | 336 | if ($filter_name != '') { |
337 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
337 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
338 | 338 | } |
339 | 339 | $Spotter = new Spotter($this->db); |
340 | 340 | //$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
341 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
341 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters); |
|
342 | 342 | } |
343 | 343 | return $all; |
344 | 344 | } |
345 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
345 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
346 | 346 | global $globalStatsFilters; |
347 | 347 | if ($filter_name == '') $filter_name = $this->filter_name; |
348 | 348 | if ($year == '' && $month == '') { |
@@ -350,24 +350,24 @@ discard block |
||
350 | 350 | else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
351 | 351 | try { |
352 | 352 | $sth = $this->db->prepare($query); |
353 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
354 | - } catch(PDOException $e) { |
|
353 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
354 | + } catch (PDOException $e) { |
|
355 | 355 | echo "error : ".$e->getMessage(); |
356 | 356 | } |
357 | 357 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
358 | 358 | } else $all = array(); |
359 | 359 | if (empty($all)) { |
360 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
360 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
361 | 361 | if ($filter_name != '') { |
362 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
362 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
363 | 363 | } |
364 | 364 | $Spotter = new Spotter($this->db); |
365 | 365 | //$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month); |
366 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters); |
|
366 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters); |
|
367 | 367 | } |
368 | 368 | return $all; |
369 | 369 | } |
370 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
370 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
371 | 371 | $Connection = new Connection(); |
372 | 372 | if ($filter_name == '') $filter_name = $this->filter_name; |
373 | 373 | if ($Connection->tableExists('countries')) { |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
377 | 377 | try { |
378 | 378 | $sth = $this->db->prepare($query); |
379 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
380 | - } catch(PDOException $e) { |
|
379 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
380 | + } catch (PDOException $e) { |
|
381 | 381 | echo "error : ".$e->getMessage(); |
382 | 382 | } |
383 | 383 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | return array(); |
394 | 394 | } |
395 | 395 | } |
396 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
|
396 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
397 | 397 | global $globalStatsFilters; |
398 | 398 | if ($filter_name == '') $filter_name = $this->filter_name; |
399 | 399 | if ($year == '' && $month == '') { |
@@ -401,25 +401,25 @@ discard block |
||
401 | 401 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
402 | 402 | try { |
403 | 403 | $sth = $this->db->prepare($query); |
404 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
405 | - } catch(PDOException $e) { |
|
404 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
405 | + } catch (PDOException $e) { |
|
406 | 406 | echo "error : ".$e->getMessage(); |
407 | 407 | } |
408 | 408 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
409 | 409 | } else $all = array(); |
410 | 410 | if (empty($all)) { |
411 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
411 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
412 | 412 | if ($filter_name != '') { |
413 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
413 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
414 | 414 | } |
415 | 415 | $Spotter = new Spotter($this->db); |
416 | 416 | //$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month); |
417 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
417 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters); |
|
418 | 418 | } |
419 | 419 | return $all; |
420 | 420 | } |
421 | 421 | |
422 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
422 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
423 | 423 | global $globalStatsFilters; |
424 | 424 | if ($filter_name == '') $filter_name = $this->filter_name; |
425 | 425 | if ($year == '' && $month == '') { |
@@ -427,24 +427,24 @@ discard block |
||
427 | 427 | else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
428 | 428 | try { |
429 | 429 | $sth = $this->db->prepare($query); |
430 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
431 | - } catch(PDOException $e) { |
|
430 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
431 | + } catch (PDOException $e) { |
|
432 | 432 | echo "error : ".$e->getMessage(); |
433 | 433 | } |
434 | 434 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
435 | 435 | } else $all = array(); |
436 | 436 | if (empty($all)) { |
437 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
437 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
438 | 438 | if ($filter_name != '') { |
439 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
439 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
440 | 440 | } |
441 | 441 | $Spotter = new Spotter($this->db); |
442 | 442 | //$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
443 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
443 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters); |
|
444 | 444 | } |
445 | 445 | return $all; |
446 | 446 | } |
447 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
447 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
448 | 448 | global $globalStatsFilters; |
449 | 449 | if ($filter_name == '') $filter_name = $this->filter_name; |
450 | 450 | if ($year == '' && $month == '') { |
@@ -452,22 +452,22 @@ discard block |
||
452 | 452 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
453 | 453 | try { |
454 | 454 | $sth = $this->db->prepare($query); |
455 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
456 | - } catch(PDOException $e) { |
|
455 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
456 | + } catch (PDOException $e) { |
|
457 | 457 | echo "error : ".$e->getMessage(); |
458 | 458 | } |
459 | 459 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
460 | 460 | } else $all = array(); |
461 | 461 | if (empty($all)) { |
462 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
462 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
463 | 463 | if ($filter_name != '') { |
464 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
464 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
465 | 465 | } |
466 | 466 | $Spotter = new Spotter($this->db); |
467 | 467 | // $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
468 | 468 | // $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
469 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
470 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
469 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters); |
|
470 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters); |
|
471 | 471 | $all = array(); |
472 | 472 | foreach ($pall as $value) { |
473 | 473 | $icao = $value['airport_departure_icao']; |
@@ -484,11 +484,11 @@ discard block |
||
484 | 484 | foreach ($all as $key => $row) { |
485 | 485 | $count[$key] = $row['airport_departure_icao_count']; |
486 | 486 | } |
487 | - array_multisort($count,SORT_DESC,$all); |
|
487 | + array_multisort($count, SORT_DESC, $all); |
|
488 | 488 | } |
489 | 489 | return $all; |
490 | 490 | } |
491 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
491 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
492 | 492 | global $globalStatsFilters; |
493 | 493 | if ($filter_name == '') $filter_name = $this->filter_name; |
494 | 494 | if ($year == '' && $month == '') { |
@@ -496,22 +496,22 @@ discard block |
||
496 | 496 | else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
497 | 497 | try { |
498 | 498 | $sth = $this->db->prepare($query); |
499 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
500 | - } catch(PDOException $e) { |
|
499 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
500 | + } catch (PDOException $e) { |
|
501 | 501 | echo "error : ".$e->getMessage(); |
502 | 502 | } |
503 | 503 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
504 | 504 | } else $all = array(); |
505 | 505 | if (empty($all)) { |
506 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
506 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
507 | 507 | if ($filter_name != '') { |
508 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
508 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
509 | 509 | } |
510 | 510 | $Spotter = new Spotter($this->db); |
511 | 511 | // $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month); |
512 | 512 | // $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month); |
513 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
|
514 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
|
513 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters); |
|
514 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters); |
|
515 | 515 | $all = array(); |
516 | 516 | foreach ($pall as $value) { |
517 | 517 | $icao = $value['airport_arrival_icao']; |
@@ -528,12 +528,12 @@ discard block |
||
528 | 528 | foreach ($all as $key => $row) { |
529 | 529 | $count[$key] = $row['airport_arrival_icao_count']; |
530 | 530 | } |
531 | - array_multisort($count,SORT_DESC,$all); |
|
531 | + array_multisort($count, SORT_DESC, $all); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | return $all; |
535 | 535 | } |
536 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
536 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
537 | 537 | global $globalDBdriver, $globalStatsFilters; |
538 | 538 | if ($filter_name == '') $filter_name = $this->filter_name; |
539 | 539 | if ($globalDBdriver == 'mysql') { |
@@ -543,18 +543,18 @@ discard block |
||
543 | 543 | if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
544 | 544 | else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
545 | 545 | } |
546 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
546 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
547 | 547 | try { |
548 | 548 | $sth = $this->db->prepare($query); |
549 | 549 | $sth->execute($query_data); |
550 | - } catch(PDOException $e) { |
|
550 | + } catch (PDOException $e) { |
|
551 | 551 | echo "error : ".$e->getMessage(); |
552 | 552 | } |
553 | 553 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
554 | 554 | if (empty($all)) { |
555 | 555 | $filters = array('airlines' => array($stats_airline)); |
556 | 556 | if ($filter_name != '') { |
557 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
557 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
558 | 558 | } |
559 | 559 | $Spotter = new Spotter($this->db); |
560 | 560 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -563,29 +563,29 @@ discard block |
||
563 | 563 | return $all; |
564 | 564 | } |
565 | 565 | |
566 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
566 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
567 | 567 | global $globalStatsFilters; |
568 | 568 | if ($filter_name == '') $filter_name = $this->filter_name; |
569 | 569 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
570 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
570 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
571 | 571 | try { |
572 | 572 | $sth = $this->db->prepare($query); |
573 | 573 | $sth->execute($query_data); |
574 | - } catch(PDOException $e) { |
|
574 | + } catch (PDOException $e) { |
|
575 | 575 | echo "error : ".$e->getMessage(); |
576 | 576 | } |
577 | 577 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
578 | 578 | if (empty($all)) { |
579 | 579 | $filters = array('airlines' => array($stats_airline)); |
580 | 580 | if ($filter_name != '') { |
581 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
581 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
582 | 582 | } |
583 | 583 | $Spotter = new Spotter($this->db); |
584 | 584 | $all = $Spotter->countAllDatesLastMonth($filters); |
585 | 585 | } |
586 | 586 | return $all; |
587 | 587 | } |
588 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
588 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
589 | 589 | global $globalDBdriver, $globalStatsFilters; |
590 | 590 | if ($filter_name == '') $filter_name = $this->filter_name; |
591 | 591 | if ($globalDBdriver == 'mysql') { |
@@ -593,40 +593,40 @@ discard block |
||
593 | 593 | } else { |
594 | 594 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
595 | 595 | } |
596 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
596 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
597 | 597 | try { |
598 | 598 | $sth = $this->db->prepare($query); |
599 | 599 | $sth->execute($query_data); |
600 | - } catch(PDOException $e) { |
|
600 | + } catch (PDOException $e) { |
|
601 | 601 | echo "error : ".$e->getMessage(); |
602 | 602 | } |
603 | 603 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
604 | 604 | if (empty($all)) { |
605 | 605 | $filters = array('airlines' => array($stats_airline)); |
606 | 606 | if ($filter_name != '') { |
607 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
607 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
608 | 608 | } |
609 | 609 | $Spotter = new Spotter($this->db); |
610 | 610 | $all = $Spotter->countAllDatesLast7Days($filters); |
611 | 611 | } |
612 | 612 | return $all; |
613 | 613 | } |
614 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
614 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
615 | 615 | global $globalStatsFilters; |
616 | 616 | if ($filter_name == '') $filter_name = $this->filter_name; |
617 | 617 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date_count DESC"; |
618 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
618 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
619 | 619 | try { |
620 | 620 | $sth = $this->db->prepare($query); |
621 | 621 | $sth->execute($query_data); |
622 | - } catch(PDOException $e) { |
|
622 | + } catch (PDOException $e) { |
|
623 | 623 | echo "error : ".$e->getMessage(); |
624 | 624 | } |
625 | 625 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
626 | 626 | if (empty($all)) { |
627 | 627 | $filters = array('airlines' => array($stats_airline)); |
628 | 628 | if ($filter_name != '') { |
629 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
629 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
630 | 630 | } |
631 | 631 | $Spotter = new Spotter($this->db); |
632 | 632 | $all = $Spotter->countAllDates($filters); |
@@ -641,21 +641,21 @@ discard block |
||
641 | 641 | try { |
642 | 642 | $sth = $this->db->prepare($query); |
643 | 643 | $sth->execute($query_data); |
644 | - } catch(PDOException $e) { |
|
644 | + } catch (PDOException $e) { |
|
645 | 645 | echo "error : ".$e->getMessage(); |
646 | 646 | } |
647 | 647 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
648 | 648 | if (empty($all)) { |
649 | 649 | $filters = array(); |
650 | 650 | if ($filter_name != '') { |
651 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
651 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
652 | 652 | } |
653 | 653 | $Spotter = new Spotter($this->db); |
654 | 654 | $all = $Spotter->countAllDatesByAirlines($filters); |
655 | 655 | } |
656 | 656 | return $all; |
657 | 657 | } |
658 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
658 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
659 | 659 | global $globalStatsFilters, $globalDBdriver; |
660 | 660 | if ($filter_name == '') $filter_name = $this->filter_name; |
661 | 661 | if ($globalDBdriver == 'mysql') { |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | try { |
667 | 667 | $sth = $this->db->prepare($query); |
668 | 668 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
669 | - } catch(PDOException $e) { |
|
669 | + } catch (PDOException $e) { |
|
670 | 670 | echo "error : ".$e->getMessage(); |
671 | 671 | } |
672 | 672 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | if (empty($all)) { |
675 | 675 | $filters = array('airlines' => array($stats_airline)); |
676 | 676 | if ($filter_name != '') { |
677 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
677 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
678 | 678 | } |
679 | 679 | $Spotter = new Spotter($this->db); |
680 | 680 | $all = $Spotter->countAllMonths($filters); |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | try { |
693 | 693 | $sth = $this->db->prepare($query); |
694 | 694 | $sth->execute(); |
695 | - } catch(PDOException $e) { |
|
695 | + } catch (PDOException $e) { |
|
696 | 696 | echo "error : ".$e->getMessage(); |
697 | 697 | } |
698 | 698 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | try { |
714 | 714 | $sth = $this->db->prepare($query); |
715 | 715 | $sth->execute(); |
716 | - } catch(PDOException $e) { |
|
716 | + } catch (PDOException $e) { |
|
717 | 717 | echo "error : ".$e->getMessage(); |
718 | 718 | } |
719 | 719 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -731,21 +731,21 @@ discard block |
||
731 | 731 | try { |
732 | 732 | $sth = $this->db->prepare($query); |
733 | 733 | $sth->execute(array(':filter_name' => $filter_name)); |
734 | - } catch(PDOException $e) { |
|
734 | + } catch (PDOException $e) { |
|
735 | 735 | echo "error : ".$e->getMessage(); |
736 | 736 | } |
737 | 737 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
738 | 738 | if (empty($all)) { |
739 | 739 | $filters = array(); |
740 | 740 | if ($filter_name != '') { |
741 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
741 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
742 | 742 | } |
743 | 743 | $Spotter = new Spotter($this->db); |
744 | 744 | $all = $Spotter->countAllMilitaryMonths($filters); |
745 | 745 | } |
746 | 746 | return $all; |
747 | 747 | } |
748 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
748 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
749 | 749 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
750 | 750 | if ($filter_name == '') $filter_name = $this->filter_name; |
751 | 751 | if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -762,30 +762,30 @@ discard block |
||
762 | 762 | try { |
763 | 763 | $sth = $this->db->prepare($query); |
764 | 764 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
765 | - } catch(PDOException $e) { |
|
765 | + } catch (PDOException $e) { |
|
766 | 766 | echo "error : ".$e->getMessage(); |
767 | 767 | } |
768 | 768 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
769 | 769 | if (empty($all)) { |
770 | 770 | $filters = array('airlines' => array($stats_airline)); |
771 | 771 | if ($filter_name != '') { |
772 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
772 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
773 | 773 | } |
774 | 774 | $Spotter = new Spotter($this->db); |
775 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
775 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
776 | 776 | } |
777 | 777 | return $all; |
778 | 778 | } |
779 | 779 | |
780 | - public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
780 | + public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
781 | 781 | global $globalStatsFilters; |
782 | 782 | if ($filter_name == '') $filter_name = $this->filter_name; |
783 | 783 | if ($year == '') $year = date('Y'); |
784 | - $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
|
784 | + $all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month); |
|
785 | 785 | if (empty($all)) { |
786 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
786 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
787 | 787 | if ($filter_name != '') { |
788 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
788 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
789 | 789 | } |
790 | 790 | $Spotter = new Spotter($this->db); |
791 | 791 | //$all = $Spotter->countOverallFlights($filters,$year,$month); |
@@ -793,16 +793,16 @@ discard block |
||
793 | 793 | } |
794 | 794 | return $all; |
795 | 795 | } |
796 | - public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
|
796 | + public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') { |
|
797 | 797 | global $globalStatsFilters; |
798 | 798 | if ($filter_name == '') $filter_name = $this->filter_name; |
799 | 799 | if ($year == '') $year = date('Y'); |
800 | - $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
|
800 | + $all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month); |
|
801 | 801 | if (empty($all)) { |
802 | 802 | $filters = array(); |
803 | - $filters = array('year' => $year,'month' => $month); |
|
803 | + $filters = array('year' => $year, 'month' => $month); |
|
804 | 804 | if ($filter_name != '') { |
805 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
805 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
806 | 806 | } |
807 | 807 | $Spotter = new Spotter($this->db); |
808 | 808 | //$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month); |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | } |
811 | 811 | return $all; |
812 | 812 | } |
813 | - public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
|
813 | + public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
814 | 814 | global $globalStatsFilters; |
815 | 815 | if ($filter_name == '') $filter_name = $this->filter_name; |
816 | 816 | if ($year == '') $year = date('Y'); |
817 | - $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
|
817 | + $all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month); |
|
818 | 818 | if (empty($all)) { |
819 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
819 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
820 | 820 | if ($filter_name != '') { |
821 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
821 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
822 | 822 | } |
823 | 823 | $Spotter = new Spotter($this->db); |
824 | 824 | //$all = $Spotter->countOverallArrival($filters,$year,$month); |
@@ -826,24 +826,24 @@ discard block |
||
826 | 826 | } |
827 | 827 | return $all; |
828 | 828 | } |
829 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
829 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
830 | 830 | global $globalStatsFilters; |
831 | 831 | if ($filter_name == '') $filter_name = $this->filter_name; |
832 | 832 | if ($year == '' && $month == '') { |
833 | 833 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
834 | 834 | try { |
835 | 835 | $sth = $this->db->prepare($query); |
836 | - $sth->execute(array(':filter_name' => $filter_name,':stats_airline' => $stats_airline)); |
|
837 | - } catch(PDOException $e) { |
|
836 | + $sth->execute(array(':filter_name' => $filter_name, ':stats_airline' => $stats_airline)); |
|
837 | + } catch (PDOException $e) { |
|
838 | 838 | echo "error : ".$e->getMessage(); |
839 | 839 | } |
840 | 840 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
841 | 841 | $all = $result[0]['nb']; |
842 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
842 | + } else $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
843 | 843 | if (empty($all)) { |
844 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
844 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
845 | 845 | if ($filter_name != '') { |
846 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
846 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
847 | 847 | } |
848 | 848 | $Spotter = new Spotter($this->db); |
849 | 849 | //$all = $Spotter->countOverallAircrafts($filters,$year,$month); |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | } |
852 | 852 | return $all; |
853 | 853 | } |
854 | - public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
|
854 | + public function countOverallAirlines($filter_name = '', $year = '', $month = '') { |
|
855 | 855 | global $globalStatsFilters; |
856 | 856 | if ($filter_name == '') $filter_name = $this->filter_name; |
857 | 857 | if ($year == '' && $month == '') { |
@@ -859,17 +859,17 @@ discard block |
||
859 | 859 | try { |
860 | 860 | $sth = $this->db->prepare($query); |
861 | 861 | $sth->execute(array(':filter_name' => $filter_name)); |
862 | - } catch(PDOException $e) { |
|
862 | + } catch (PDOException $e) { |
|
863 | 863 | echo "error : ".$e->getMessage(); |
864 | 864 | } |
865 | 865 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
866 | 866 | $all = $result[0]['nb_airline']; |
867 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
867 | + } else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month); |
|
868 | 868 | if (empty($all)) { |
869 | 869 | $filters = array(); |
870 | - $filters = array('year' => $year,'month' => $month); |
|
870 | + $filters = array('year' => $year, 'month' => $month); |
|
871 | 871 | if ($filter_name != '') { |
872 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
872 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
873 | 873 | } |
874 | 874 | $Spotter = new Spotter($this->db); |
875 | 875 | //$all = $Spotter->countOverallAirlines($filters,$year,$month); |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | } |
878 | 878 | return $all; |
879 | 879 | } |
880 | - public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
880 | + public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
881 | 881 | global $globalStatsFilters; |
882 | 882 | if ($filter_name == '') $filter_name = $this->filter_name; |
883 | 883 | if ($year == '' && $month == '') { |
@@ -886,18 +886,18 @@ discard block |
||
886 | 886 | try { |
887 | 887 | $sth = $this->db->prepare($query); |
888 | 888 | $sth->execute($query_values); |
889 | - } catch(PDOException $e) { |
|
889 | + } catch (PDOException $e) { |
|
890 | 890 | echo "error : ".$e->getMessage(); |
891 | 891 | } |
892 | 892 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
893 | 893 | $all = $result[0]['nb']; |
894 | 894 | } else { |
895 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
895 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
896 | 896 | } |
897 | 897 | if (empty($all)) { |
898 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
898 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
899 | 899 | if ($filter_name != '') { |
900 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
900 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
901 | 901 | } |
902 | 902 | $Spotter = new Spotter($this->db); |
903 | 903 | //$all = $Spotter->countOverallOwners($filters,$year,$month); |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | } |
906 | 906 | return $all; |
907 | 907 | } |
908 | - public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
908 | + public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
909 | 909 | global $globalStatsFilters; |
910 | 910 | if ($filter_name == '') $filter_name = $this->filter_name; |
911 | 911 | //if ($year == '') $year = date('Y'); |
@@ -915,18 +915,18 @@ discard block |
||
915 | 915 | try { |
916 | 916 | $sth = $this->db->prepare($query); |
917 | 917 | $sth->execute($query_values); |
918 | - } catch(PDOException $e) { |
|
918 | + } catch (PDOException $e) { |
|
919 | 919 | echo "error : ".$e->getMessage(); |
920 | 920 | } |
921 | 921 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
922 | 922 | $all = $result[0]['nb']; |
923 | 923 | } else { |
924 | - $all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month); |
|
924 | + $all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month); |
|
925 | 925 | } |
926 | 926 | if (empty($all)) { |
927 | - $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
|
927 | + $filters = array('airlines' => array($stats_airline), 'year' => $year, 'month' => $month); |
|
928 | 928 | if ($filter_name != '') { |
929 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
929 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
930 | 930 | } |
931 | 931 | $Spotter = new Spotter($this->db); |
932 | 932 | //$all = $Spotter->countOverallPilots($filters,$year,$month); |
@@ -935,67 +935,67 @@ discard block |
||
935 | 935 | return $all; |
936 | 936 | } |
937 | 937 | |
938 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
938 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
939 | 939 | if ($filter_name == '') $filter_name = $this->filter_name; |
940 | 940 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
941 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
941 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
942 | 942 | try { |
943 | 943 | $sth = $this->db->prepare($query); |
944 | 944 | $sth->execute($query_values); |
945 | - } catch(PDOException $e) { |
|
945 | + } catch (PDOException $e) { |
|
946 | 946 | echo "error : ".$e->getMessage(); |
947 | 947 | } |
948 | 948 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
949 | 949 | return $all; |
950 | 950 | } |
951 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
951 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
952 | 952 | if ($filter_name == '') $filter_name = $this->filter_name; |
953 | 953 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
954 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
954 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
955 | 955 | try { |
956 | 956 | $sth = $this->db->prepare($query); |
957 | 957 | $sth->execute($query_values); |
958 | - } catch(PDOException $e) { |
|
958 | + } catch (PDOException $e) { |
|
959 | 959 | echo "error : ".$e->getMessage(); |
960 | 960 | } |
961 | 961 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
962 | 962 | return $all; |
963 | 963 | } |
964 | - public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') { |
|
964 | + public function deleteStatsByType($type, $stats_airline = '', $filter_name = '') { |
|
965 | 965 | if ($filter_name == '') $filter_name = $this->filter_name; |
966 | 966 | $query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
967 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
967 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
968 | 968 | try { |
969 | 969 | $sth = $this->db->prepare($query); |
970 | 970 | $sth->execute($query_values); |
971 | - } catch(PDOException $e) { |
|
971 | + } catch (PDOException $e) { |
|
972 | 972 | echo "error : ".$e->getMessage(); |
973 | 973 | } |
974 | 974 | } |
975 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
|
975 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') { |
|
976 | 976 | if ($filter_name == '') $filter_name = $this->filter_name; |
977 | 977 | global $globalArchiveMonths, $globalDBdriver; |
978 | 978 | if ($globalDBdriver == 'mysql') { |
979 | 979 | if ($month == '') { |
980 | 980 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
981 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
981 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
982 | 982 | } else { |
983 | 983 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
984 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
984 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
985 | 985 | } |
986 | 986 | } else { |
987 | 987 | if ($month == '') { |
988 | 988 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
989 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
989 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
990 | 990 | } else { |
991 | 991 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
992 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
992 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
993 | 993 | } |
994 | 994 | } |
995 | 995 | try { |
996 | 996 | $sth = $this->db->prepare($query); |
997 | 997 | $sth->execute($query_values); |
998 | - } catch(PDOException $e) { |
|
998 | + } catch (PDOException $e) { |
|
999 | 999 | echo "error : ".$e->getMessage(); |
1000 | 1000 | } |
1001 | 1001 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | try { |
1014 | 1014 | $sth = $this->db->prepare($query); |
1015 | 1015 | $sth->execute($query_values); |
1016 | - } catch(PDOException $e) { |
|
1016 | + } catch (PDOException $e) { |
|
1017 | 1017 | echo "error : ".$e->getMessage(); |
1018 | 1018 | } |
1019 | 1019 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | try { |
1031 | 1031 | $sth = $this->db->prepare($query); |
1032 | 1032 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
1033 | - } catch(PDOException $e) { |
|
1033 | + } catch (PDOException $e) { |
|
1034 | 1034 | echo "error : ".$e->getMessage(); |
1035 | 1035 | } |
1036 | 1036 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | try { |
1048 | 1048 | $sth = $this->db->prepare($query); |
1049 | 1049 | $sth->execute(array(':filter_name' => $filter_name)); |
1050 | - } catch(PDOException $e) { |
|
1050 | + } catch (PDOException $e) { |
|
1051 | 1051 | echo "error : ".$e->getMessage(); |
1052 | 1052 | } |
1053 | 1053 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1064,20 +1064,20 @@ discard block |
||
1064 | 1064 | try { |
1065 | 1065 | $sth = $this->db->prepare($query); |
1066 | 1066 | $sth->execute(array(':filter_name' => $filter_name)); |
1067 | - } catch(PDOException $e) { |
|
1067 | + } catch (PDOException $e) { |
|
1068 | 1068 | echo "error : ".$e->getMessage(); |
1069 | 1069 | } |
1070 | 1070 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1071 | 1071 | return $all[0]['total']; |
1072 | 1072 | } |
1073 | - public function getStatsOwner($owner_name,$filter_name = '') { |
|
1073 | + public function getStatsOwner($owner_name, $filter_name = '') { |
|
1074 | 1074 | global $globalArchiveMonths, $globalDBdriver; |
1075 | 1075 | if ($filter_name == '') $filter_name = $this->filter_name; |
1076 | 1076 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
1077 | 1077 | try { |
1078 | 1078 | $sth = $this->db->prepare($query); |
1079 | - $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name)); |
|
1080 | - } catch(PDOException $e) { |
|
1079 | + $sth->execute(array(':filter_name' => $filter_name, ':owner_name' => $owner_name)); |
|
1080 | + } catch (PDOException $e) { |
|
1081 | 1081 | echo "error : ".$e->getMessage(); |
1082 | 1082 | } |
1083 | 1083 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1095,20 +1095,20 @@ discard block |
||
1095 | 1095 | try { |
1096 | 1096 | $sth = $this->db->prepare($query); |
1097 | 1097 | $sth->execute(array(':filter_name' => $filter_name)); |
1098 | - } catch(PDOException $e) { |
|
1098 | + } catch (PDOException $e) { |
|
1099 | 1099 | echo "error : ".$e->getMessage(); |
1100 | 1100 | } |
1101 | 1101 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1102 | 1102 | return $all[0]['total']; |
1103 | 1103 | } |
1104 | - public function getStatsPilot($pilot,$filter_name = '') { |
|
1104 | + public function getStatsPilot($pilot, $filter_name = '') { |
|
1105 | 1105 | global $globalArchiveMonths, $globalDBdriver; |
1106 | 1106 | if ($filter_name == '') $filter_name = $this->filter_name; |
1107 | 1107 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
1108 | 1108 | try { |
1109 | 1109 | $sth = $this->db->prepare($query); |
1110 | - $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot)); |
|
1111 | - } catch(PDOException $e) { |
|
1110 | + $sth->execute(array(':filter_name' => $filter_name, ':pilot' => $pilot)); |
|
1111 | + } catch (PDOException $e) { |
|
1112 | 1112 | echo "error : ".$e->getMessage(); |
1113 | 1113 | } |
1114 | 1114 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -1116,7 +1116,7 @@ discard block |
||
1116 | 1116 | else return 0; |
1117 | 1117 | } |
1118 | 1118 | |
1119 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
1119 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
1120 | 1120 | global $globalDBdriver; |
1121 | 1121 | if ($filter_name == '') $filter_name = $this->filter_name; |
1122 | 1122 | if ($globalDBdriver == 'mysql') { |
@@ -1124,15 +1124,15 @@ discard block |
||
1124 | 1124 | } else { |
1125 | 1125 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1126 | 1126 | } |
1127 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1127 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1128 | 1128 | try { |
1129 | 1129 | $sth = $this->db->prepare($query); |
1130 | 1130 | $sth->execute($query_values); |
1131 | - } catch(PDOException $e) { |
|
1131 | + } catch (PDOException $e) { |
|
1132 | 1132 | return "error : ".$e->getMessage(); |
1133 | 1133 | } |
1134 | 1134 | } |
1135 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
1135 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
1136 | 1136 | global $globalDBdriver; |
1137 | 1137 | if ($filter_name == '') $filter_name = $this->filter_name; |
1138 | 1138 | if ($globalDBdriver == 'mysql') { |
@@ -1141,11 +1141,11 @@ discard block |
||
1141 | 1141 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
1142 | 1142 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1143 | 1143 | } |
1144 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1144 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1145 | 1145 | try { |
1146 | 1146 | $sth = $this->db->prepare($query); |
1147 | 1147 | $sth->execute($query_values); |
1148 | - } catch(PDOException $e) { |
|
1148 | + } catch (PDOException $e) { |
|
1149 | 1149 | return "error : ".$e->getMessage(); |
1150 | 1150 | } |
1151 | 1151 | } |
@@ -1169,75 +1169,75 @@ discard block |
||
1169 | 1169 | } |
1170 | 1170 | */ |
1171 | 1171 | |
1172 | - public function getStatsSource($stats_type,$year = '',$month = '',$day = '') { |
|
1172 | + public function getStatsSource($stats_type, $year = '', $month = '', $day = '') { |
|
1173 | 1173 | global $globalDBdriver; |
1174 | 1174 | $query = "SELECT * FROM stats_source WHERE stats_type = :stats_type"; |
1175 | 1175 | $query_values = array(); |
1176 | 1176 | if ($globalDBdriver == 'mysql') { |
1177 | 1177 | if ($year != '') { |
1178 | 1178 | $query .= ' AND YEAR(stats_date) = :year'; |
1179 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1179 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1180 | 1180 | } |
1181 | 1181 | if ($month != '') { |
1182 | 1182 | $query .= ' AND MONTH(stats_date) = :month'; |
1183 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1183 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1184 | 1184 | } |
1185 | 1185 | if ($day != '') { |
1186 | 1186 | $query .= ' AND DAY(stats_date) = :day'; |
1187 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1187 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1188 | 1188 | } |
1189 | 1189 | } else { |
1190 | 1190 | if ($year != '') { |
1191 | 1191 | $query .= ' AND EXTRACT(YEAR FROM stats_date) = :year'; |
1192 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1192 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1193 | 1193 | } |
1194 | 1194 | if ($month != '') { |
1195 | 1195 | $query .= ' AND EXTRACT(MONTH FROM stats_date) = :month'; |
1196 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1196 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1197 | 1197 | } |
1198 | 1198 | if ($day != '') { |
1199 | 1199 | $query .= ' AND EXTRACT(DAY FROM stats_date) = :day'; |
1200 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1200 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1201 | 1201 | } |
1202 | 1202 | } |
1203 | 1203 | $query .= " ORDER BY source_name"; |
1204 | - $query_values = array_merge($query_values,array(':stats_type' => $stats_type)); |
|
1204 | + $query_values = array_merge($query_values, array(':stats_type' => $stats_type)); |
|
1205 | 1205 | try { |
1206 | 1206 | $sth = $this->db->prepare($query); |
1207 | 1207 | $sth->execute($query_values); |
1208 | - } catch(PDOException $e) { |
|
1208 | + } catch (PDOException $e) { |
|
1209 | 1209 | echo "error : ".$e->getMessage(); |
1210 | 1210 | } |
1211 | 1211 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1212 | 1212 | return $all; |
1213 | 1213 | } |
1214 | 1214 | |
1215 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
1215 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
1216 | 1216 | global $globalDBdriver; |
1217 | 1217 | if ($globalDBdriver == 'mysql') { |
1218 | 1218 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
1219 | 1219 | } else { |
1220 | 1220 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
1221 | 1221 | } |
1222 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
1222 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
1223 | 1223 | try { |
1224 | 1224 | $sth = $this->db->prepare($query); |
1225 | 1225 | $sth->execute($query_values); |
1226 | - } catch(PDOException $e) { |
|
1226 | + } catch (PDOException $e) { |
|
1227 | 1227 | return "error : ".$e->getMessage(); |
1228 | 1228 | } |
1229 | 1229 | } |
1230 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
1230 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
1231 | 1231 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
1232 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1232 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1233 | 1233 | try { |
1234 | 1234 | $sth = $this->db->prepare($query); |
1235 | 1235 | $sth->execute($query_values); |
1236 | - } catch(PDOException $e) { |
|
1236 | + } catch (PDOException $e) { |
|
1237 | 1237 | return "error : ".$e->getMessage(); |
1238 | 1238 | } |
1239 | 1239 | } |
1240 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) { |
|
1240 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
1241 | 1241 | global $globalDBdriver; |
1242 | 1242 | if ($globalDBdriver == 'mysql') { |
1243 | 1243 | if ($reset) { |
@@ -1252,15 +1252,15 @@ discard block |
||
1252 | 1252 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1253 | 1253 | } |
1254 | 1254 | } |
1255 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1255 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1256 | 1256 | try { |
1257 | 1257 | $sth = $this->db->prepare($query); |
1258 | 1258 | $sth->execute($query_values); |
1259 | - } catch(PDOException $e) { |
|
1259 | + } catch (PDOException $e) { |
|
1260 | 1260 | return "error : ".$e->getMessage(); |
1261 | 1261 | } |
1262 | 1262 | } |
1263 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) { |
|
1263 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1264 | 1264 | global $globalDBdriver; |
1265 | 1265 | if ($globalDBdriver == 'mysql') { |
1266 | 1266 | if ($reset) { |
@@ -1275,15 +1275,15 @@ discard block |
||
1275 | 1275 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
1276 | 1276 | } |
1277 | 1277 | } |
1278 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1278 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1279 | 1279 | try { |
1280 | 1280 | $sth = $this->db->prepare($query); |
1281 | 1281 | $sth->execute($query_values); |
1282 | - } catch(PDOException $e) { |
|
1282 | + } catch (PDOException $e) { |
|
1283 | 1283 | return "error : ".$e->getMessage(); |
1284 | 1284 | } |
1285 | 1285 | } |
1286 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) { |
|
1286 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1287 | 1287 | global $globalDBdriver; |
1288 | 1288 | if ($globalDBdriver == 'mysql') { |
1289 | 1289 | if ($reset) { |
@@ -1298,15 +1298,15 @@ discard block |
||
1298 | 1298 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; |
1299 | 1299 | } |
1300 | 1300 | } |
1301 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
1301 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao); |
|
1302 | 1302 | try { |
1303 | 1303 | $sth = $this->db->prepare($query); |
1304 | 1304 | $sth->execute($query_values); |
1305 | - } catch(PDOException $e) { |
|
1305 | + } catch (PDOException $e) { |
|
1306 | 1306 | return "error : ".$e->getMessage(); |
1307 | 1307 | } |
1308 | 1308 | } |
1309 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
1309 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
1310 | 1310 | global $globalDBdriver; |
1311 | 1311 | if ($globalDBdriver == 'mysql') { |
1312 | 1312 | if ($reset) { |
@@ -1321,15 +1321,15 @@ discard block |
||
1321 | 1321 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1322 | 1322 | } |
1323 | 1323 | } |
1324 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1324 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1325 | 1325 | try { |
1326 | 1326 | $sth = $this->db->prepare($query); |
1327 | 1327 | $sth->execute($query_values); |
1328 | - } catch(PDOException $e) { |
|
1328 | + } catch (PDOException $e) { |
|
1329 | 1329 | return "error : ".$e->getMessage(); |
1330 | 1330 | } |
1331 | 1331 | } |
1332 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) { |
|
1332 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) { |
|
1333 | 1333 | global $globalDBdriver; |
1334 | 1334 | if ($globalDBdriver == 'mysql') { |
1335 | 1335 | if ($reset) { |
@@ -1344,15 +1344,15 @@ discard block |
||
1344 | 1344 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
1345 | 1345 | } |
1346 | 1346 | } |
1347 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1347 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1348 | 1348 | try { |
1349 | 1349 | $sth = $this->db->prepare($query); |
1350 | 1350 | $sth->execute($query_values); |
1351 | - } catch(PDOException $e) { |
|
1351 | + } catch (PDOException $e) { |
|
1352 | 1352 | return "error : ".$e->getMessage(); |
1353 | 1353 | } |
1354 | 1354 | } |
1355 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) { |
|
1355 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) { |
|
1356 | 1356 | global $globalDBdriver; |
1357 | 1357 | if ($globalDBdriver == 'mysql') { |
1358 | 1358 | if ($reset) { |
@@ -1367,15 +1367,15 @@ discard block |
||
1367 | 1367 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1368 | 1368 | } |
1369 | 1369 | } |
1370 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1370 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1371 | 1371 | try { |
1372 | 1372 | $sth = $this->db->prepare($query); |
1373 | 1373 | $sth->execute($query_values); |
1374 | - } catch(PDOException $e) { |
|
1374 | + } catch (PDOException $e) { |
|
1375 | 1375 | return "error : ".$e->getMessage(); |
1376 | 1376 | } |
1377 | 1377 | } |
1378 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) { |
|
1378 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) { |
|
1379 | 1379 | global $globalDBdriver; |
1380 | 1380 | if ($globalDBdriver == 'mysql') { |
1381 | 1381 | if ($reset) { |
@@ -1390,15 +1390,15 @@ discard block |
||
1390 | 1390 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1391 | 1391 | } |
1392 | 1392 | } |
1393 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1393 | + $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source); |
|
1394 | 1394 | try { |
1395 | 1395 | $sth = $this->db->prepare($query); |
1396 | 1396 | $sth->execute($query_values); |
1397 | - } catch(PDOException $e) { |
|
1397 | + } catch (PDOException $e) { |
|
1398 | 1398 | return "error : ".$e->getMessage(); |
1399 | 1399 | } |
1400 | 1400 | } |
1401 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) { |
|
1401 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1402 | 1402 | global $globalDBdriver; |
1403 | 1403 | if ($airport_icao != '') { |
1404 | 1404 | if ($globalDBdriver == 'mysql') { |
@@ -1414,16 +1414,16 @@ discard block |
||
1414 | 1414 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1415 | 1415 | } |
1416 | 1416 | } |
1417 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1417 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1418 | 1418 | try { |
1419 | 1419 | $sth = $this->db->prepare($query); |
1420 | 1420 | $sth->execute($query_values); |
1421 | - } catch(PDOException $e) { |
|
1421 | + } catch (PDOException $e) { |
|
1422 | 1422 | return "error : ".$e->getMessage(); |
1423 | 1423 | } |
1424 | 1424 | } |
1425 | 1425 | } |
1426 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
1426 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
1427 | 1427 | global $globalDBdriver; |
1428 | 1428 | if ($airport_icao != '') { |
1429 | 1429 | if ($globalDBdriver == 'mysql') { |
@@ -1431,16 +1431,16 @@ discard block |
||
1431 | 1431 | } else { |
1432 | 1432 | $query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1433 | 1433 | } |
1434 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1434 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1435 | 1435 | try { |
1436 | 1436 | $sth = $this->db->prepare($query); |
1437 | 1437 | $sth->execute($query_values); |
1438 | - } catch(PDOException $e) { |
|
1438 | + } catch (PDOException $e) { |
|
1439 | 1439 | return "error : ".$e->getMessage(); |
1440 | 1440 | } |
1441 | 1441 | } |
1442 | 1442 | } |
1443 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) { |
|
1443 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1444 | 1444 | global $globalDBdriver; |
1445 | 1445 | if ($airport_icao != '') { |
1446 | 1446 | if ($globalDBdriver == 'mysql') { |
@@ -1456,16 +1456,16 @@ discard block |
||
1456 | 1456 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1457 | 1457 | } |
1458 | 1458 | } |
1459 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1459 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1460 | 1460 | try { |
1461 | 1461 | $sth = $this->db->prepare($query); |
1462 | 1462 | $sth->execute($query_values); |
1463 | - } catch(PDOException $e) { |
|
1463 | + } catch (PDOException $e) { |
|
1464 | 1464 | return "error : ".$e->getMessage(); |
1465 | 1465 | } |
1466 | 1466 | } |
1467 | 1467 | } |
1468 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1468 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1469 | 1469 | global $globalDBdriver; |
1470 | 1470 | if ($airport_icao != '') { |
1471 | 1471 | if ($globalDBdriver == 'mysql') { |
@@ -1473,11 +1473,11 @@ discard block |
||
1473 | 1473 | } else { |
1474 | 1474 | $query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1475 | 1475 | } |
1476 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1476 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1477 | 1477 | try { |
1478 | 1478 | $sth = $this->db->prepare($query); |
1479 | 1479 | $sth->execute($query_values); |
1480 | - } catch(PDOException $e) { |
|
1480 | + } catch (PDOException $e) { |
|
1481 | 1481 | return "error : ".$e->getMessage(); |
1482 | 1482 | } |
1483 | 1483 | } |
@@ -1489,7 +1489,7 @@ discard block |
||
1489 | 1489 | try { |
1490 | 1490 | $sth = $this->db->prepare($query); |
1491 | 1491 | $sth->execute($query_values); |
1492 | - } catch(PDOException $e) { |
|
1492 | + } catch (PDOException $e) { |
|
1493 | 1493 | return "error : ".$e->getMessage(); |
1494 | 1494 | } |
1495 | 1495 | } |
@@ -1499,7 +1499,7 @@ discard block |
||
1499 | 1499 | try { |
1500 | 1500 | $sth = $this->db->prepare($query); |
1501 | 1501 | $sth->execute($query_values); |
1502 | - } catch(PDOException $e) { |
|
1502 | + } catch (PDOException $e) { |
|
1503 | 1503 | return "error : ".$e->getMessage(); |
1504 | 1504 | } |
1505 | 1505 | } |
@@ -1509,13 +1509,13 @@ discard block |
||
1509 | 1509 | try { |
1510 | 1510 | $sth = $this->db->prepare($query); |
1511 | 1511 | $sth->execute($query_values); |
1512 | - } catch(PDOException $e) { |
|
1512 | + } catch (PDOException $e) { |
|
1513 | 1513 | return "error : ".$e->getMessage(); |
1514 | 1514 | } |
1515 | 1515 | } |
1516 | 1516 | |
1517 | 1517 | public function addOldStats() { |
1518 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear, $globalAccidents; |
|
1518 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear, $globalAccidents; |
|
1519 | 1519 | $Common = new Common(); |
1520 | 1520 | $Connection = new Connection(); |
1521 | 1521 | date_default_timezone_set('UTC'); |
@@ -1533,41 +1533,41 @@ discard block |
||
1533 | 1533 | $Spotter = new Spotter($this->db); |
1534 | 1534 | |
1535 | 1535 | if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
1536 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
1536 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
1537 | 1537 | foreach ($alldata as $number) { |
1538 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
|
1538 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset); |
|
1539 | 1539 | } |
1540 | 1540 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
1541 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
1541 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
1542 | 1542 | foreach ($alldata as $number) { |
1543 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
|
1543 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset); |
|
1544 | 1544 | } |
1545 | 1545 | if ($globalDebug) echo 'Count all registrations...'."\n"; |
1546 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
1546 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
1547 | 1547 | foreach ($alldata as $number) { |
1548 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
|
1548 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset); |
|
1549 | 1549 | } |
1550 | 1550 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
1551 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
1551 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
1552 | 1552 | foreach ($alldata as $number) { |
1553 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
1553 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
1554 | 1554 | } |
1555 | 1555 | if ($globalDebug) echo 'Count all owners...'."\n"; |
1556 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
1556 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
1557 | 1557 | foreach ($alldata as $number) { |
1558 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
|
1558 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset); |
|
1559 | 1559 | } |
1560 | 1560 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
1561 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
1561 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
1562 | 1562 | foreach ($alldata as $number) { |
1563 | 1563 | if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name']; |
1564 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
|
1564 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset); |
|
1565 | 1565 | } |
1566 | 1566 | |
1567 | 1567 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1568 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
1568 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
1569 | 1569 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1570 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1570 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
1571 | 1571 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1572 | 1572 | $alldata = array(); |
1573 | 1573 | |
@@ -1585,14 +1585,14 @@ discard block |
||
1585 | 1585 | foreach ($alldata as $key => $row) { |
1586 | 1586 | $count[$key] = $row['airport_departure_icao_count']; |
1587 | 1587 | } |
1588 | - array_multisort($count,SORT_DESC,$alldata); |
|
1588 | + array_multisort($count, SORT_DESC, $alldata); |
|
1589 | 1589 | foreach ($alldata as $number) { |
1590 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
|
1590 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset); |
|
1591 | 1591 | } |
1592 | 1592 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1593 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
1593 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
1594 | 1594 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1595 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1595 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
1596 | 1596 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1597 | 1597 | $alldata = array(); |
1598 | 1598 | foreach ($pall as $value) { |
@@ -1609,18 +1609,18 @@ discard block |
||
1609 | 1609 | foreach ($alldata as $key => $row) { |
1610 | 1610 | $count[$key] = $row['airport_arrival_icao_count']; |
1611 | 1611 | } |
1612 | - array_multisort($count,SORT_DESC,$alldata); |
|
1612 | + array_multisort($count, SORT_DESC, $alldata); |
|
1613 | 1613 | foreach ($alldata as $number) { |
1614 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
|
1614 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset); |
|
1615 | 1615 | } |
1616 | 1616 | if ($Connection->tableExists('countries')) { |
1617 | 1617 | if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
1618 | 1618 | //$SpotterArchive = new SpotterArchive(); |
1619 | 1619 | //$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1620 | 1620 | $Spotter = new Spotter($this->db); |
1621 | - $alldata = $Spotter->countAllFlightOverCountries(false,0,$last_update_day); |
|
1621 | + $alldata = $Spotter->countAllFlightOverCountries(false, 0, $last_update_day); |
|
1622 | 1622 | foreach ($alldata as $number) { |
1623 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset); |
|
1623 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset); |
|
1624 | 1624 | } |
1625 | 1625 | } |
1626 | 1626 | |
@@ -1630,12 +1630,12 @@ discard block |
||
1630 | 1630 | $this->deleteStatsByType('fatalities_byyear'); |
1631 | 1631 | $alldata = $Accident->countFatalitiesByYear(); |
1632 | 1632 | foreach ($alldata as $number) { |
1633 | - $this->addStat('fatalities_byyear',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,1,1,$number['year']))); |
|
1633 | + $this->addStat('fatalities_byyear', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $number['year']))); |
|
1634 | 1634 | } |
1635 | 1635 | $this->deleteStatsByType('fatalities_bymonth'); |
1636 | 1636 | $alldata = $Accident->countFatalitiesLast12Months(); |
1637 | 1637 | foreach ($alldata as $number) { |
1638 | - $this->addStat('fatalities_bymonth',$number['count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month'],1,$number['year']))); |
|
1638 | + $this->addStat('fatalities_bymonth', $number['count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month'], 1, $number['year']))); |
|
1639 | 1639 | } |
1640 | 1640 | } |
1641 | 1641 | |
@@ -1651,37 +1651,37 @@ discard block |
||
1651 | 1651 | $lastyear = false; |
1652 | 1652 | foreach ($alldata as $number) { |
1653 | 1653 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1654 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1654 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1655 | 1655 | } |
1656 | 1656 | if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
1657 | 1657 | $alldata = $Spotter->countAllMilitaryMonths($filter_last_month); |
1658 | 1658 | foreach ($alldata as $number) { |
1659 | - $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1659 | + $this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1660 | 1660 | } |
1661 | 1661 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
1662 | 1662 | $alldata = $Spotter->countAllMonthsOwners($filter_last_month); |
1663 | 1663 | foreach ($alldata as $number) { |
1664 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1664 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1665 | 1665 | } |
1666 | 1666 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
1667 | 1667 | $alldata = $Spotter->countAllMonthsPilots($filter_last_month); |
1668 | 1668 | foreach ($alldata as $number) { |
1669 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1669 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1670 | 1670 | } |
1671 | 1671 | if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
1672 | 1672 | $alldata = $Spotter->countAllMonthsAirlines($filter_last_month); |
1673 | 1673 | foreach ($alldata as $number) { |
1674 | - $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1674 | + $this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1675 | 1675 | } |
1676 | 1676 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
1677 | 1677 | $alldata = $Spotter->countAllMonthsAircrafts($filter_last_month); |
1678 | 1678 | foreach ($alldata as $number) { |
1679 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1679 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1680 | 1680 | } |
1681 | 1681 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
1682 | 1682 | $alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month); |
1683 | 1683 | foreach ($alldata as $number) { |
1684 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1684 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1685 | 1685 | } |
1686 | 1686 | if ($globalDebug) echo 'Airports data...'."\n"; |
1687 | 1687 | if ($globalDebug) echo '...Departure'."\n"; |
@@ -1726,7 +1726,7 @@ discard block |
||
1726 | 1726 | } |
1727 | 1727 | $alldata = $pall; |
1728 | 1728 | foreach ($alldata as $number) { |
1729 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
1729 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
1730 | 1730 | } |
1731 | 1731 | echo '...Arrival'."\n"; |
1732 | 1732 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -1768,7 +1768,7 @@ discard block |
||
1768 | 1768 | } |
1769 | 1769 | $alldata = $pall; |
1770 | 1770 | foreach ($alldata as $number) { |
1771 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
1771 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
1772 | 1772 | } |
1773 | 1773 | |
1774 | 1774 | echo 'Flights data...'."\n"; |
@@ -1776,28 +1776,28 @@ discard block |
||
1776 | 1776 | echo '-> countAllDatesLastMonth...'."\n"; |
1777 | 1777 | $alldata = $Spotter->countAllDatesLastMonth($filter_last_month); |
1778 | 1778 | foreach ($alldata as $number) { |
1779 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
1779 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
1780 | 1780 | } |
1781 | 1781 | echo '-> countAllDates...'."\n"; |
1782 | 1782 | $previousdata = $this->countAllDates(); |
1783 | 1783 | $previousdatabyairlines = $this->countAllDatesByAirlines(); |
1784 | 1784 | $this->deleteStatFlight('date'); |
1785 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter_last_month)); |
|
1785 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter_last_month)); |
|
1786 | 1786 | $values = array(); |
1787 | 1787 | foreach ($alldata as $cnt) { |
1788 | 1788 | $values[] = $cnt['date_count']; |
1789 | 1789 | } |
1790 | - array_multisort($values,SORT_DESC,$alldata); |
|
1791 | - array_splice($alldata,11); |
|
1790 | + array_multisort($values, SORT_DESC, $alldata); |
|
1791 | + array_splice($alldata, 11); |
|
1792 | 1792 | foreach ($alldata as $number) { |
1793 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
1793 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
1794 | 1794 | } |
1795 | 1795 | |
1796 | 1796 | $this->deleteStatFlight('hour'); |
1797 | 1797 | echo '-> countAllHours...'."\n"; |
1798 | - $alldata = $Spotter->countAllHours('hour',$filter_last_month); |
|
1798 | + $alldata = $Spotter->countAllHours('hour', $filter_last_month); |
|
1799 | 1799 | foreach ($alldata as $number) { |
1800 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
1800 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
1801 | 1801 | } |
1802 | 1802 | |
1803 | 1803 | |
@@ -1808,42 +1808,42 @@ discard block |
||
1808 | 1808 | if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
1809 | 1809 | $SpotterArchive = new SpotterArchive(); |
1810 | 1810 | //$Spotter = new Spotter($this->db); |
1811 | - $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
|
1811 | + $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day); |
|
1812 | 1812 | //$alldata = $Spotter->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
1813 | 1813 | foreach ($alldata as $number) { |
1814 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
|
1814 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset); |
|
1815 | 1815 | } |
1816 | 1816 | } |
1817 | 1817 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
1818 | 1818 | $Spotter = new Spotter($this->db); |
1819 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
1819 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
1820 | 1820 | foreach ($alldata as $number) { |
1821 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
|
1821 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset); |
|
1822 | 1822 | } |
1823 | 1823 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
1824 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
1824 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
1825 | 1825 | foreach ($alldata as $number) { |
1826 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
|
1826 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset); |
|
1827 | 1827 | } |
1828 | 1828 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
1829 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
1829 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
1830 | 1830 | foreach ($alldata as $number) { |
1831 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
1831 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
1832 | 1832 | } |
1833 | 1833 | if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
1834 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
1834 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
1835 | 1835 | foreach ($alldata as $number) { |
1836 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
|
1836 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset); |
|
1837 | 1837 | } |
1838 | 1838 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
1839 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
1839 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
1840 | 1840 | foreach ($alldata as $number) { |
1841 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
|
1841 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset); |
|
1842 | 1842 | } |
1843 | 1843 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1844 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1844 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1845 | 1845 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1846 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1846 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1847 | 1847 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1848 | 1848 | //$alldata = array(); |
1849 | 1849 | foreach ($dall as $value) { |
@@ -1863,12 +1863,12 @@ discard block |
||
1863 | 1863 | } |
1864 | 1864 | $alldata = $pall; |
1865 | 1865 | foreach ($alldata as $number) { |
1866 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
|
1866 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset); |
|
1867 | 1867 | } |
1868 | 1868 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1869 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1869 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1870 | 1870 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1871 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1871 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1872 | 1872 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1873 | 1873 | //$alldata = array(); |
1874 | 1874 | foreach ($dall as $value) { |
@@ -1888,7 +1888,7 @@ discard block |
||
1888 | 1888 | } |
1889 | 1889 | $alldata = $pall; |
1890 | 1890 | foreach ($alldata as $number) { |
1891 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
1891 | + if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset); |
|
1892 | 1892 | } |
1893 | 1893 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
1894 | 1894 | $Spotter = new Spotter($this->db); |
@@ -1896,27 +1896,27 @@ discard block |
||
1896 | 1896 | $lastyear = false; |
1897 | 1897 | foreach ($alldata as $number) { |
1898 | 1898 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1899 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
1899 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
1900 | 1900 | } |
1901 | 1901 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
1902 | 1902 | $alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month); |
1903 | 1903 | foreach ($alldata as $number) { |
1904 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
1904 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
1905 | 1905 | } |
1906 | 1906 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
1907 | 1907 | $alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month); |
1908 | 1908 | foreach ($alldata as $number) { |
1909 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
1909 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
1910 | 1910 | } |
1911 | 1911 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
1912 | 1912 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month); |
1913 | 1913 | foreach ($alldata as $number) { |
1914 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
1914 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
1915 | 1915 | } |
1916 | 1916 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
1917 | 1917 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month); |
1918 | 1918 | foreach ($alldata as $number) { |
1919 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
1919 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
1920 | 1920 | } |
1921 | 1921 | if ($globalDebug) echo '...Departure'."\n"; |
1922 | 1922 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -1939,7 +1939,7 @@ discard block |
||
1939 | 1939 | } |
1940 | 1940 | $alldata = $pall; |
1941 | 1941 | foreach ($alldata as $number) { |
1942 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
|
1942 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']); |
|
1943 | 1943 | } |
1944 | 1944 | if ($globalDebug) echo '...Arrival'."\n"; |
1945 | 1945 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -1962,32 +1962,32 @@ discard block |
||
1962 | 1962 | } |
1963 | 1963 | $alldata = $pall; |
1964 | 1964 | foreach ($alldata as $number) { |
1965 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
|
1965 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']); |
|
1966 | 1966 | } |
1967 | 1967 | |
1968 | 1968 | if ($globalDebug) echo 'Flights data...'."\n"; |
1969 | 1969 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
1970 | 1970 | $alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month); |
1971 | 1971 | foreach ($alldata as $number) { |
1972 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
1972 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1973 | 1973 | } |
1974 | 1974 | if ($globalDebug) echo '-> countAllDates...'."\n"; |
1975 | 1975 | //$previousdata = $this->countAllDatesByAirlines(); |
1976 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month)); |
|
1976 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines($filter_last_month)); |
|
1977 | 1977 | $values = array(); |
1978 | 1978 | foreach ($alldata as $cnt) { |
1979 | 1979 | $values[] = $cnt['date_count']; |
1980 | 1980 | } |
1981 | - array_multisort($values,SORT_DESC,$alldata); |
|
1982 | - array_splice($alldata,11); |
|
1981 | + array_multisort($values, SORT_DESC, $alldata); |
|
1982 | + array_splice($alldata, 11); |
|
1983 | 1983 | foreach ($alldata as $number) { |
1984 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
1984 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1985 | 1985 | } |
1986 | 1986 | |
1987 | 1987 | if ($globalDebug) echo '-> countAllHours...'."\n"; |
1988 | - $alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month); |
|
1988 | + $alldata = $Spotter->countAllHoursByAirlines('hour', $filter_last_month); |
|
1989 | 1989 | foreach ($alldata as $number) { |
1990 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
1990 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
1991 | 1991 | } |
1992 | 1992 | |
1993 | 1993 | |
@@ -2011,7 +2011,7 @@ discard block |
||
2011 | 2011 | $last_update_day = date('Y').'-01-01 00:00:00'; |
2012 | 2012 | } |
2013 | 2013 | } |
2014 | - if (isset($filter['DeleteLastYearStats']) && date('Y',strtotime($last_update_day)) != date('Y')) { |
|
2014 | + if (isset($filter['DeleteLastYearStats']) && date('Y', strtotime($last_update_day)) != date('Y')) { |
|
2015 | 2015 | $last_update_day = date('Y').'-01-01 00:00:00'; |
2016 | 2016 | $reset = true; |
2017 | 2017 | } |
@@ -2020,32 +2020,32 @@ discard block |
||
2020 | 2020 | // Count by filter |
2021 | 2021 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
2022 | 2022 | $Spotter = new Spotter($this->db); |
2023 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
2023 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
2024 | 2024 | foreach ($alldata as $number) { |
2025 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
|
2025 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset); |
|
2026 | 2026 | } |
2027 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
|
2027 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter); |
|
2028 | 2028 | foreach ($alldata as $number) { |
2029 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
|
2029 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset); |
|
2030 | 2030 | } |
2031 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
2031 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
2032 | 2032 | foreach ($alldata as $number) { |
2033 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
|
2033 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset); |
|
2034 | 2034 | } |
2035 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
2035 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
2036 | 2036 | foreach ($alldata as $number) { |
2037 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
|
2037 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset); |
|
2038 | 2038 | } |
2039 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
2039 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
2040 | 2040 | foreach ($alldata as $number) { |
2041 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
|
2041 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset); |
|
2042 | 2042 | } |
2043 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
2043 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
2044 | 2044 | foreach ($alldata as $number) { |
2045 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
|
2045 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset); |
|
2046 | 2046 | } |
2047 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
2048 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
2047 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
2048 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
2049 | 2049 | $alldata = array(); |
2050 | 2050 | foreach ($pall as $value) { |
2051 | 2051 | $icao = $value['airport_departure_icao']; |
@@ -2061,12 +2061,12 @@ discard block |
||
2061 | 2061 | foreach ($alldata as $key => $row) { |
2062 | 2062 | $count[$key] = $row['airport_departure_icao_count']; |
2063 | 2063 | } |
2064 | - array_multisort($count,SORT_DESC,$alldata); |
|
2064 | + array_multisort($count, SORT_DESC, $alldata); |
|
2065 | 2065 | foreach ($alldata as $number) { |
2066 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
|
2066 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset); |
|
2067 | 2067 | } |
2068 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
|
2069 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
2068 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
2069 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
2070 | 2070 | $alldata = array(); |
2071 | 2071 | foreach ($pall as $value) { |
2072 | 2072 | $icao = $value['airport_arrival_icao']; |
@@ -2082,40 +2082,40 @@ discard block |
||
2082 | 2082 | foreach ($alldata as $key => $row) { |
2083 | 2083 | $count[$key] = $row['airport_arrival_icao_count']; |
2084 | 2084 | } |
2085 | - array_multisort($count,SORT_DESC,$alldata); |
|
2085 | + array_multisort($count, SORT_DESC, $alldata); |
|
2086 | 2086 | foreach ($alldata as $number) { |
2087 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
|
2087 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset); |
|
2088 | 2088 | } |
2089 | 2089 | $Spotter = new Spotter($this->db); |
2090 | 2090 | $alldata = $Spotter->countAllMonths($filter); |
2091 | 2091 | $lastyear = false; |
2092 | 2092 | foreach ($alldata as $number) { |
2093 | 2093 | if ($number['year_name'] != date('Y')) $lastyear = true; |
2094 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2094 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
2095 | 2095 | } |
2096 | 2096 | $alldata = $Spotter->countAllMonthsOwners($filter); |
2097 | 2097 | foreach ($alldata as $number) { |
2098 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2098 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
2099 | 2099 | } |
2100 | 2100 | $alldata = $Spotter->countAllMonthsPilots($filter); |
2101 | 2101 | foreach ($alldata as $number) { |
2102 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2102 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
2103 | 2103 | } |
2104 | 2104 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
2105 | 2105 | foreach ($alldata as $number) { |
2106 | - $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2106 | + $this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
2107 | 2107 | } |
2108 | 2108 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
2109 | 2109 | foreach ($alldata as $number) { |
2110 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2110 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
2111 | 2111 | } |
2112 | 2112 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
2113 | 2113 | foreach ($alldata as $number) { |
2114 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
2114 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
2115 | 2115 | } |
2116 | 2116 | echo '...Departure'."\n"; |
2117 | - $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
|
2118 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
2117 | + $pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); |
|
2118 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); |
|
2119 | 2119 | foreach ($dall as $value) { |
2120 | 2120 | $icao = $value['departure_airport_icao']; |
2121 | 2121 | $ddate = $value['date']; |
@@ -2133,11 +2133,11 @@ discard block |
||
2133 | 2133 | } |
2134 | 2134 | $alldata = $pall; |
2135 | 2135 | foreach ($alldata as $number) { |
2136 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
|
2136 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name); |
|
2137 | 2137 | } |
2138 | 2138 | echo '...Arrival'."\n"; |
2139 | - $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
|
2140 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
2139 | + $pall = $Spotter->getLast7DaysAirportsArrival('', $filter); |
|
2140 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); |
|
2141 | 2141 | foreach ($dall as $value) { |
2142 | 2142 | $icao = $value['arrival_airport_icao']; |
2143 | 2143 | $ddate = $value['date']; |
@@ -2155,40 +2155,40 @@ discard block |
||
2155 | 2155 | } |
2156 | 2156 | $alldata = $pall; |
2157 | 2157 | foreach ($alldata as $number) { |
2158 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
|
2158 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name); |
|
2159 | 2159 | } |
2160 | 2160 | |
2161 | 2161 | echo 'Flights data...'."\n"; |
2162 | 2162 | echo '-> countAllDatesLastMonth...'."\n"; |
2163 | 2163 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
2164 | 2164 | foreach ($alldata as $number) { |
2165 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
2165 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
2166 | 2166 | } |
2167 | 2167 | echo '-> countAllDates...'."\n"; |
2168 | - $previousdata = $this->countAllDates('',$filter_name); |
|
2169 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
2168 | + $previousdata = $this->countAllDates('', $filter_name); |
|
2169 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
2170 | 2170 | $values = array(); |
2171 | 2171 | foreach ($alldata as $cnt) { |
2172 | 2172 | $values[] = $cnt['date_count']; |
2173 | 2173 | } |
2174 | - array_multisort($values,SORT_DESC,$alldata); |
|
2175 | - array_splice($alldata,11); |
|
2174 | + array_multisort($values, SORT_DESC, $alldata); |
|
2175 | + array_splice($alldata, 11); |
|
2176 | 2176 | foreach ($alldata as $number) { |
2177 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
2177 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
2178 | 2178 | } |
2179 | 2179 | |
2180 | 2180 | echo '-> countAllHours...'."\n"; |
2181 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
2181 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
2182 | 2182 | foreach ($alldata as $number) { |
2183 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
2183 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
2184 | 2184 | } |
2185 | 2185 | echo 'Insert last stats update date...'."\n"; |
2186 | 2186 | date_default_timezone_set('UTC'); |
2187 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s')); |
|
2187 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s')); |
|
2188 | 2188 | if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) { |
2189 | - if (date('Y',strtotime($last_update_day)) != date('Y')) { |
|
2189 | + if (date('Y', strtotime($last_update_day)) != date('Y')) { |
|
2190 | 2190 | $this->deleteOldStats($filter_name); |
2191 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00'); |
|
2191 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00'); |
|
2192 | 2192 | } |
2193 | 2193 | } |
2194 | 2194 | |
@@ -2201,16 +2201,16 @@ discard block |
||
2201 | 2201 | // SUM all previous month to put as year |
2202 | 2202 | $previous_year = date('Y'); |
2203 | 2203 | $previous_year--; |
2204 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2205 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2206 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2207 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2204 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2205 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2206 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2207 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2208 | 2208 | $allairlines = $this->getAllAirlineNames(); |
2209 | 2209 | foreach ($allairlines as $data) { |
2210 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2211 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2212 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2213 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2210 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2211 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2212 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2213 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2214 | 2214 | } |
2215 | 2215 | |
2216 | 2216 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -2219,7 +2219,7 @@ discard block |
||
2219 | 2219 | try { |
2220 | 2220 | $sth = $this->db->prepare($query); |
2221 | 2221 | $sth->execute(); |
2222 | - } catch(PDOException $e) { |
|
2222 | + } catch (PDOException $e) { |
|
2223 | 2223 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
2224 | 2224 | } |
2225 | 2225 | } |
@@ -2228,15 +2228,15 @@ discard block |
||
2228 | 2228 | try { |
2229 | 2229 | $sth = $this->db->prepare($query); |
2230 | 2230 | $sth->execute(); |
2231 | - } catch(PDOException $e) { |
|
2231 | + } catch (PDOException $e) { |
|
2232 | 2232 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
2233 | 2233 | } |
2234 | 2234 | } |
2235 | 2235 | if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) { |
2236 | 2236 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
2237 | - if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) { |
|
2237 | + if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) { |
|
2238 | 2238 | $this->deleteOldStats(); |
2239 | - $this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00'); |
|
2239 | + $this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00'); |
|
2240 | 2240 | $lastyearupdate = true; |
2241 | 2241 | } |
2242 | 2242 | } |
@@ -2258,7 +2258,7 @@ discard block |
||
2258 | 2258 | try { |
2259 | 2259 | $sth = $this->db->prepare($query); |
2260 | 2260 | $sth->execute(); |
2261 | - } catch(PDOException $e) { |
|
2261 | + } catch (PDOException $e) { |
|
2262 | 2262 | return "error : ".$e->getMessage(); |
2263 | 2263 | } |
2264 | 2264 | } |
@@ -2272,14 +2272,14 @@ discard block |
||
2272 | 2272 | try { |
2273 | 2273 | $sth = $this->db->prepare($query); |
2274 | 2274 | $sth->execute(); |
2275 | - } catch(PDOException $e) { |
|
2275 | + } catch (PDOException $e) { |
|
2276 | 2276 | return "error : ".$e->getMessage(); |
2277 | 2277 | } |
2278 | 2278 | } |
2279 | 2279 | if (!isset($lastyearupdate)) { |
2280 | 2280 | echo 'Insert last stats update date...'."\n"; |
2281 | 2281 | date_default_timezone_set('UTC'); |
2282 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
2282 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
2283 | 2283 | } |
2284 | 2284 | if ($globalStatsResetYear) { |
2285 | 2285 | require_once(dirname(__FILE__).'/../install/class.settings.php'); |