@@ -7,13 +7,13 @@ |
||
7 | 7 | |
8 | 8 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
9 | 9 | if ($airline_icao == 'all') { |
10 | - unset($_COOKIE['stats_airline_icao']); |
|
11 | - setcookie('stats_airline_icao', '', time()-3600); |
|
12 | - $airline_icao = ''; |
|
10 | + unset($_COOKIE['stats_airline_icao']); |
|
11 | + setcookie('stats_airline_icao', '', time()-3600); |
|
12 | + $airline_icao = ''; |
|
13 | 13 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
14 | - $airline_icao = $_COOKIE['stats_airline_icao']; |
|
14 | + $airline_icao = $_COOKIE['stats_airline_icao']; |
|
15 | 15 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
16 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
16 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
17 | 17 | } |
18 | 18 | setcookie('stats_airline_icao',$airline_icao); |
19 | 19 |
@@ -7,13 +7,13 @@ |
||
7 | 7 | |
8 | 8 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
9 | 9 | if ($airline_icao == 'all') { |
10 | - unset($_COOKIE['stats_airline_icao']); |
|
11 | - setcookie('stats_airline_icao', '', time()-3600); |
|
12 | - $airline_icao = ''; |
|
10 | + unset($_COOKIE['stats_airline_icao']); |
|
11 | + setcookie('stats_airline_icao', '', time()-3600); |
|
12 | + $airline_icao = ''; |
|
13 | 13 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
14 | - $airline_icao = $_COOKIE['stats_airline_icao']; |
|
14 | + $airline_icao = $_COOKIE['stats_airline_icao']; |
|
15 | 15 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
16 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
16 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
17 | 17 | } |
18 | 18 | setcookie('stats_airline_icao',$airline_icao); |
19 | 19 |
@@ -7,91 +7,91 @@ discard block |
||
7 | 7 | |
8 | 8 | |
9 | 9 | class Translation { |
10 | - public $db; |
|
11 | - public function __construct($dbc = null) { |
|
12 | - $Connection = new Connection($dbc); |
|
13 | - $this->db = $Connection->db(); |
|
14 | - } |
|
10 | + public $db; |
|
11 | + public function __construct($dbc = null) { |
|
12 | + $Connection = new Connection($dbc); |
|
13 | + $this->db = $Connection->db(); |
|
14 | + } |
|
15 | 15 | |
16 | - /** |
|
17 | - * Change IATA to ICAO value for ident |
|
18 | - * |
|
19 | - * @param String $ident ident |
|
20 | - * @return String the icao |
|
21 | - */ |
|
22 | - public function ident2icao($ident) { |
|
16 | + /** |
|
17 | + * Change IATA to ICAO value for ident |
|
18 | + * |
|
19 | + * @param String $ident ident |
|
20 | + * @return String the icao |
|
21 | + */ |
|
22 | + public function ident2icao($ident) { |
|
23 | 23 | $Spotter = new Spotter(); |
24 | 24 | if (!is_numeric(substr($ident, 0, 3))) |
25 | - { |
|
26 | - if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { |
|
27 | - $airline_icao = substr($ident, 0, 2); |
|
28 | - } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
|
29 | - //$airline_icao = substr($ident, 0, 3); |
|
30 | - return $ident; |
|
31 | - } else return $ident; |
|
32 | - } else return $ident; |
|
33 | - if ($airline_icao == 'AF') { |
|
34 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
35 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
36 | - } else { |
|
37 | - $identicao = $Spotter->getAllAirlineInfo($airline_icao); |
|
38 | - if (isset($identicao[0])) { |
|
39 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
40 | - } else $icao = $ident; |
|
41 | - } |
|
42 | - return $icao; |
|
43 | - } |
|
25 | + { |
|
26 | + if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { |
|
27 | + $airline_icao = substr($ident, 0, 2); |
|
28 | + } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
|
29 | + //$airline_icao = substr($ident, 0, 3); |
|
30 | + return $ident; |
|
31 | + } else return $ident; |
|
32 | + } else return $ident; |
|
33 | + if ($airline_icao == 'AF') { |
|
34 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
35 | + else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
36 | + } else { |
|
37 | + $identicao = $Spotter->getAllAirlineInfo($airline_icao); |
|
38 | + if (isset($identicao[0])) { |
|
39 | + $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
40 | + } else $icao = $ident; |
|
41 | + } |
|
42 | + return $icao; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - public function getOperator($ident) { |
|
47 | - $query = "SELECT * FROM translation WHERE Operator = :ident LIMIT 1"; |
|
48 | - $query_values = array(':ident' => $ident); |
|
49 | - try { |
|
50 | - $sth = $this->db->prepare($query); |
|
51 | - $sth->execute($query_values); |
|
52 | - } catch(PDOException $e) { |
|
53 | - return "error : ".$e->getMessage(); |
|
54 | - } |
|
55 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
56 | - $sth->closeCursor(); |
|
57 | - if (count($row) > 0) { |
|
58 | - return $row['operator_correct']; |
|
59 | - } else return $ident; |
|
60 | - } |
|
46 | + public function getOperator($ident) { |
|
47 | + $query = "SELECT * FROM translation WHERE Operator = :ident LIMIT 1"; |
|
48 | + $query_values = array(':ident' => $ident); |
|
49 | + try { |
|
50 | + $sth = $this->db->prepare($query); |
|
51 | + $sth->execute($query_values); |
|
52 | + } catch(PDOException $e) { |
|
53 | + return "error : ".$e->getMessage(); |
|
54 | + } |
|
55 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
56 | + $sth->closeCursor(); |
|
57 | + if (count($row) > 0) { |
|
58 | + return $row['operator_correct']; |
|
59 | + } else return $ident; |
|
60 | + } |
|
61 | 61 | |
62 | - public function addOperator($ident,$correct_ident,$source) { |
|
63 | - $query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)"; |
|
64 | - $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source); |
|
65 | - try { |
|
66 | - $sth = $this->db->prepare($query); |
|
67 | - $sth->execute($query_values); |
|
68 | - } catch(PDOException $e) { |
|
69 | - return "error : ".$e->getMessage(); |
|
70 | - } |
|
71 | - } |
|
62 | + public function addOperator($ident,$correct_ident,$source) { |
|
63 | + $query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)"; |
|
64 | + $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source); |
|
65 | + try { |
|
66 | + $sth = $this->db->prepare($query); |
|
67 | + $sth->execute($query_values); |
|
68 | + } catch(PDOException $e) { |
|
69 | + return "error : ".$e->getMessage(); |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - public function updateOperator($ident,$correct_ident,$source) { |
|
74 | - $query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident"; |
|
75 | - $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source); |
|
76 | - try { |
|
77 | - $sth = $this->db->prepare($query); |
|
78 | - $sth->execute($query_values); |
|
79 | - } catch(PDOException $e) { |
|
80 | - return "error : ".$e->getMessage(); |
|
81 | - } |
|
82 | - } |
|
73 | + public function updateOperator($ident,$correct_ident,$source) { |
|
74 | + $query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident"; |
|
75 | + $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source); |
|
76 | + try { |
|
77 | + $sth = $this->db->prepare($query); |
|
78 | + $sth->execute($query_values); |
|
79 | + } catch(PDOException $e) { |
|
80 | + return "error : ".$e->getMessage(); |
|
81 | + } |
|
82 | + } |
|
83 | 83 | |
84 | - public function checkTranslation($ident,$web = false) { |
|
85 | - global $globalTranslationSources, $globalTranslationFetch; |
|
86 | - //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder'); |
|
87 | - $globalTranslationSources = array(); |
|
88 | - if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE; |
|
89 | - //echo "Check Translation for ".$ident."..."; |
|
90 | - $correct = $this->getOperator($ident); |
|
91 | - if ($correct != '' && $correct != $ident) { |
|
92 | - //echo "Found in DB !\n"; |
|
93 | - return $correct; |
|
94 | - } /* |
|
84 | + public function checkTranslation($ident,$web = false) { |
|
85 | + global $globalTranslationSources, $globalTranslationFetch; |
|
86 | + //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder'); |
|
87 | + $globalTranslationSources = array(); |
|
88 | + if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE; |
|
89 | + //echo "Check Translation for ".$ident."..."; |
|
90 | + $correct = $this->getOperator($ident); |
|
91 | + if ($correct != '' && $correct != $ident) { |
|
92 | + //echo "Found in DB !\n"; |
|
93 | + return $correct; |
|
94 | + } /* |
|
95 | 95 | elseif ($web && $globalTranslationFetch) { |
96 | 96 | if (! is_numeric(substr($ident,-4))) { |
97 | 97 | if (count($globalTranslationSources) > 0) { |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | } |
109 | 109 | } |
110 | 110 | */ |
111 | - return $this->ident2icao($ident); |
|
112 | - } |
|
111 | + return $this->ident2icao($ident); |
|
112 | + } |
|
113 | 113 | |
114 | 114 | /* |
115 | 115 | function fromPlanefinder($icao) { |
@@ -7,18 +7,18 @@ discard block |
||
7 | 7 | public $latest_schema = 26; |
8 | 8 | |
9 | 9 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
10 | - global $globalDBdriver; |
|
11 | - if ($dbc === null) { |
|
10 | + global $globalDBdriver; |
|
11 | + if ($dbc === null) { |
|
12 | 12 | if ($this->db === null && $dbname === null) { |
13 | - if ($user === null && $pass === null) { |
|
13 | + if ($user === null && $pass === null) { |
|
14 | 14 | $this->createDBConnection(); |
15 | - } else { |
|
15 | + } else { |
|
16 | 16 | $this->createDBConnection(null,$user,$pass); |
17 | - } |
|
17 | + } |
|
18 | 18 | } else { |
19 | - $this->createDBConnection($dbname); |
|
19 | + $this->createDBConnection($dbname); |
|
20 | 20 | } |
21 | - } elseif ($dbname === null || $dbname === 'default') { |
|
21 | + } elseif ($dbname === null || $dbname === 'default') { |
|
22 | 22 | $this->db = $dbc; |
23 | 23 | if ($this->connectionExists() === false) { |
24 | 24 | /* |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | */ |
29 | 29 | $this->createDBConnection(); |
30 | 30 | } |
31 | - } else { |
|
31 | + } else { |
|
32 | 32 | //$this->connectionExists(); |
33 | 33 | $this->dbs[$dbname] = $dbc; |
34 | - } |
|
34 | + } |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function db() { |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | - * Creates the database connection |
|
51 | - * |
|
52 | - * @return Boolean of the database connection |
|
53 | - * |
|
54 | - */ |
|
50 | + * Creates the database connection |
|
51 | + * |
|
52 | + * @return Boolean of the database connection |
|
53 | + * |
|
54 | + */ |
|
55 | 55 | |
56 | 56 | public function createDBConnection($DBname = null, $user = null, $pass = null) |
57 | 57 | { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | return false; |
148 | 148 | } |
149 | 149 | if($results->rowCount()>0) { |
150 | - return true; |
|
150 | + return true; |
|
151 | 151 | } |
152 | 152 | else return false; |
153 | 153 | } |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | $sum = $sum->fetchColumn(0); |
165 | 165 | } else $sum = 0; |
166 | 166 | if (intval($sum) !== 2) { |
167 | - return false; |
|
167 | + return false; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | } catch(PDOException $e) { |
171 | 171 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
172 | - throw $e; |
|
173 | - } |
|
174 | - //echo 'error ! '.$e->getMessage(); |
|
172 | + throw $e; |
|
173 | + } |
|
174 | + //echo 'error ! '.$e->getMessage(); |
|
175 | 175 | return false; |
176 | 176 | } |
177 | 177 | return true; |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | $version = 0; |
269 | 269 | if ($this->tableExists('aircraft')) { |
270 | 270 | if (!$this->tableExists('config')) { |
271 | - $version = '1'; |
|
272 | - return $version; |
|
271 | + $version = '1'; |
|
272 | + return $version; |
|
273 | 273 | } else { |
274 | 274 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
275 | 275 | try { |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * @return Boolean if latest version or not |
290 | 290 | */ |
291 | 291 | public function latest() { |
292 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
293 | - else return false; |
|
292 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
293 | + else return false; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | } |
@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | print '<div class="select-item">'; |
22 | 22 | print '<form action="'.$globalURL.'/aircraft" method="post">'; |
23 | 23 | print '<select name="aircraft_type" class="selectpicker" data-live-search="true">'; |
24 | - print '<option></option>'; |
|
25 | - $Stats = new Stats(); |
|
26 | - $aircraft_types = $Stats->getAllAircraftTypes(); |
|
27 | - if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
28 | - foreach($aircraft_types as $aircrafttype) |
|
29 | - { |
|
30 | - if($aircraft_type == $aircrafttype['aircraft_icao']) |
|
31 | - { |
|
32 | - print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
|
33 | - } else { |
|
34 | - print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
|
35 | - } |
|
24 | + print '<option></option>'; |
|
25 | + $Stats = new Stats(); |
|
26 | + $aircraft_types = $Stats->getAllAircraftTypes(); |
|
27 | + if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
28 | + foreach($aircraft_types as $aircrafttype) |
|
29 | + { |
|
30 | + if($aircraft_type == $aircrafttype['aircraft_icao']) |
|
31 | + { |
|
32 | + print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
|
33 | + } else { |
|
34 | + print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | print '</select>'; |
38 | 38 | print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>'; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | function drawChart() { |
65 | 65 | var data = google.visualization.arrayToDataTable([ |
66 | 66 | ["Country", "# of times"], '; |
67 | - $country_data = ''; |
|
67 | + $country_data = ''; |
|
68 | 68 | foreach($airline_array as $airline_item) |
69 | 69 | { |
70 | 70 | $country_data .= '[ "'.$airline_item['airline_country'].'",'.$airline_item['airline_country_count'].'],'; |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | print '<div class="select-item">'; |
43 | 43 | print '<form action="'.$globalURL.'/aircraft" method="post">'; |
44 | 44 | print '<select name="aircraft_type" class="selectpicker" data-live-search="true">'; |
45 | - print '<option></option>'; |
|
46 | - $Stats = new Stats(); |
|
45 | + print '<option></option>'; |
|
46 | + $Stats = new Stats(); |
|
47 | 47 | $aircraft_types = $Stats->getAllAircraftTypes(); |
48 | 48 | if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
49 | 49 | foreach($aircraft_types as $aircrafttype) |
@@ -54,20 +54,20 @@ discard block |
||
54 | 54 | } else { |
55 | 55 | print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_manufacturer'].' '.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>'; |
56 | 56 | } |
57 | - } |
|
58 | - print '</select>'; |
|
59 | - print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>'; |
|
57 | + } |
|
58 | + print '</select>'; |
|
59 | + print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>'; |
|
60 | 60 | print '</form>'; |
61 | 61 | print '</div>'; |
62 | 62 | |
63 | 63 | if ($aircraft_type != "NA") |
64 | 64 | { |
65 | - print '<div class="info column">'; |
|
66 | - print '<h1>'.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')</h1>'; |
|
67 | - print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['aircraft_name'].'</div>'; |
|
68 | - print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['aircraft_type'].'</div>'; |
|
69 | - if (isset($spotter_array[0]['aircraft_manufacturer'])) print '<div><span class="label">'._("Manufacturer").'</span><a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $spotter_array[0]['aircraft_manufacturer'])).'">'.$spotter_array[0]['aircraft_manufacturer'].'</a></div>'; |
|
70 | - print '</div>'; |
|
65 | + print '<div class="info column">'; |
|
66 | + print '<h1>'.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')</h1>'; |
|
67 | + print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['aircraft_name'].'</div>'; |
|
68 | + print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['aircraft_type'].'</div>'; |
|
69 | + if (isset($spotter_array[0]['aircraft_manufacturer'])) print '<div><span class="label">'._("Manufacturer").'</span><a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $spotter_array[0]['aircraft_manufacturer'])).'">'.$spotter_array[0]['aircraft_manufacturer'].'</a></div>'; |
|
70 | + print '</div>'; |
|
71 | 71 | } else { |
72 | 72 | print '<div class="alert alert-warning">'._("This special aircraft profile shows all flights in where the aircraft type is unknown.").'</div>'; |
73 | 73 | } |
@@ -7,109 +7,109 @@ discard block |
||
7 | 7 | public $db; |
8 | 8 | |
9 | 9 | protected $texts = Array( |
10 | - 'MI' => 'Shallow', |
|
11 | - 'PR' => 'Partial', |
|
12 | - 'BC' => 'Low drifting', |
|
13 | - 'BL' => 'Blowing', |
|
14 | - 'SH' => 'Showers', |
|
15 | - 'TS' => 'Thunderstorm', |
|
16 | - 'FZ' => 'Freezing', |
|
17 | - 'DZ' => 'Drizzle', |
|
18 | - 'RA' => 'Rain', |
|
19 | - 'SN' => 'Snow', |
|
20 | - 'SG' => 'Snow Grains', |
|
21 | - 'IC' => 'Ice crystals', |
|
22 | - 'PL' => 'Ice pellets', |
|
23 | - 'GR' => 'Hail', |
|
24 | - 'GS' => 'Small hail', |
|
25 | - 'UP' => 'Unknown', |
|
26 | - 'BR' => 'Mist', |
|
27 | - 'FG' => 'Fog', |
|
28 | - 'FU' => 'Smoke', |
|
29 | - 'VA' => 'Volcanic ash', |
|
30 | - 'DU' => 'Widespread dust', |
|
31 | - 'SA' => 'Sand', |
|
32 | - 'HZ' => 'Haze', |
|
33 | - 'PY' => 'Spray', |
|
34 | - 'PO' => 'Well developed dust / sand whirls', |
|
35 | - 'SQ' => 'Squalls', |
|
36 | - 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
37 | - 'SS' => 'Sandstorm', |
|
38 | - 'DS' => 'Duststorm' |
|
10 | + 'MI' => 'Shallow', |
|
11 | + 'PR' => 'Partial', |
|
12 | + 'BC' => 'Low drifting', |
|
13 | + 'BL' => 'Blowing', |
|
14 | + 'SH' => 'Showers', |
|
15 | + 'TS' => 'Thunderstorm', |
|
16 | + 'FZ' => 'Freezing', |
|
17 | + 'DZ' => 'Drizzle', |
|
18 | + 'RA' => 'Rain', |
|
19 | + 'SN' => 'Snow', |
|
20 | + 'SG' => 'Snow Grains', |
|
21 | + 'IC' => 'Ice crystals', |
|
22 | + 'PL' => 'Ice pellets', |
|
23 | + 'GR' => 'Hail', |
|
24 | + 'GS' => 'Small hail', |
|
25 | + 'UP' => 'Unknown', |
|
26 | + 'BR' => 'Mist', |
|
27 | + 'FG' => 'Fog', |
|
28 | + 'FU' => 'Smoke', |
|
29 | + 'VA' => 'Volcanic ash', |
|
30 | + 'DU' => 'Widespread dust', |
|
31 | + 'SA' => 'Sand', |
|
32 | + 'HZ' => 'Haze', |
|
33 | + 'PY' => 'Spray', |
|
34 | + 'PO' => 'Well developed dust / sand whirls', |
|
35 | + 'SQ' => 'Squalls', |
|
36 | + 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
37 | + 'SS' => 'Sandstorm', |
|
38 | + 'DS' => 'Duststorm' |
|
39 | 39 | ); |
40 | 40 | |
41 | 41 | public function __construct($dbc = null) { |
42 | - $Connection = new Connection($dbc); |
|
43 | - $this->db = $Connection->db; |
|
44 | - } |
|
42 | + $Connection = new Connection($dbc); |
|
43 | + $this->db = $Connection->db; |
|
44 | + } |
|
45 | 45 | |
46 | - public static function check_last_update() { |
|
47 | - global $globalDBdriver; |
|
48 | - if ($globalDBdriver == 'mysql') { |
|
46 | + public static function check_last_update() { |
|
47 | + global $globalDBdriver; |
|
48 | + if ($globalDBdriver == 'mysql') { |
|
49 | 49 | $query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value > DATE_SUB(NOW(), INTERVAL 20 MINUTE)"; |
50 | 50 | } else { |
51 | 51 | $query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '20 MINUTES'"; |
52 | 52 | } |
53 | - try { |
|
54 | - $Connection = new Connection(); |
|
55 | - $sth = $Connection->db->prepare($query); |
|
56 | - $sth->execute(); |
|
57 | - } catch(PDOException $e) { |
|
58 | - return "error : ".$e->getMessage(); |
|
59 | - } |
|
60 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
61 | - $sth->closeCursor(); |
|
62 | - if ($row['nb'] > 0) return false; |
|
63 | - else return true; |
|
64 | - } |
|
53 | + try { |
|
54 | + $Connection = new Connection(); |
|
55 | + $sth = $Connection->db->prepare($query); |
|
56 | + $sth->execute(); |
|
57 | + } catch(PDOException $e) { |
|
58 | + return "error : ".$e->getMessage(); |
|
59 | + } |
|
60 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
61 | + $sth->closeCursor(); |
|
62 | + if ($row['nb'] > 0) return false; |
|
63 | + else return true; |
|
64 | + } |
|
65 | 65 | |
66 | - public static function insert_last_update() { |
|
67 | - $query = "DELETE FROM config WHERE name = 'last_update_metar'; |
|
66 | + public static function insert_last_update() { |
|
67 | + $query = "DELETE FROM config WHERE name = 'last_update_metar'; |
|
68 | 68 | INSERT INTO config (name,value) VALUES ('last_update_metar',NOW());"; |
69 | - try { |
|
70 | - $Connection = new Connection(); |
|
71 | - $sth = $Connection->db->prepare($query); |
|
72 | - $sth->execute(); |
|
73 | - } catch(PDOException $e) { |
|
74 | - return "error : ".$e->getMessage(); |
|
75 | - } |
|
76 | - } |
|
69 | + try { |
|
70 | + $Connection = new Connection(); |
|
71 | + $sth = $Connection->db->prepare($query); |
|
72 | + $sth->execute(); |
|
73 | + } catch(PDOException $e) { |
|
74 | + return "error : ".$e->getMessage(); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | 79 | |
80 | - public function parse($data) { |
|
81 | - //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
|
82 | - $codes = implode('|', array_keys($this->texts)); |
|
83 | - $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
84 | - //$pieces = explode(' ',$data); |
|
85 | - $pieces = preg_split('/\s/',$data); |
|
86 | - $pos = 0; |
|
87 | - if ($pieces[0] == 'METAR') $pos++; |
|
88 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
89 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
90 | - $result = array(); |
|
91 | - $result['location'] = $pieces[$pos]; |
|
92 | - $pos++; |
|
93 | - $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
94 | - $result['time'] = substr($pieces[$pos],2,4); |
|
95 | - $c = count($pieces); |
|
96 | - for($pos++; $pos < $c; $pos++) { |
|
97 | - $piece = $pieces[$pos]; |
|
98 | - if ($piece == 'RMK') break; |
|
99 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
100 | - if ($piece == 'COR') $result['correction'] = true; |
|
101 | - // Wind Speed |
|
102 | - if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
|
103 | - $result['wind']['direction'] = (float)$matches[1]; |
|
80 | + public function parse($data) { |
|
81 | + //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
|
82 | + $codes = implode('|', array_keys($this->texts)); |
|
83 | + $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
84 | + //$pieces = explode(' ',$data); |
|
85 | + $pieces = preg_split('/\s/',$data); |
|
86 | + $pos = 0; |
|
87 | + if ($pieces[0] == 'METAR') $pos++; |
|
88 | + elseif ($pieces[0] == 'SPECI') $pos++; |
|
89 | + if (strlen($pieces[$pos]) != 4) $pos++; |
|
90 | + $result = array(); |
|
91 | + $result['location'] = $pieces[$pos]; |
|
92 | + $pos++; |
|
93 | + $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
94 | + $result['time'] = substr($pieces[$pos],2,4); |
|
95 | + $c = count($pieces); |
|
96 | + for($pos++; $pos < $c; $pos++) { |
|
97 | + $piece = $pieces[$pos]; |
|
98 | + if ($piece == 'RMK') break; |
|
99 | + if ($piece == 'AUTO') $result['auto'] = true; |
|
100 | + if ($piece == 'COR') $result['correction'] = true; |
|
101 | + // Wind Speed |
|
102 | + if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
|
103 | + $result['wind']['direction'] = (float)$matches[1]; |
|
104 | 104 | $result['wind']['unit'] = $matches[4]; |
105 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
105 | + if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | + elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | + elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
108 | 108 | $result['wind']['gust'] = (float)$matches[3]; |
109 | 109 | $result['wind']['unit'] = $matches[4]; |
110 | 110 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
111 | 111 | $result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0; |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | 114 | /* if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) { |
115 | 115 | $result['wind_direction'] = (float)$matches[1]; |
@@ -126,35 +126,35 @@ discard block |
||
126 | 126 | } |
127 | 127 | } |
128 | 128 | */ |
129 | - // Temperature |
|
130 | - if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
|
131 | - $temp = (float)$matches[1]; |
|
129 | + // Temperature |
|
130 | + if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
|
131 | + $temp = (float)$matches[1]; |
|
132 | 132 | if ($matches[1]{0} == 'M') { |
133 | 133 | $temp = ((float)substr($matches[1], 1)) * -1; |
134 | 134 | } |
135 | - $result['temperature'] = $temp; |
|
136 | - $dew = (float)$matches[2]; |
|
135 | + $result['temperature'] = $temp; |
|
136 | + $dew = (float)$matches[2]; |
|
137 | 137 | if ($matches[2]{0} == 'M') { |
138 | 138 | $dew = ((float)substr($matches[2], 1)) * -1; |
139 | 139 | } |
140 | 140 | $result['dew'] = $dew; |
141 | - } |
|
142 | - // QNH |
|
143 | - if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) { |
|
144 | - // #^(Q|A)(////|[0-9]{4})( )# |
|
145 | - if ($matches[1] == 'Q') { |
|
146 | - // hPa |
|
147 | - $result['QNH'] = $matches[2]; |
|
148 | - } else { |
|
149 | - // inHg |
|
150 | - $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
151 | 141 | } |
152 | - /* |
|
142 | + // QNH |
|
143 | + if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) { |
|
144 | + // #^(Q|A)(////|[0-9]{4})( )# |
|
145 | + if ($matches[1] == 'Q') { |
|
146 | + // hPa |
|
147 | + $result['QNH'] = $matches[2]; |
|
148 | + } else { |
|
149 | + // inHg |
|
150 | + $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
151 | + } |
|
152 | + /* |
|
153 | 153 | $result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100); |
154 | 154 | $result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg'; |
155 | 155 | */ |
156 | - } |
|
157 | - /* |
|
156 | + } |
|
157 | + /* |
|
158 | 158 | // Wind Direction |
159 | 159 | if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) { |
160 | 160 | $result['wind_direction'] = $matches[1]; |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | $result['speed_variable'] = $matches[1]; |
166 | 166 | } |
167 | 167 | */ |
168 | - // Visibility |
|
169 | - if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
|
170 | - if (isset($matches[3]) && strlen($matches[3]) > 0) { |
|
168 | + // Visibility |
|
169 | + if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
|
170 | + if (isset($matches[3]) && strlen($matches[3]) > 0) { |
|
171 | 171 | $result['visibility'] = (float)$matches[3] * 1609.34; |
172 | 172 | } else { |
173 | 173 | if ($matches[1] == '9999') { |
@@ -180,28 +180,28 @@ discard block |
||
180 | 180 | $result['visibility'] = '> 10000'; |
181 | 181 | $result['weather'] = "CAVOK"; |
182 | 182 | } |
183 | - } |
|
184 | - // Cloud Coverage |
|
185 | - if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) { |
|
186 | - //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
|
187 | - $type = $matches[1]; |
|
188 | - $cloud = array(); |
|
189 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
190 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
191 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
192 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
193 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
194 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
195 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
196 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
197 | - $cloud['type_code'] = $type; |
|
198 | - $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
199 | - $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
|
200 | - $result['cloud'][] = $cloud; |
|
201 | - } |
|
202 | - // RVR |
|
203 | - if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) { |
|
204 | - $rvr = array(); |
|
183 | + } |
|
184 | + // Cloud Coverage |
|
185 | + if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) { |
|
186 | + //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
|
187 | + $type = $matches[1]; |
|
188 | + $cloud = array(); |
|
189 | + if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
190 | + elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
191 | + elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
192 | + elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
193 | + elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
194 | + elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
195 | + elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
196 | + elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
197 | + $cloud['type_code'] = $type; |
|
198 | + $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
199 | + $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
|
200 | + $result['cloud'][] = $cloud; |
|
201 | + } |
|
202 | + // RVR |
|
203 | + if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) { |
|
204 | + $rvr = array(); |
|
205 | 205 | $rvr['runway'] = $matches[1]; |
206 | 206 | $rvr['assessment'] = $matches[2]; |
207 | 207 | $rvr['rvr'] = $matches[3]; |
@@ -210,33 +210,33 @@ discard block |
||
210 | 210 | $result['RVR'] = $rvr; |
211 | 211 | } |
212 | 212 | |
213 | - //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
214 | - if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) { |
|
215 | - //print_r($matches); |
|
216 | - // https://github.com/davidmegginson/metar-taf/blob/master/Metar.php |
|
217 | - $result['RVR']['runway'] = $matches[1]; |
|
218 | - $result['RVR']['deposits'] = $matches[2]; |
|
219 | - $result['RVR']['extent'] = $matches[3]; |
|
220 | - $result['RVR']['depth'] = $matches[4]; |
|
221 | - $result['RVR']['friction'] = $matches[5]; |
|
222 | - } |
|
223 | - if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
224 | - //echo $piece; |
|
225 | - //print_r($matches); |
|
226 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
213 | + //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
214 | + if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) { |
|
215 | + //print_r($matches); |
|
216 | + // https://github.com/davidmegginson/metar-taf/blob/master/Metar.php |
|
217 | + $result['RVR']['runway'] = $matches[1]; |
|
218 | + $result['RVR']['deposits'] = $matches[2]; |
|
219 | + $result['RVR']['extent'] = $matches[3]; |
|
220 | + $result['RVR']['depth'] = $matches[4]; |
|
221 | + $result['RVR']['friction'] = $matches[5]; |
|
222 | + } |
|
223 | + if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
224 | + //echo $piece; |
|
225 | + //print_r($matches); |
|
226 | + if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | + else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
228 | 228 | if (isset($matches[3])) { |
229 | 229 | $range = Array( |
230 | - 'from' => (float)$matches[2], |
|
231 | - 'to' => (float)$matches[4], |
|
232 | - 'unit' => $matches[5] ? 'FT' : 'M' |
|
230 | + 'from' => (float)$matches[2], |
|
231 | + 'to' => (float)$matches[4], |
|
232 | + 'unit' => $matches[5] ? 'FT' : 'M' |
|
233 | 233 | ); |
234 | 234 | } |
235 | 235 | $result['RVR'] = $matches[1]; |
236 | 236 | $result['RVR_range'] = $range; |
237 | - } |
|
238 | - // Weather |
|
239 | - if (preg_match($regWeather, $piece, $matches)) { |
|
237 | + } |
|
238 | + // Weather |
|
239 | + if (preg_match($regWeather, $piece, $matches)) { |
|
240 | 240 | $text = Array(); |
241 | 241 | switch ($matches[1]) { |
242 | 242 | case '+': |
@@ -259,35 +259,35 @@ discard block |
||
259 | 259 | } |
260 | 260 | if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
261 | 261 | else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
262 | - } |
|
263 | - } |
|
264 | - return $result; |
|
262 | + } |
|
263 | + } |
|
264 | + return $result; |
|
265 | 265 | |
266 | - } |
|
266 | + } |
|
267 | 267 | |
268 | 268 | public function getMETAR($icao) { |
269 | - global $globalMETARcycle, $globalDBdriver; |
|
270 | - if (isset($globalMETARcycle) && $globalMETARcycle) { |
|
271 | - $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
|
272 | - } else { |
|
273 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
274 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
275 | - } |
|
276 | - $query_values = array(':icao' => $icao); |
|
277 | - try { |
|
278 | - $sth = $this->db->prepare($query); |
|
279 | - $sth->execute($query_values); |
|
280 | - } catch(PDOException $e) { |
|
281 | - return "error : ".$e->getMessage(); |
|
282 | - } |
|
283 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
284 | - if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) { |
|
285 | - $all = $this->downloadMETAR($icao); |
|
286 | - } |
|
287 | - return $all; |
|
288 | - } |
|
269 | + global $globalMETARcycle, $globalDBdriver; |
|
270 | + if (isset($globalMETARcycle) && $globalMETARcycle) { |
|
271 | + $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
|
272 | + } else { |
|
273 | + if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
274 | + else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
275 | + } |
|
276 | + $query_values = array(':icao' => $icao); |
|
277 | + try { |
|
278 | + $sth = $this->db->prepare($query); |
|
279 | + $sth->execute($query_values); |
|
280 | + } catch(PDOException $e) { |
|
281 | + return "error : ".$e->getMessage(); |
|
282 | + } |
|
283 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
284 | + if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) { |
|
285 | + $all = $this->downloadMETAR($icao); |
|
286 | + } |
|
287 | + return $all; |
|
288 | + } |
|
289 | 289 | |
290 | - public function addMETAR($location,$metar,$date) { |
|
290 | + public function addMETAR($location,$metar,$date) { |
|
291 | 291 | global $globalDBdriver; |
292 | 292 | $date = date('Y-m-d H:i:s',strtotime($date)); |
293 | 293 | if ($globalDBdriver == 'mysql') { |
@@ -295,100 +295,100 @@ discard block |
||
295 | 295 | } else { |
296 | 296 | $query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);"; |
297 | 297 | } |
298 | - $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
299 | - try { |
|
300 | - $sth = $this->db->prepare($query); |
|
301 | - $sth->execute($query_values); |
|
302 | - } catch(PDOException $e) { |
|
303 | - return "error : ".$e->getMessage(); |
|
304 | - } |
|
305 | - } |
|
298 | + $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
299 | + try { |
|
300 | + $sth = $this->db->prepare($query); |
|
301 | + $sth->execute($query_values); |
|
302 | + } catch(PDOException $e) { |
|
303 | + return "error : ".$e->getMessage(); |
|
304 | + } |
|
305 | + } |
|
306 | 306 | |
307 | - public function deleteMETAR($id) { |
|
308 | - $query = "DELETE FROM metar WHERE id = :id"; |
|
309 | - $query_values = array(':id' => $id); |
|
310 | - try { |
|
311 | - $sth = $this->db->prepare($query); |
|
312 | - $sth->execute($query_values); |
|
313 | - } catch(PDOException $e) { |
|
314 | - return "error : ".$e->getMessage(); |
|
315 | - } |
|
316 | - } |
|
317 | - public function deleteAllMETARLocation() { |
|
318 | - $query = "DELETE FROM metar"; |
|
319 | - try { |
|
320 | - $sth = $this->db->prepare($query); |
|
321 | - $sth->execute(); |
|
322 | - } catch(PDOException $e) { |
|
323 | - return "error : ".$e->getMessage(); |
|
324 | - } |
|
325 | - } |
|
307 | + public function deleteMETAR($id) { |
|
308 | + $query = "DELETE FROM metar WHERE id = :id"; |
|
309 | + $query_values = array(':id' => $id); |
|
310 | + try { |
|
311 | + $sth = $this->db->prepare($query); |
|
312 | + $sth->execute($query_values); |
|
313 | + } catch(PDOException $e) { |
|
314 | + return "error : ".$e->getMessage(); |
|
315 | + } |
|
316 | + } |
|
317 | + public function deleteAllMETARLocation() { |
|
318 | + $query = "DELETE FROM metar"; |
|
319 | + try { |
|
320 | + $sth = $this->db->prepare($query); |
|
321 | + $sth->execute(); |
|
322 | + } catch(PDOException $e) { |
|
323 | + return "error : ".$e->getMessage(); |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | - public function addMETARCycle() { |
|
328 | - global $globalDebug, $globalIVAO; |
|
329 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
330 | - date_default_timezone_set("UTC"); |
|
331 | - $Common = new Common(); |
|
332 | - if (isset($globalIVAO) && $globalIVAO) { |
|
333 | - $cycle = $Common->getData('http://wx.ivao.aero/metar.php'); |
|
334 | - } else { |
|
327 | + public function addMETARCycle() { |
|
328 | + global $globalDebug, $globalIVAO; |
|
329 | + if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
330 | + date_default_timezone_set("UTC"); |
|
331 | + $Common = new Common(); |
|
332 | + if (isset($globalIVAO) && $globalIVAO) { |
|
333 | + $cycle = $Common->getData('http://wx.ivao.aero/metar.php'); |
|
334 | + } else { |
|
335 | 335 | $cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT'); |
336 | - } |
|
337 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
338 | - $date = ''; |
|
339 | - foreach(explode("\n",$cycle) as $line) { |
|
340 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
341 | - //echo "date : ".$line."\n"; |
|
342 | - $date = $line; |
|
343 | - } |
|
344 | - if ($line != '') { |
|
345 | - //$this->parse($line); |
|
346 | - //echo $line; |
|
347 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
348 | - $pos = 0; |
|
349 | - $pieces = preg_split('/\s/',$line); |
|
350 | - if ($pieces[0] == 'METAR') $pos++; |
|
351 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
352 | - $location = $pieces[$pos]; |
|
353 | - echo $this->addMETAR($location,$line,$date); |
|
354 | - } |
|
355 | - //echo $line."\n"; |
|
356 | - } |
|
357 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
336 | + } |
|
337 | + if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
338 | + $date = ''; |
|
339 | + foreach(explode("\n",$cycle) as $line) { |
|
340 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
341 | + //echo "date : ".$line."\n"; |
|
342 | + $date = $line; |
|
343 | + } |
|
344 | + if ($line != '') { |
|
345 | + //$this->parse($line); |
|
346 | + //echo $line; |
|
347 | + if ($date == '') $date = date('Y/m/d H:m'); |
|
348 | + $pos = 0; |
|
349 | + $pieces = preg_split('/\s/',$line); |
|
350 | + if ($pieces[0] == 'METAR') $pos++; |
|
351 | + if (strlen($pieces[$pos]) != 4) $pos++; |
|
352 | + $location = $pieces[$pos]; |
|
353 | + echo $this->addMETAR($location,$line,$date); |
|
354 | + } |
|
355 | + //echo $line."\n"; |
|
356 | + } |
|
357 | + if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
358 | 358 | |
359 | - } |
|
360 | - public function downloadMETAR($icao) { |
|
361 | - global $globalMETARurl; |
|
362 | - if ($globalMETARurl == '') return array(); |
|
363 | - date_default_timezone_set("UTC"); |
|
364 | - $Common = new Common(); |
|
365 | - $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
366 | - $cycle = $Common->getData($url); |
|
367 | - $date = ''; |
|
368 | - foreach(explode("\n",$cycle) as $line) { |
|
369 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
370 | - //echo "date : ".$line."\n"; |
|
371 | - $date = $line; |
|
372 | - } |
|
373 | - if ($line != '') { |
|
374 | - //$this->parse($line); |
|
375 | - //echo $line; |
|
376 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
377 | - $pos = 0; |
|
378 | - $pieces = preg_split('/\s/',$line); |
|
379 | - if ($pieces[0] == 'METAR') $pos++; |
|
380 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
381 | - $location = $pieces[$pos]; |
|
382 | - if (strlen($location == 4)) { |
|
383 | - $this->addMETAR($location,$line,$date); |
|
384 | - return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
|
385 | - } else return array(); |
|
386 | - } |
|
387 | - //echo $line."\n"; |
|
388 | - } |
|
389 | - return array(); |
|
359 | + } |
|
360 | + public function downloadMETAR($icao) { |
|
361 | + global $globalMETARurl; |
|
362 | + if ($globalMETARurl == '') return array(); |
|
363 | + date_default_timezone_set("UTC"); |
|
364 | + $Common = new Common(); |
|
365 | + $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
366 | + $cycle = $Common->getData($url); |
|
367 | + $date = ''; |
|
368 | + foreach(explode("\n",$cycle) as $line) { |
|
369 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
370 | + //echo "date : ".$line."\n"; |
|
371 | + $date = $line; |
|
372 | + } |
|
373 | + if ($line != '') { |
|
374 | + //$this->parse($line); |
|
375 | + //echo $line; |
|
376 | + if ($date == '') $date = date('Y/m/d H:m'); |
|
377 | + $pos = 0; |
|
378 | + $pieces = preg_split('/\s/',$line); |
|
379 | + if ($pieces[0] == 'METAR') $pos++; |
|
380 | + if (strlen($pieces[$pos]) != 4) $pos++; |
|
381 | + $location = $pieces[$pos]; |
|
382 | + if (strlen($location == 4)) { |
|
383 | + $this->addMETAR($location,$line,$date); |
|
384 | + return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
|
385 | + } else return array(); |
|
386 | + } |
|
387 | + //echo $line."\n"; |
|
388 | + } |
|
389 | + return array(); |
|
390 | 390 | |
391 | - } |
|
391 | + } |
|
392 | 392 | } |
393 | 393 | /* |
394 | 394 | $METAR = new METAR(); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | // When button "Remove all filters" is clicked |
29 | 29 | if (isset($_POST['removefilters'])) { |
30 | 30 | $allfilters = array_filter(array_keys($_COOKIE),function($key) { |
31 | - return strpos($key,'filter_') === 0; |
|
31 | + return strpos($key,'filter_') === 0; |
|
32 | 32 | }); |
33 | 33 | foreach ($allfilters as $filt) { |
34 | 34 | unset($_COOKIE[$filt]); |
@@ -167,16 +167,16 @@ discard block |
||
167 | 167 | } |
168 | 168 | ?> |
169 | 169 | <?php |
170 | - if (isset($_POST['archive'])) { |
|
170 | + if (isset($_POST['archive'])) { |
|
171 | 171 | ?> |
172 | 172 | <?php |
173 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
173 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
174 | 174 | ?> |
175 | 175 | |
176 | 176 | <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script> |
177 | 177 | <?php |
178 | - } |
|
179 | - } else { |
|
178 | + } |
|
179 | + } else { |
|
180 | 180 | ?> |
181 | 181 | <?php |
182 | 182 | /* if (isset($globalBeta) && $globalBeta) { |
@@ -188,18 +188,18 @@ discard block |
||
188 | 188 | */ |
189 | 189 | ?> |
190 | 190 | <?php |
191 | - if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
191 | + if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) { |
|
192 | 192 | ?> |
193 | 193 | <script src="<?php print $globalURL; ?>/js/leaflet-playback.js"></script> |
194 | 194 | <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>"></script> |
195 | 195 | <?php |
196 | - } |
|
196 | + } |
|
197 | 197 | ?> |
198 | 198 | <?php |
199 | 199 | // } |
200 | 200 | ?> |
201 | 201 | <?php |
202 | - } |
|
202 | + } |
|
203 | 203 | } |
204 | 204 | ?> |
205 | 205 | <?php |
@@ -359,23 +359,23 @@ discard block |
||
359 | 359 | <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li> |
360 | 360 | <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li> |
361 | 361 | <?php |
362 | - if ($globalACARS) { |
|
363 | - if (isset($globalDemo) && $globalDemo) { |
|
364 | - ?> |
|
362 | + if ($globalACARS) { |
|
363 | + if (isset($globalDemo) && $globalDemo) { |
|
364 | + ?> |
|
365 | 365 | <li><hr /></li> |
366 | 366 | <li><i><?php echo _('ACARS data not available publicly'); ?></i></li> |
367 | 367 | <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li> |
368 | 368 | <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li> |
369 | 369 | <?php |
370 | - } else { |
|
371 | - ?> |
|
370 | + } else { |
|
371 | + ?> |
|
372 | 372 | <li><hr /></li> |
373 | 373 | <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li> |
374 | 374 | <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li> |
375 | 375 | <?php |
376 | - } |
|
377 | - } |
|
378 | - ?> |
|
376 | + } |
|
377 | + } |
|
378 | + ?> |
|
379 | 379 | <li><hr /></li> |
380 | 380 | <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li> |
381 | 381 | <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li> |
@@ -417,14 +417,14 @@ discard block |
||
417 | 417 | <form> |
418 | 418 | <select class="selectpicker" data-width="120px" onchange="language(this);"> |
419 | 419 | <?php |
420 | - $Language = new Language(); |
|
421 | - $alllang = $Language->getLanguages(); |
|
422 | - foreach ($alllang as $key => $lang) { |
|
423 | - print '<option value="'.$key.'"'; |
|
424 | - if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
425 | - print '>'.$lang[0].'</option>'; |
|
426 | - } |
|
427 | - ?> |
|
420 | + $Language = new Language(); |
|
421 | + $alllang = $Language->getLanguages(); |
|
422 | + foreach ($alllang as $key => $lang) { |
|
423 | + print '<option value="'.$key.'"'; |
|
424 | + if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected '; |
|
425 | + print '>'.$lang[0].'</option>'; |
|
426 | + } |
|
427 | + ?> |
|
428 | 428 | </select> |
429 | 429 | </form> |
430 | 430 | </div> |
@@ -455,18 +455,18 @@ discard block |
||
455 | 455 | ?> |
456 | 456 | <div class="top-header clear" role="main"> |
457 | 457 | <?php |
458 | - if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) { |
|
458 | + if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) { |
|
459 | 459 | ?> |
460 | 460 | <div id="archive-map"></div> |
461 | 461 | <?php |
462 | - } |
|
462 | + } |
|
463 | 463 | ?> |
464 | 464 | </div> |
465 | 465 | <?php |
466 | 466 | } |
467 | 467 | if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false)) |
468 | 468 | { |
469 | - ?> |
|
469 | + ?> |
|
470 | 470 | <div class="top-header clear" role="main"> |
471 | 471 | <div id="map"></div> |
472 | 472 | <link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" /> |
@@ -477,15 +477,15 @@ discard block |
||
477 | 477 | var zoom = 13; |
478 | 478 | //create the map |
479 | 479 | <?php |
480 | - if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
480 | + if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) { |
|
481 | 481 | ?> |
482 | 482 | map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom); |
483 | 483 | <?php |
484 | - } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
484 | + } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) { |
|
485 | 485 | ?> |
486 | 486 | map = L.map('map', { zoomControl:true }); |
487 | 487 | <?php |
488 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
488 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) { |
|
489 | 489 | ?> |
490 | 490 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]); |
491 | 491 | var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map); |
@@ -493,22 +493,22 @@ discard block |
||
493 | 493 | var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map); |
494 | 494 | var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map); |
495 | 495 | <?php |
496 | - } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
496 | + } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) { |
|
497 | 497 | ?> |
498 | 498 | map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]); |
499 | 499 | <?php |
500 | - } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
500 | + } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) { |
|
501 | 501 | ?> |
502 | 502 | map = L.map('map', { zoomControl:true }); |
503 | 503 | <?php |
504 | - } |
|
504 | + } |
|
505 | 505 | ?> |
506 | 506 | //initialize the layer group for the aircrft markers |
507 | 507 | var layer_data = L.layerGroup(); |
508 | 508 | |
509 | 509 | //a few title layers |
510 | 510 | <?php |
511 | - if ($globalMapProvider == 'Mapbox') { |
|
511 | + if ($globalMapProvider == 'Mapbox') { |
|
512 | 512 | ?> |
513 | 513 | L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', { |
514 | 514 | maxZoom: 18, |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | token : '<?php print $globalMapboxToken; ?>' |
520 | 520 | }).addTo(map); |
521 | 521 | <?php |
522 | - } elseif ($globalMapProvider == 'OpenStreetMap') { |
|
522 | + } elseif ($globalMapProvider == 'OpenStreetMap') { |
|
523 | 523 | ?> |
524 | 524 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
525 | 525 | maxZoom: 18, |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>' |
528 | 528 | }).addTo(map); |
529 | 529 | <?php |
530 | - } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
530 | + } elseif ($globalMapProvider == 'MapQuest-OSM') { |
|
531 | 531 | ?> |
532 | 532 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', { |
533 | 533 | maxZoom: 18, |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | 'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>' |
537 | 537 | }).addTo(map); |
538 | 538 | <?php |
539 | - } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
539 | + } elseif ($globalMapProvider == 'MapQuest-Aerial') { |
|
540 | 540 | ?> |
541 | 541 | L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', { |
542 | 542 | maxZoom: 18, |
@@ -545,27 +545,27 @@ discard block |
||
545 | 545 | 'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"' |
546 | 546 | }).addTo(map); |
547 | 547 | <?php |
548 | - } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
548 | + } elseif ($globalMapProvider == 'Google-Roadmap') { |
|
549 | 549 | ?> |
550 | 550 | var googleLayer = new L.Google('ROADMAP'); |
551 | 551 | map.addLayer(googleLayer); |
552 | 552 | <?php |
553 | - } elseif ($globalMapProvider == 'Google-Satellite') { |
|
553 | + } elseif ($globalMapProvider == 'Google-Satellite') { |
|
554 | 554 | ?> |
555 | 555 | var googleLayer = new L.Google('SATELLITE'); |
556 | 556 | map.addLayer(googleLayer); |
557 | 557 | <?php |
558 | - } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
558 | + } elseif ($globalMapProvider == 'Google-Hybrid') { |
|
559 | 559 | ?> |
560 | 560 | var googleLayer = new L.Google('HYBRID'); |
561 | 561 | map.addLayer(googleLayer); |
562 | 562 | <?php |
563 | - } elseif ($globalMapProvider == 'Google-Terrain') { |
|
563 | + } elseif ($globalMapProvider == 'Google-Terrain') { |
|
564 | 564 | ?> |
565 | 565 | var googleLayer = new L.Google('Terrain'); |
566 | 566 | map.addLayer(googleLayer); |
567 | 567 | <?php |
568 | - } |
|
568 | + } |
|
569 | 569 | ?> |
570 | 570 | </script> |
571 | 571 | </div> |
@@ -305,17 +305,17 @@ discard block |
||
305 | 305 | </tr> |
306 | 306 | <!-- |
307 | 307 | <?php |
308 | - require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
309 | - $Connection = new Connection(); |
|
308 | + require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
309 | + $Connection = new Connection(); |
|
310 | 310 | ?> |
311 | 311 | --> |
312 | 312 | <?php |
313 | - if ($Connection->db != NULL) { |
|
313 | + if ($Connection->db != NULL) { |
|
314 | 314 | if ($Connection->tableExists('source_location')) { |
315 | - require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
316 | - $Source = new Source(); |
|
317 | - $alllocations = $Source->getAllLocationInfo(); |
|
318 | - foreach ($alllocations as $location) { |
|
315 | + require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
316 | + $Source = new Source(); |
|
317 | + $alllocations = $Source->getAllLocationInfo(); |
|
318 | + foreach ($alllocations as $location) { |
|
319 | 319 | ?> |
320 | 320 | <tr> |
321 | 321 | <input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" /> |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | </tr> |
330 | 330 | |
331 | 331 | <?php |
332 | - } |
|
332 | + } |
|
333 | + } |
|
333 | 334 | } |
334 | - } |
|
335 | 335 | ?> |
336 | 336 | |
337 | 337 | <tr> |
@@ -424,12 +424,12 @@ discard block |
||
424 | 424 | ?> |
425 | 425 | <tr> |
426 | 426 | <?php |
427 | - if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
427 | + if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
428 | 428 | ?> |
429 | 429 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
430 | 430 | <td><input type="number" name="port[]" id="port" value="<?php print $source['port']; ?>" /></td> |
431 | 431 | <?php |
432 | - } else { |
|
432 | + } else { |
|
433 | 433 | $hostport = explode(':',$source['host']); |
434 | 434 | if (isset($hostport[1])) { |
435 | 435 | $host = $hostport[0]; |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | <td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td> |
443 | 443 | <td><input type="number" name="port[]" id="port" value="<?php print $port; ?>" /></td> |
444 | 444 | <?php |
445 | - } |
|
445 | + } |
|
446 | 446 | ?> |
447 | 447 | <td> |
448 | 448 | <select name="format[]" id="format"> |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | <br /> |
759 | 759 | <p> |
760 | 760 | <?php |
761 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
761 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
762 | 762 | ?> |
763 | 763 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
764 | 764 | <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
@@ -768,11 +768,11 @@ discard block |
||
768 | 768 | <b>The directory cache is not writable, aircraft icon will not be cached</b> |
769 | 769 | <?php |
770 | 770 | } |
771 | - } else { |
|
771 | + } else { |
|
772 | 772 | ?> |
773 | 773 | <b>PHP GD is not installed, you can t change color of aircraft icon on map</b> |
774 | 774 | <?php |
775 | - } |
|
775 | + } |
|
776 | 776 | ?> |
777 | 777 | </p> |
778 | 778 | <br /> |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | </p> |
792 | 792 | <?php |
793 | 793 | require('../footer.php'); |
794 | - exit; |
|
794 | + exit; |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | $settings = array(); |
@@ -881,8 +881,8 @@ discard block |
||
881 | 881 | |
882 | 882 | $sources = array(); |
883 | 883 | foreach ($source_name as $keys => $name) { |
884 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
885 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
884 | + if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
885 | + else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
886 | 886 | } |
887 | 887 | if (count($sources) > 0) $_SESSION['sources'] = $sources; |
888 | 888 | |
@@ -1176,14 +1176,14 @@ discard block |
||
1176 | 1176 | |
1177 | 1177 | // Set some defaults values... |
1178 | 1178 | if (!isset($globalAircraftImageSources)) { |
1179 | - $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1180 | - $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1179 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1180 | + $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | 1183 | if (!isset($globalSchedulesSources)) { |
1184 | - $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1185 | - $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1186 | - } |
|
1184 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1185 | + $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1186 | + } |
|
1187 | 1187 | |
1188 | 1188 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
1189 | 1189 | |
@@ -1235,21 +1235,21 @@ discard block |
||
1235 | 1235 | $popi = false; |
1236 | 1236 | $popw = false; |
1237 | 1237 | foreach ($_SESSION['done'] as $done) { |
1238 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1239 | - if ($done == 'Create database') $pop = true; |
|
1240 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1241 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1242 | - if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1238 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1239 | + if ($done == 'Create database') $pop = true; |
|
1240 | + if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1241 | + if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1242 | + if ($_SESSION['install'] == 'waypoints') $popw = true; |
|
1243 | 1243 | } |
1244 | 1244 | if ($pop) { |
1245 | - sleep(5); |
|
1246 | - print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1245 | + sleep(5); |
|
1246 | + print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1247 | 1247 | } else if ($popi) { |
1248 | - sleep(5); |
|
1249 | - print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1248 | + sleep(5); |
|
1249 | + print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1250 | 1250 | } else if ($popw) { |
1251 | - sleep(5); |
|
1252 | - print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1251 | + sleep(5); |
|
1252 | + print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>'; |
|
1253 | 1253 | } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
1254 | 1254 | print '</div></ul>'; |
1255 | 1255 | print '<div id="error"></div>'; |
@@ -1312,7 +1312,7 @@ discard block |
||
1312 | 1312 | unset($_COOKIE['install']); |
1313 | 1313 | print '<div class="info column"><ul>'; |
1314 | 1314 | foreach ($_SESSION['done'] as $done) { |
1315 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1315 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1316 | 1316 | } |
1317 | 1317 | print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>'; |
1318 | 1318 | print '</ul></div>'; |