@@ -24,13 +24,21 @@ discard block |
||
24 | 24 | |
25 | 25 | print '<div class="select-item"><form action="'.$globalURL.'/airline" method="post"><select name="airline_type" class="selectpicker" data-live-search="true">'; |
26 | 26 | print '<option value="all"'; |
27 | - if ($airline_type == 'all') print 'selected="selected" '; |
|
27 | + if ($airline_type == 'all') { |
|
28 | + print 'selected="selected" '; |
|
29 | + } |
|
28 | 30 | print '>'._("All").'</option><option value="passenger"'; |
29 | - if ($airline_type == 'passenger') print 'selected="selected" '; |
|
31 | + if ($airline_type == 'passenger') { |
|
32 | + print 'selected="selected" '; |
|
33 | + } |
|
30 | 34 | print '>'._("Passenger").'</option><option value="cargo"'; |
31 | - if ($airline_type == 'cargo') print 'selected="selected" '; |
|
35 | + if ($airline_type == 'cargo') { |
|
36 | + print 'selected="selected" '; |
|
37 | + } |
|
32 | 38 | print '>'._("Cargo").'</option><option value="military"'; |
33 | - if ($airline_type == 'military') print 'selected="selected" '; |
|
39 | + if ($airline_type == 'military') { |
|
40 | + print 'selected="selected" '; |
|
41 | + } |
|
34 | 42 | print '>'._("Military").'</option></select>'; |
35 | 43 | print '<button type="submit"><i class="fa fa-angle-double-right"></i></button></form></div>'; |
36 | 44 | |
@@ -57,7 +65,9 @@ discard block |
||
57 | 65 | $firstLetter = mb_strtoupper(mb_substr($value['airline_name'], 0, 1),'UTF-8'); |
58 | 66 | if($previous !== $firstLetter) |
59 | 67 | { |
60 | - if ($previous !== null) print ' | '; |
|
68 | + if ($previous !== null) { |
|
69 | + print ' | '; |
|
70 | + } |
|
61 | 71 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
62 | 72 | } |
63 | 73 | $previous = $firstLetter; |
@@ -70,7 +80,9 @@ discard block |
||
70 | 80 | { |
71 | 81 | if($previous !== $firstLetter) |
72 | 82 | { |
73 | - if ($previous !== null) print '</div>'; |
|
83 | + if ($previous !== null) { |
|
84 | + print '</div>'; |
|
85 | + } |
|
74 | 86 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
75 | 87 | } |
76 | 88 | $previous = $firstLetter; |
@@ -82,10 +94,14 @@ discard block |
||
82 | 94 | } elseif (@getimagesize('images/airlines/'.$value['airline_icao'].'.png') || @getimagesize($globalURL.'/images/airlines/'.$value['airline_icao'].'.png')) |
83 | 95 | { |
84 | 96 | print '<img src="'.$globalURL.'/images/airlines/'.$value['airline_icao'].'.png" alt="'._("Click to see airline activity").'" title="'._("Click to see airline activity").'" /> '; |
85 | - if (isset($value['ban_eu']) && $value['ban_eu'] == 1) print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> '; |
|
97 | + if (isset($value['ban_eu']) && $value['ban_eu'] == 1) { |
|
98 | + print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> '; |
|
99 | + } |
|
86 | 100 | } else { |
87 | 101 | print $value['airline_name']; |
88 | - if (isset($value['ban_eu']) && $value['ban_eu'] == 1) print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> '; |
|
102 | + if (isset($value['ban_eu']) && $value['ban_eu'] == 1) { |
|
103 | + print '<img src="'.$globalURL.'/images/baneu.png" alt="'._("Banned in Europe").'" title="'._("Banned in Europe").'" /> '; |
|
104 | + } |
|
89 | 105 | } |
90 | 106 | print '</a>'; |
91 | 107 | print '</div>'; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $limit_start = 0; |
15 | 15 | $limit_end = 25; |
16 | 16 | $absolute_difference = 25; |
17 | - } else { |
|
17 | + } else { |
|
18 | 18 | $limit_explode = explode(",", $_GET['limit']); |
19 | 19 | $limit_start = $limit_explode[0]; |
20 | 20 | $limit_end = $limit_explode[1]; |
@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | { |
39 | 39 | if (isset($spotter_array[0]['airline_name']) && isset($spotter_array[0]['airline_icao'])) { |
40 | 40 | $title = sprintf(_("Detailed View for %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']); |
41 | - } else $title = ''; |
|
41 | + } else { |
|
42 | + $title = ''; |
|
43 | + } |
|
42 | 44 | require_once('header.php'); |
43 | 45 | |
44 | 46 | print '<div class="select-item">'; |
@@ -47,7 +49,9 @@ discard block |
||
47 | 49 | print '<option></option>'; |
48 | 50 | $Stats = new Stats(); |
49 | 51 | $airline_names = $Stats->getAllAirlineNames(); |
50 | - if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames(); |
|
52 | + if (empty($airline_names)) { |
|
53 | + $airline_names = $Spotter->getAllAirlineNames(); |
|
54 | + } |
|
51 | 55 | foreach($airline_names as $airline_name) |
52 | 56 | { |
53 | 57 | if($_GET['airline'] == $airline_name['airline_icao']) |
@@ -76,10 +80,16 @@ discard block |
||
76 | 80 | print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['airline_name'].'</div>'; |
77 | 81 | print '<div><span class="label">'._("Country").'</span>'.$spotter_array[0]['airline_country'].'</div>'; |
78 | 82 | print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['airline_icao'].'</div>'; |
79 | - if (isset($spotter_array[0]['airline_iata'])) print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>'; |
|
80 | - if (isset($spotter_array[0]['airline_callsign'])) print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>'; |
|
83 | + if (isset($spotter_array[0]['airline_iata'])) { |
|
84 | + print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>'; |
|
85 | + } |
|
86 | + if (isset($spotter_array[0]['airline_callsign'])) { |
|
87 | + print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>'; |
|
88 | + } |
|
81 | 89 | print '<div><span class="label">'._("Type").'</span>'.ucwords($spotter_array[0]['airline_type']).'</div>'; |
82 | - if (isset($spotter_array[0]['ban_eu']) && $spotter_array[0]['ban_eu'] == 1) print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>'; |
|
90 | + if (isset($spotter_array[0]['ban_eu']) && $spotter_array[0]['ban_eu'] == 1) { |
|
91 | + print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>'; |
|
92 | + } |
|
83 | 93 | print '</div>'; |
84 | 94 | } else { |
85 | 95 | print '<div class="alert alert-warning">'._("This special airline profile shows all flights that do <u>not</u> have a airline associated with them.").'</div>'; |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | curl_setopt($ch, CURLOPT_URL, $url); |
17 | 17 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
18 | 18 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
19 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
19 | + if ($referer != '') { |
|
20 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
21 | + } |
|
20 | 22 | 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'); |
21 | 23 | curl_setopt($ch, CURLOPT_FILE, $fp); |
22 | 24 | curl_exec($ch); |
@@ -27,12 +29,16 @@ discard block |
||
27 | 29 | public static function gunzip($in_file,$out_file_name = '') { |
28 | 30 | //echo $in_file.' -> '.$out_file_name."\n"; |
29 | 31 | $buffer_size = 4096; // read 4kb at a time |
30 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
32 | + if ($out_file_name == '') { |
|
33 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
34 | + } |
|
31 | 35 | if ($in_file != '' && file_exists($in_file)) { |
32 | 36 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
33 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
34 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
35 | - else { |
|
37 | + if (function_exists('gzopen')) { |
|
38 | + $file = gzopen($in_file,'rb'); |
|
39 | + } elseif (function_exists('gzopen64')) { |
|
40 | + $file = gzopen64($in_file,'rb'); |
|
41 | + } else { |
|
36 | 42 | echo 'gzopen not available'; |
37 | 43 | die; |
38 | 44 | } |
@@ -53,8 +59,12 @@ discard block |
||
53 | 59 | if ($res === TRUE) { |
54 | 60 | $zip->extractTo($path); |
55 | 61 | $zip->close(); |
56 | - } else return false; |
|
57 | - } else return false; |
|
62 | + } else { |
|
63 | + return false; |
|
64 | + } |
|
65 | + } else { |
|
66 | + return false; |
|
67 | + } |
|
58 | 68 | } |
59 | 69 | |
60 | 70 | public static function connect_sqlite($database) { |
@@ -69,7 +79,9 @@ discard block |
||
69 | 79 | public static function retrieve_route_sqlite_to_dest($database_file) { |
70 | 80 | global $globalDebug, $globalTransaction; |
71 | 81 | //$query = 'TRUNCATE TABLE routes'; |
72 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
82 | + if ($globalDebug) { |
|
83 | + echo " - Delete previous routes from DB -"; |
|
84 | + } |
|
73 | 85 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
74 | 86 | $Connection = new Connection(); |
75 | 87 | try { |
@@ -80,7 +92,9 @@ discard block |
||
80 | 92 | return "error : ".$e->getMessage(); |
81 | 93 | } |
82 | 94 | |
83 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
95 | + if ($globalDebug) { |
|
96 | + echo " - Add routes to DB -"; |
|
97 | + } |
|
84 | 98 | update_db::connect_sqlite($database_file); |
85 | 99 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
86 | 100 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -95,15 +109,21 @@ discard block |
||
95 | 109 | $Connection = new Connection(); |
96 | 110 | $sth_dest = $Connection->db->prepare($query_dest); |
97 | 111 | try { |
98 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
112 | + if ($globalTransaction) { |
|
113 | + $Connection->db->beginTransaction(); |
|
114 | + } |
|
99 | 115 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
100 | 116 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
101 | 117 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
102 | 118 | $sth_dest->execute($query_dest_values); |
103 | 119 | } |
104 | - if ($globalTransaction) $Connection->db->commit(); |
|
120 | + if ($globalTransaction) { |
|
121 | + $Connection->db->commit(); |
|
122 | + } |
|
105 | 123 | } catch(PDOException $e) { |
106 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
124 | + if ($globalTransaction) { |
|
125 | + $Connection->db->rollBack(); |
|
126 | + } |
|
107 | 127 | return "error : ".$e->getMessage(); |
108 | 128 | } |
109 | 129 | return ''; |
@@ -111,7 +131,9 @@ discard block |
||
111 | 131 | public static function retrieve_route_oneworld($database_file) { |
112 | 132 | global $globalDebug, $globalTransaction; |
113 | 133 | //$query = 'TRUNCATE TABLE routes'; |
114 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
134 | + if ($globalDebug) { |
|
135 | + echo " - Delete previous routes from DB -"; |
|
136 | + } |
|
115 | 137 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
116 | 138 | $Connection = new Connection(); |
117 | 139 | try { |
@@ -122,14 +144,18 @@ discard block |
||
122 | 144 | return "error : ".$e->getMessage(); |
123 | 145 | } |
124 | 146 | |
125 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
147 | + if ($globalDebug) { |
|
148 | + echo " - Add routes to DB -"; |
|
149 | + } |
|
126 | 150 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
127 | 151 | $Spotter = new Spotter(); |
128 | 152 | if ($fh = fopen($database_file,"r")) { |
129 | 153 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
130 | 154 | $Connection = new Connection(); |
131 | 155 | $sth_dest = $Connection->db->prepare($query_dest); |
132 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
156 | + if ($globalTransaction) { |
|
157 | + $Connection->db->beginTransaction(); |
|
158 | + } |
|
133 | 159 | while (!feof($fh)) { |
134 | 160 | $line = fgetcsv($fh,9999,','); |
135 | 161 | if ($line[0] != '') { |
@@ -138,13 +164,17 @@ discard block |
||
138 | 164 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
139 | 165 | $sth_dest->execute($query_dest_values); |
140 | 166 | } catch(PDOException $e) { |
141 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
167 | + if ($globalTransaction) { |
|
168 | + $Connection->db->rollBack(); |
|
169 | + } |
|
142 | 170 | return "error : ".$e->getMessage(); |
143 | 171 | } |
144 | 172 | } |
145 | 173 | } |
146 | 174 | } |
147 | - if ($globalTransaction) $Connection->db->commit(); |
|
175 | + if ($globalTransaction) { |
|
176 | + $Connection->db->commit(); |
|
177 | + } |
|
148 | 178 | } |
149 | 179 | return ''; |
150 | 180 | } |
@@ -152,7 +182,9 @@ discard block |
||
152 | 182 | public static function retrieve_route_skyteam($database_file) { |
153 | 183 | global $globalDebug, $globalTransaction; |
154 | 184 | //$query = 'TRUNCATE TABLE routes'; |
155 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
185 | + if ($globalDebug) { |
|
186 | + echo " - Delete previous routes from DB -"; |
|
187 | + } |
|
156 | 188 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
157 | 189 | $Connection = new Connection(); |
158 | 190 | try { |
@@ -163,7 +195,9 @@ discard block |
||
163 | 195 | return "error : ".$e->getMessage(); |
164 | 196 | } |
165 | 197 | |
166 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
198 | + if ($globalDebug) { |
|
199 | + echo " - Add routes to DB -"; |
|
200 | + } |
|
167 | 201 | |
168 | 202 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
169 | 203 | $Spotter = new Spotter(); |
@@ -172,7 +206,9 @@ discard block |
||
172 | 206 | $Connection = new Connection(); |
173 | 207 | $sth_dest = $Connection->db->prepare($query_dest); |
174 | 208 | try { |
175 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
209 | + if ($globalTransaction) { |
|
210 | + $Connection->db->beginTransaction(); |
|
211 | + } |
|
176 | 212 | while (!feof($fh)) { |
177 | 213 | $line = fgetcsv($fh,9999,','); |
178 | 214 | if ($line[0] != '') { |
@@ -183,9 +219,13 @@ discard block |
||
183 | 219 | } |
184 | 220 | } |
185 | 221 | } |
186 | - if ($globalTransaction) $Connection->db->commit(); |
|
222 | + if ($globalTransaction) { |
|
223 | + $Connection->db->commit(); |
|
224 | + } |
|
187 | 225 | } catch(PDOException $e) { |
188 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
226 | + if ($globalTransaction) { |
|
227 | + $Connection->db->rollBack(); |
|
228 | + } |
|
189 | 229 | return "error : ".$e->getMessage(); |
190 | 230 | } |
191 | 231 | } |
@@ -228,11 +268,16 @@ discard block |
||
228 | 268 | $sth_dest = $Connection->db->prepare($query_dest); |
229 | 269 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
230 | 270 | try { |
231 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
271 | + if ($globalTransaction) { |
|
272 | + $Connection->db->beginTransaction(); |
|
273 | + } |
|
232 | 274 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
233 | 275 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
234 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
235 | - else $type = null; |
|
276 | + if ($values['UserString4'] == 'M') { |
|
277 | + $type = 'military'; |
|
278 | + } else { |
|
279 | + $type = null; |
|
280 | + } |
|
236 | 281 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
237 | 282 | $sth_dest->execute($query_dest_values); |
238 | 283 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -240,7 +285,9 @@ discard block |
||
240 | 285 | $sth_dest_owner->execute($query_dest_owner_values); |
241 | 286 | } |
242 | 287 | } |
243 | - if ($globalTransaction) $Connection->db->commit(); |
|
288 | + if ($globalTransaction) { |
|
289 | + $Connection->db->commit(); |
|
290 | + } |
|
244 | 291 | } catch(PDOException $e) { |
245 | 292 | return "error : ".$e->getMessage(); |
246 | 293 | } |
@@ -277,7 +324,9 @@ discard block |
||
277 | 324 | $Connection = new Connection(); |
278 | 325 | $sth_dest = $Connection->db->prepare($query_dest); |
279 | 326 | try { |
280 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
327 | + if ($globalTransaction) { |
|
328 | + $Connection->db->beginTransaction(); |
|
329 | + } |
|
281 | 330 | while (!feof($fh)) { |
282 | 331 | $values = array(); |
283 | 332 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -288,7 +337,9 @@ discard block |
||
288 | 337 | // Check if we can find ICAO, else set it to GLID |
289 | 338 | $aircraft_name_split = explode(' ',$aircraft_name); |
290 | 339 | $search_more = ''; |
291 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
340 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
341 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
342 | + } |
|
292 | 343 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
293 | 344 | $sth_search = $Connection->db->prepare($query_search); |
294 | 345 | try { |
@@ -301,7 +352,9 @@ discard block |
||
301 | 352 | } catch(PDOException $e) { |
302 | 353 | return "error : ".$e->getMessage(); |
303 | 354 | } |
304 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
355 | + if (!isset($values['ICAOTypeCode'])) { |
|
356 | + $values['ICAOTypeCode'] = 'GLID'; |
|
357 | + } |
|
305 | 358 | // Add data to db |
306 | 359 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
307 | 360 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -310,7 +363,9 @@ discard block |
||
310 | 363 | $sth_dest->execute($query_dest_values); |
311 | 364 | } |
312 | 365 | } |
313 | - if ($globalTransaction) $Connection->db->commit(); |
|
366 | + if ($globalTransaction) { |
|
367 | + $Connection->db->commit(); |
|
368 | + } |
|
314 | 369 | } catch(PDOException $e) { |
315 | 370 | return "error : ".$e->getMessage(); |
316 | 371 | } |
@@ -346,7 +401,9 @@ discard block |
||
346 | 401 | $Connection = new Connection(); |
347 | 402 | $sth_dest = $Connection->db->prepare($query_dest); |
348 | 403 | try { |
349 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
404 | + if ($globalTransaction) { |
|
405 | + $Connection->db->beginTransaction(); |
|
406 | + } |
|
350 | 407 | $tmp = fgetcsv($fh,9999,',',"'"); |
351 | 408 | while (!feof($fh)) { |
352 | 409 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -359,13 +416,17 @@ discard block |
||
359 | 416 | // Check if we can find ICAO, else set it to GLID |
360 | 417 | $aircraft_name_split = explode(' ',$aircraft_name); |
361 | 418 | $search_more = ''; |
362 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
419 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
420 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
421 | + } |
|
363 | 422 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
364 | 423 | $sth_search = $Connection->db->prepare($query_search); |
365 | 424 | try { |
366 | 425 | $sth_search->execute(); |
367 | 426 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
368 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
427 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
428 | + $values['ICAOTypeCode'] = $result['icao']; |
|
429 | + } |
|
369 | 430 | } catch(PDOException $e) { |
370 | 431 | return "error : ".$e->getMessage(); |
371 | 432 | } |
@@ -378,7 +439,9 @@ discard block |
||
378 | 439 | $sth_dest->execute($query_dest_values); |
379 | 440 | } |
380 | 441 | } |
381 | - if ($globalTransaction) $Connection->db->commit(); |
|
442 | + if ($globalTransaction) { |
|
443 | + $Connection->db->commit(); |
|
444 | + } |
|
382 | 445 | } catch(PDOException $e) { |
383 | 446 | return "error : ".$e->getMessage(); |
384 | 447 | } |
@@ -414,7 +477,9 @@ discard block |
||
414 | 477 | $Connection = new Connection(); |
415 | 478 | $sth_dest = $Connection->db->prepare($query_dest); |
416 | 479 | try { |
417 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
480 | + if ($globalTransaction) { |
|
481 | + $Connection->db->beginTransaction(); |
|
482 | + } |
|
418 | 483 | $tmp = fgetcsv($fh,9999,',','"'); |
419 | 484 | while (!feof($fh)) { |
420 | 485 | $line = fgetcsv($fh,9999,',','"'); |
@@ -424,16 +489,22 @@ discard block |
||
424 | 489 | $values['registration'] = $line[0]; |
425 | 490 | $values['base'] = $line[4]; |
426 | 491 | $values['owner'] = $line[5]; |
427 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
428 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
492 | + if ($line[6] == '') { |
|
493 | + $values['date_first_reg'] = null; |
|
494 | + } else { |
|
495 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
496 | + } |
|
429 | 497 | $values['cancel'] = $line[7]; |
430 | 498 | } elseif ($country == 'EI') { |
431 | 499 | // TODO : add modeS & reg to aircraft_modes |
432 | 500 | $values['registration'] = $line[0]; |
433 | 501 | $values['base'] = $line[3]; |
434 | 502 | $values['owner'] = $line[2]; |
435 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
436 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
503 | + if ($line[1] == '') { |
|
504 | + $values['date_first_reg'] = null; |
|
505 | + } else { |
|
506 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
507 | + } |
|
437 | 508 | $values['cancel'] = ''; |
438 | 509 | } elseif ($country == 'HB') { |
439 | 510 | // TODO : add modeS & reg to aircraft_modes |
@@ -447,16 +518,22 @@ discard block |
||
447 | 518 | $values['registration'] = $line[3]; |
448 | 519 | $values['base'] = null; |
449 | 520 | $values['owner'] = $line[5]; |
450 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
451 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
521 | + if ($line[18] == '') { |
|
522 | + $values['date_first_reg'] = null; |
|
523 | + } else { |
|
524 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
525 | + } |
|
452 | 526 | $values['cancel'] = ''; |
453 | 527 | } elseif ($country == 'VH') { |
454 | 528 | // TODO : add modeS & reg to aircraft_modes |
455 | 529 | $values['registration'] = $line[0]; |
456 | 530 | $values['base'] = null; |
457 | 531 | $values['owner'] = $line[12]; |
458 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
459 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
532 | + if ($line[28] == '') { |
|
533 | + $values['date_first_reg'] = null; |
|
534 | + } else { |
|
535 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
536 | + } |
|
460 | 537 | |
461 | 538 | $values['cancel'] = $line[39]; |
462 | 539 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -475,29 +552,41 @@ discard block |
||
475 | 552 | $values['registration'] = $line[0]; |
476 | 553 | $values['base'] = null; |
477 | 554 | $values['owner'] = $line[8]; |
478 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
479 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
555 | + if ($line[7] == '') { |
|
556 | + $values['date_first_reg'] = null; |
|
557 | + } else { |
|
558 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
559 | + } |
|
480 | 560 | $values['cancel'] = ''; |
481 | 561 | } elseif ($country == 'PP') { |
482 | 562 | $values['registration'] = $line[0]; |
483 | 563 | $values['base'] = null; |
484 | 564 | $values['owner'] = $line[4]; |
485 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
486 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
565 | + if ($line[6] == '') { |
|
566 | + $values['date_first_reg'] = null; |
|
567 | + } else { |
|
568 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
569 | + } |
|
487 | 570 | $values['cancel'] = $line[7]; |
488 | 571 | } elseif ($country == 'E7') { |
489 | 572 | $values['registration'] = $line[0]; |
490 | 573 | $values['base'] = null; |
491 | 574 | $values['owner'] = $line[4]; |
492 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
493 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
575 | + if ($line[5] == '') { |
|
576 | + $values['date_first_reg'] = null; |
|
577 | + } else { |
|
578 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
579 | + } |
|
494 | 580 | $values['cancel'] = ''; |
495 | 581 | } elseif ($country == '8Q') { |
496 | 582 | $values['registration'] = $line[0]; |
497 | 583 | $values['base'] = null; |
498 | 584 | $values['owner'] = $line[3]; |
499 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
500 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
585 | + if ($line[7] == '') { |
|
586 | + $values['date_first_reg'] = null; |
|
587 | + } else { |
|
588 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
589 | + } |
|
501 | 590 | $values['cancel'] = ''; |
502 | 591 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
503 | 592 | $values['registration'] = $line[0]; |
@@ -511,7 +600,9 @@ discard block |
||
511 | 600 | $sth_dest->execute($query_dest_values); |
512 | 601 | } |
513 | 602 | } |
514 | - if ($globalTransaction) $Connection->db->commit(); |
|
603 | + if ($globalTransaction) { |
|
604 | + $Connection->db->commit(); |
|
605 | + } |
|
515 | 606 | } catch(PDOException $e) { |
516 | 607 | return "error : ".$e->getMessage(); |
517 | 608 | } |
@@ -645,25 +736,45 @@ discard block |
||
645 | 736 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
646 | 737 | $Connection = new Connection(); |
647 | 738 | $sth_dest = $Connection->db->prepare($query_dest); |
648 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
739 | + if ($globalTransaction) { |
|
740 | + $Connection->db->beginTransaction(); |
|
741 | + } |
|
649 | 742 | |
650 | 743 | $i = 0; |
651 | 744 | while($row = sparql_fetch_array($result)) |
652 | 745 | { |
653 | 746 | if ($i >= 1) { |
654 | 747 | //print_r($row); |
655 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
656 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
657 | - if (!isset($row['type'])) $row['type'] = ''; |
|
658 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
748 | + if (!isset($row['iata'])) { |
|
749 | + $row['iata'] = ''; |
|
750 | + } |
|
751 | + if (!isset($row['icao'])) { |
|
752 | + $row['icao'] = ''; |
|
753 | + } |
|
754 | + if (!isset($row['type'])) { |
|
755 | + $row['type'] = ''; |
|
756 | + } |
|
757 | + if (!isset($row['altitude'])) { |
|
758 | + $row['altitude'] = ''; |
|
759 | + } |
|
659 | 760 | if (isset($row['city_bis'])) { |
660 | 761 | $row['city'] = $row['city_bis']; |
661 | 762 | } |
662 | - if (!isset($row['city'])) $row['city'] = ''; |
|
663 | - if (!isset($row['country'])) $row['country'] = ''; |
|
664 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
665 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
666 | - if (!isset($row['name'])) continue; |
|
763 | + if (!isset($row['city'])) { |
|
764 | + $row['city'] = ''; |
|
765 | + } |
|
766 | + if (!isset($row['country'])) { |
|
767 | + $row['country'] = ''; |
|
768 | + } |
|
769 | + if (!isset($row['homepage'])) { |
|
770 | + $row['homepage'] = ''; |
|
771 | + } |
|
772 | + if (!isset($row['wikipedia_page'])) { |
|
773 | + $row['wikipedia_page'] = ''; |
|
774 | + } |
|
775 | + if (!isset($row['name'])) { |
|
776 | + continue; |
|
777 | + } |
|
667 | 778 | if (!isset($row['image'])) { |
668 | 779 | $row['image'] = ''; |
669 | 780 | $row['image_thumb'] = ''; |
@@ -699,7 +810,9 @@ discard block |
||
699 | 810 | |
700 | 811 | $i++; |
701 | 812 | } |
702 | - if ($globalTransaction) $Connection->db->commit(); |
|
813 | + if ($globalTransaction) { |
|
814 | + $Connection->db->commit(); |
|
815 | + } |
|
703 | 816 | echo "Delete duplicate rows...\n"; |
704 | 817 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
705 | 818 | try { |
@@ -711,7 +824,9 @@ discard block |
||
711 | 824 | } |
712 | 825 | |
713 | 826 | |
714 | - if ($globalDebug) echo "Insert Not available Airport...\n"; |
|
827 | + if ($globalDebug) { |
|
828 | + echo "Insert Not available Airport...\n"; |
|
829 | + } |
|
715 | 830 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
716 | 831 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
717 | 832 | $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
@@ -738,7 +853,9 @@ discard block |
||
738 | 853 | $delimiter = ','; |
739 | 854 | $out_file = $tmp_dir.'airports.csv'; |
740 | 855 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
741 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
856 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
857 | + return FALSE; |
|
858 | + } |
|
742 | 859 | echo "Add data from ourairports.com...\n"; |
743 | 860 | |
744 | 861 | $header = NULL; |
@@ -748,8 +865,9 @@ discard block |
||
748 | 865 | //$Connection->db->beginTransaction(); |
749 | 866 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
750 | 867 | { |
751 | - if(!$header) $header = $row; |
|
752 | - else { |
|
868 | + if(!$header) { |
|
869 | + $header = $row; |
|
870 | + } else { |
|
753 | 871 | $data = array(); |
754 | 872 | $data = array_combine($header, $row); |
755 | 873 | try { |
@@ -787,7 +905,9 @@ discard block |
||
787 | 905 | echo "Download data from another free database...\n"; |
788 | 906 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
789 | 907 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
790 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
908 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
909 | + return FALSE; |
|
910 | + } |
|
791 | 911 | update_db::unzip($out_file); |
792 | 912 | $header = NULL; |
793 | 913 | echo "Add data from another free database...\n"; |
@@ -798,8 +918,9 @@ discard block |
||
798 | 918 | //$Connection->db->beginTransaction(); |
799 | 919 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
800 | 920 | { |
801 | - if(!$header) $header = $row; |
|
802 | - else { |
|
921 | + if(!$header) { |
|
922 | + $header = $row; |
|
923 | + } else { |
|
803 | 924 | $data = $row; |
804 | 925 | |
805 | 926 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
@@ -975,7 +1096,9 @@ discard block |
||
975 | 1096 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
976 | 1097 | { |
977 | 1098 | $i = 0; |
978 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1099 | + if ($globalTransaction) { |
|
1100 | + $Connection->db->beginTransaction(); |
|
1101 | + } |
|
979 | 1102 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
980 | 1103 | { |
981 | 1104 | if ($i > 0) { |
@@ -988,7 +1111,9 @@ discard block |
||
988 | 1111 | } |
989 | 1112 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
990 | 1113 | if (!empty($result_search)) { |
991 | - if ($globalDebug) echo '.'; |
|
1114 | + if ($globalDebug) { |
|
1115 | + echo '.'; |
|
1116 | + } |
|
992 | 1117 | //if ($globalDBdriver == 'mysql') { |
993 | 1118 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
994 | 1119 | //} else { |
@@ -1010,8 +1135,12 @@ discard block |
||
1010 | 1135 | } |
1011 | 1136 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
1012 | 1137 | if (!empty($result_search_mfr)) { |
1013 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
1014 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
1138 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
1139 | + $data[16] = $data[23]; |
|
1140 | + } |
|
1141 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
1142 | + $data[16] = $data[15]; |
|
1143 | + } |
|
1015 | 1144 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1016 | 1145 | try { |
1017 | 1146 | $sthf = $Connection->db->prepare($queryf); |
@@ -1022,7 +1151,9 @@ discard block |
||
1022 | 1151 | } |
1023 | 1152 | } |
1024 | 1153 | if (strtotime($data[29]) > time()) { |
1025 | - if ($globalDebug) echo 'i'; |
|
1154 | + if ($globalDebug) { |
|
1155 | + echo 'i'; |
|
1156 | + } |
|
1026 | 1157 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1027 | 1158 | try { |
1028 | 1159 | $sth = $Connection->db->prepare($query); |
@@ -1033,13 +1164,19 @@ discard block |
||
1033 | 1164 | } |
1034 | 1165 | } |
1035 | 1166 | if ($i % 90 == 0) { |
1036 | - if ($globalTransaction) $Connection->db->commit(); |
|
1037 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1167 | + if ($globalTransaction) { |
|
1168 | + $Connection->db->commit(); |
|
1169 | + } |
|
1170 | + if ($globalTransaction) { |
|
1171 | + $Connection->db->beginTransaction(); |
|
1172 | + } |
|
1038 | 1173 | } |
1039 | 1174 | $i++; |
1040 | 1175 | } |
1041 | 1176 | fclose($handle); |
1042 | - if ($globalTransaction) $Connection->db->commit(); |
|
1177 | + if ($globalTransaction) { |
|
1178 | + $Connection->db->commit(); |
|
1179 | + } |
|
1043 | 1180 | } |
1044 | 1181 | print_r($mfr); |
1045 | 1182 | return ''; |
@@ -1064,7 +1201,9 @@ discard block |
||
1064 | 1201 | $i = 0; |
1065 | 1202 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1066 | 1203 | //$Connection->db->beginTransaction(); |
1067 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1204 | + if ($globalTransaction) { |
|
1205 | + $Connection->db->beginTransaction(); |
|
1206 | + } |
|
1068 | 1207 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1069 | 1208 | { |
1070 | 1209 | if ($i > 0) { |
@@ -1079,7 +1218,9 @@ discard block |
||
1079 | 1218 | $i++; |
1080 | 1219 | } |
1081 | 1220 | fclose($handle); |
1082 | - if ($globalTransaction) $Connection->db->commit(); |
|
1221 | + if ($globalTransaction) { |
|
1222 | + $Connection->db->commit(); |
|
1223 | + } |
|
1083 | 1224 | } |
1084 | 1225 | return ''; |
1085 | 1226 | } |
@@ -1100,7 +1241,9 @@ discard block |
||
1100 | 1241 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
1101 | 1242 | { |
1102 | 1243 | $i = 0; |
1103 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1244 | + if ($globalTransaction) { |
|
1245 | + $Connection->db->beginTransaction(); |
|
1246 | + } |
|
1104 | 1247 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1105 | 1248 | { |
1106 | 1249 | if ($i > 0) { |
@@ -1116,7 +1259,9 @@ discard block |
||
1116 | 1259 | $i++; |
1117 | 1260 | } |
1118 | 1261 | fclose($handle); |
1119 | - if ($globalTransaction) $Connection->db->commit(); |
|
1262 | + if ($globalTransaction) { |
|
1263 | + $Connection->db->commit(); |
|
1264 | + } |
|
1120 | 1265 | } |
1121 | 1266 | return ''; |
1122 | 1267 | } |
@@ -1141,7 +1286,9 @@ discard block |
||
1141 | 1286 | $i = 0; |
1142 | 1287 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1143 | 1288 | //$Connection->db->beginTransaction(); |
1144 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1289 | + if ($globalTransaction) { |
|
1290 | + $Connection->db->beginTransaction(); |
|
1291 | + } |
|
1145 | 1292 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1146 | 1293 | { |
1147 | 1294 | if ($i > 0) { |
@@ -1156,7 +1303,9 @@ discard block |
||
1156 | 1303 | $i++; |
1157 | 1304 | } |
1158 | 1305 | fclose($handle); |
1159 | - if ($globalTransaction) $Connection->db->commit(); |
|
1306 | + if ($globalTransaction) { |
|
1307 | + $Connection->db->commit(); |
|
1308 | + } |
|
1160 | 1309 | } |
1161 | 1310 | return ''; |
1162 | 1311 | } |
@@ -1175,11 +1324,15 @@ discard block |
||
1175 | 1324 | $Connection = new Connection(); |
1176 | 1325 | if (($handle = fopen($tmp_dir.'ban_ue.csv', 'r')) !== FALSE) |
1177 | 1326 | { |
1178 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1327 | + if ($globalTransaction) { |
|
1328 | + $Connection->db->beginTransaction(); |
|
1329 | + } |
|
1179 | 1330 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1180 | 1331 | { |
1181 | 1332 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
1182 | - if ($data[0] != '') $icao = $data[0]; |
|
1333 | + if ($data[0] != '') { |
|
1334 | + $icao = $data[0]; |
|
1335 | + } |
|
1183 | 1336 | try { |
1184 | 1337 | $sth = $Connection->db->prepare($query); |
1185 | 1338 | $sth->execute(array(':icao' => $icao)); |
@@ -1188,7 +1341,9 @@ discard block |
||
1188 | 1341 | } |
1189 | 1342 | } |
1190 | 1343 | fclose($handle); |
1191 | - if ($globalTransaction) $Connection->db->commit(); |
|
1344 | + if ($globalTransaction) { |
|
1345 | + $Connection->db->commit(); |
|
1346 | + } |
|
1192 | 1347 | } |
1193 | 1348 | return ''; |
1194 | 1349 | } |
@@ -1339,7 +1494,9 @@ discard block |
||
1339 | 1494 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1340 | 1495 | { |
1341 | 1496 | $i = 0; |
1342 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1497 | + if ($globalTransaction) { |
|
1498 | + $Connection->db->beginTransaction(); |
|
1499 | + } |
|
1343 | 1500 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1344 | 1501 | { |
1345 | 1502 | $i++; |
@@ -1367,7 +1524,9 @@ discard block |
||
1367 | 1524 | } |
1368 | 1525 | } |
1369 | 1526 | fclose($handle); |
1370 | - if ($globalTransaction) $Connection->db->commit(); |
|
1527 | + if ($globalTransaction) { |
|
1528 | + $Connection->db->commit(); |
|
1529 | + } |
|
1371 | 1530 | } |
1372 | 1531 | return ''; |
1373 | 1532 | } |
@@ -1390,7 +1549,9 @@ discard block |
||
1390 | 1549 | $Connection = new Connection(); |
1391 | 1550 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1392 | 1551 | { |
1393 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1552 | + if ($globalTransaction) { |
|
1553 | + $Connection->db->beginTransaction(); |
|
1554 | + } |
|
1394 | 1555 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1395 | 1556 | { |
1396 | 1557 | if(count($row) > 1) { |
@@ -1404,7 +1565,9 @@ discard block |
||
1404 | 1565 | } |
1405 | 1566 | } |
1406 | 1567 | fclose($handle); |
1407 | - if ($globalTransaction) $Connection->db->commit(); |
|
1568 | + if ($globalTransaction) { |
|
1569 | + $Connection->db->commit(); |
|
1570 | + } |
|
1408 | 1571 | } |
1409 | 1572 | return ''; |
1410 | 1573 | } |
@@ -1424,8 +1587,9 @@ discard block |
||
1424 | 1587 | } |
1425 | 1588 | |
1426 | 1589 | |
1427 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1428 | - else { |
|
1590 | + if ($globalDBdriver == 'mysql') { |
|
1591 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1592 | + } else { |
|
1429 | 1593 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
1430 | 1594 | $query = "CREATE EXTENSION postgis"; |
1431 | 1595 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1444,20 +1608,30 @@ discard block |
||
1444 | 1608 | global $tmp_dir, $globalDebug; |
1445 | 1609 | include_once('class.create_db.php'); |
1446 | 1610 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1447 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
1611 | + if ($globalDebug) { |
|
1612 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
1613 | + } |
|
1448 | 1614 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
1449 | 1615 | $error = ''; |
1450 | 1616 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1451 | - if ($globalDebug) echo "Gunzip..."; |
|
1617 | + if ($globalDebug) { |
|
1618 | + echo "Gunzip..."; |
|
1619 | + } |
|
1452 | 1620 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
1453 | - if ($globalDebug) echo "Add to DB..."; |
|
1621 | + if ($globalDebug) { |
|
1622 | + echo "Add to DB..."; |
|
1623 | + } |
|
1454 | 1624 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
1455 | 1625 | $NOTAM = new NOTAM(); |
1456 | 1626 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
1457 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1627 | + } else { |
|
1628 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1629 | + } |
|
1458 | 1630 | if ($error != '') { |
1459 | 1631 | return $error; |
1460 | - } elseif ($globalDebug) echo "Done\n"; |
|
1632 | + } elseif ($globalDebug) { |
|
1633 | + echo "Done\n"; |
|
1634 | + } |
|
1461 | 1635 | return ''; |
1462 | 1636 | } |
1463 | 1637 | |
@@ -1511,67 +1685,111 @@ discard block |
||
1511 | 1685 | //if ($globalDebug) echo "IVAO : Download..."; |
1512 | 1686 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
1513 | 1687 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
1514 | - if ($globalDebug) echo "Unzip..."; |
|
1688 | + if ($globalDebug) { |
|
1689 | + echo "Unzip..."; |
|
1690 | + } |
|
1515 | 1691 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
1516 | - if ($globalDebug) echo "Add to DB..."; |
|
1692 | + if ($globalDebug) { |
|
1693 | + echo "Add to DB..."; |
|
1694 | + } |
|
1517 | 1695 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1518 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
1696 | + if ($globalDebug) { |
|
1697 | + echo "Copy airlines logos to airlines images directory..."; |
|
1698 | + } |
|
1519 | 1699 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1520 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1521 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1522 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1700 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
1701 | + $error = "Failed to copy airlines logo."; |
|
1702 | + } |
|
1703 | + } else { |
|
1704 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1705 | + } |
|
1706 | + } else { |
|
1707 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1708 | + } |
|
1523 | 1709 | if ($error != '') { |
1524 | 1710 | return $error; |
1525 | - } elseif ($globalDebug) echo "Done\n"; |
|
1711 | + } elseif ($globalDebug) { |
|
1712 | + echo "Done\n"; |
|
1713 | + } |
|
1526 | 1714 | return ''; |
1527 | 1715 | } |
1528 | 1716 | |
1529 | 1717 | public static function update_routes() { |
1530 | 1718 | global $tmp_dir, $globalDebug; |
1531 | 1719 | $error = ''; |
1532 | - if ($globalDebug) echo "Routes : Download..."; |
|
1720 | + if ($globalDebug) { |
|
1721 | + echo "Routes : Download..."; |
|
1722 | + } |
|
1533 | 1723 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
1534 | 1724 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1535 | - if ($globalDebug) echo "Gunzip..."; |
|
1725 | + if ($globalDebug) { |
|
1726 | + echo "Gunzip..."; |
|
1727 | + } |
|
1536 | 1728 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
1537 | - if ($globalDebug) echo "Add to DB..."; |
|
1729 | + if ($globalDebug) { |
|
1730 | + echo "Add to DB..."; |
|
1731 | + } |
|
1538 | 1732 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
1539 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1733 | + } else { |
|
1734 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1735 | + } |
|
1540 | 1736 | if ($error != '') { |
1541 | 1737 | return $error; |
1542 | - } elseif ($globalDebug) echo "Done\n"; |
|
1738 | + } elseif ($globalDebug) { |
|
1739 | + echo "Done\n"; |
|
1740 | + } |
|
1543 | 1741 | return ''; |
1544 | 1742 | } |
1545 | 1743 | public static function update_oneworld() { |
1546 | 1744 | global $tmp_dir, $globalDebug; |
1547 | 1745 | $error = ''; |
1548 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
1746 | + if ($globalDebug) { |
|
1747 | + echo "Schedules Oneworld : Download..."; |
|
1748 | + } |
|
1549 | 1749 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
1550 | 1750 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1551 | - if ($globalDebug) echo "Gunzip..."; |
|
1751 | + if ($globalDebug) { |
|
1752 | + echo "Gunzip..."; |
|
1753 | + } |
|
1552 | 1754 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
1553 | - if ($globalDebug) echo "Add to DB..."; |
|
1755 | + if ($globalDebug) { |
|
1756 | + echo "Add to DB..."; |
|
1757 | + } |
|
1554 | 1758 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
1555 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1759 | + } else { |
|
1760 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1761 | + } |
|
1556 | 1762 | if ($error != '') { |
1557 | 1763 | return $error; |
1558 | - } elseif ($globalDebug) echo "Done\n"; |
|
1764 | + } elseif ($globalDebug) { |
|
1765 | + echo "Done\n"; |
|
1766 | + } |
|
1559 | 1767 | return ''; |
1560 | 1768 | } |
1561 | 1769 | public static function update_skyteam() { |
1562 | 1770 | global $tmp_dir, $globalDebug; |
1563 | 1771 | $error = ''; |
1564 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
1772 | + if ($globalDebug) { |
|
1773 | + echo "Schedules Skyteam : Download..."; |
|
1774 | + } |
|
1565 | 1775 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
1566 | 1776 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1567 | - if ($globalDebug) echo "Gunzip..."; |
|
1777 | + if ($globalDebug) { |
|
1778 | + echo "Gunzip..."; |
|
1779 | + } |
|
1568 | 1780 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
1569 | - if ($globalDebug) echo "Add to DB..."; |
|
1781 | + if ($globalDebug) { |
|
1782 | + echo "Add to DB..."; |
|
1783 | + } |
|
1570 | 1784 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
1571 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1785 | + } else { |
|
1786 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1787 | + } |
|
1572 | 1788 | if ($error != '') { |
1573 | 1789 | return $error; |
1574 | - } elseif ($globalDebug) echo "Done\n"; |
|
1790 | + } elseif ($globalDebug) { |
|
1791 | + echo "Done\n"; |
|
1792 | + } |
|
1575 | 1793 | return ''; |
1576 | 1794 | } |
1577 | 1795 | public static function update_ModeS() { |
@@ -1588,341 +1806,587 @@ discard block |
||
1588 | 1806 | exit; |
1589 | 1807 | } elseif ($globalDebug) echo "Done\n"; |
1590 | 1808 | */ |
1591 | - if ($globalDebug) echo "Modes : Download..."; |
|
1592 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1809 | + if ($globalDebug) { |
|
1810 | + echo "Modes : Download..."; |
|
1811 | + } |
|
1812 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1593 | 1813 | update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
1594 | 1814 | |
1595 | 1815 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1596 | 1816 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
1597 | - if ($globalDebug) echo "Unzip..."; |
|
1598 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1817 | + if ($globalDebug) { |
|
1818 | + echo "Unzip..."; |
|
1819 | + } |
|
1820 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1599 | 1821 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
1600 | - if ($globalDebug) echo "Add to DB..."; |
|
1822 | + if ($globalDebug) { |
|
1823 | + echo "Add to DB..."; |
|
1824 | + } |
|
1601 | 1825 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
1602 | 1826 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
1603 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1827 | + } else { |
|
1828 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1829 | + } |
|
1604 | 1830 | if ($error != '') { |
1605 | 1831 | return $error; |
1606 | - } elseif ($globalDebug) echo "Done\n"; |
|
1832 | + } elseif ($globalDebug) { |
|
1833 | + echo "Done\n"; |
|
1834 | + } |
|
1607 | 1835 | return ''; |
1608 | 1836 | } |
1609 | 1837 | |
1610 | 1838 | public static function update_ModeS_faa() { |
1611 | 1839 | global $tmp_dir, $globalDebug; |
1612 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
1840 | + if ($globalDebug) { |
|
1841 | + echo "Modes FAA: Download..."; |
|
1842 | + } |
|
1613 | 1843 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
1614 | 1844 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
1615 | - if ($globalDebug) echo "Unzip..."; |
|
1845 | + if ($globalDebug) { |
|
1846 | + echo "Unzip..."; |
|
1847 | + } |
|
1616 | 1848 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
1617 | - if ($globalDebug) echo "Add to DB..."; |
|
1849 | + if ($globalDebug) { |
|
1850 | + echo "Add to DB..."; |
|
1851 | + } |
|
1618 | 1852 | $error = update_db::modes_faa(); |
1619 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
1853 | + } else { |
|
1854 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
1855 | + } |
|
1620 | 1856 | if ($error != '') { |
1621 | 1857 | return $error; |
1622 | - } elseif ($globalDebug) echo "Done\n"; |
|
1858 | + } elseif ($globalDebug) { |
|
1859 | + echo "Done\n"; |
|
1860 | + } |
|
1623 | 1861 | return ''; |
1624 | 1862 | } |
1625 | 1863 | |
1626 | 1864 | public static function update_ModeS_flarm() { |
1627 | 1865 | global $tmp_dir, $globalDebug; |
1628 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
1866 | + if ($globalDebug) { |
|
1867 | + echo "Modes Flarmnet: Download..."; |
|
1868 | + } |
|
1629 | 1869 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
1630 | 1870 | if (file_exists($tmp_dir.'data.fln')) { |
1631 | - if ($globalDebug) echo "Add to DB..."; |
|
1871 | + if ($globalDebug) { |
|
1872 | + echo "Add to DB..."; |
|
1873 | + } |
|
1632 | 1874 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
1633 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1875 | + } else { |
|
1876 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1877 | + } |
|
1634 | 1878 | if ($error != '') { |
1635 | 1879 | return $error; |
1636 | - } elseif ($globalDebug) echo "Done\n"; |
|
1880 | + } elseif ($globalDebug) { |
|
1881 | + echo "Done\n"; |
|
1882 | + } |
|
1637 | 1883 | return ''; |
1638 | 1884 | } |
1639 | 1885 | |
1640 | 1886 | public static function update_ModeS_ogn() { |
1641 | 1887 | global $tmp_dir, $globalDebug; |
1642 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
1888 | + if ($globalDebug) { |
|
1889 | + echo "Modes OGN: Download..."; |
|
1890 | + } |
|
1643 | 1891 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
1644 | 1892 | if (file_exists($tmp_dir.'ogn.csv')) { |
1645 | - if ($globalDebug) echo "Add to DB..."; |
|
1893 | + if ($globalDebug) { |
|
1894 | + echo "Add to DB..."; |
|
1895 | + } |
|
1646 | 1896 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
1647 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1897 | + } else { |
|
1898 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1899 | + } |
|
1648 | 1900 | if ($error != '') { |
1649 | 1901 | return $error; |
1650 | - } elseif ($globalDebug) echo "Done\n"; |
|
1902 | + } elseif ($globalDebug) { |
|
1903 | + echo "Done\n"; |
|
1904 | + } |
|
1651 | 1905 | return ''; |
1652 | 1906 | } |
1653 | 1907 | |
1654 | 1908 | public static function update_owner() { |
1655 | 1909 | global $tmp_dir, $globalDebug; |
1656 | 1910 | |
1657 | - if ($globalDebug) echo "Owner France: Download..."; |
|
1911 | + if ($globalDebug) { |
|
1912 | + echo "Owner France: Download..."; |
|
1913 | + } |
|
1658 | 1914 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
1659 | 1915 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1660 | - if ($globalDebug) echo "Add to DB..."; |
|
1916 | + if ($globalDebug) { |
|
1917 | + echo "Add to DB..."; |
|
1918 | + } |
|
1661 | 1919 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
1662 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1920 | + } else { |
|
1921 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1922 | + } |
|
1663 | 1923 | if ($error != '') { |
1664 | 1924 | return $error; |
1665 | - } elseif ($globalDebug) echo "Done\n"; |
|
1925 | + } elseif ($globalDebug) { |
|
1926 | + echo "Done\n"; |
|
1927 | + } |
|
1666 | 1928 | |
1667 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
1929 | + if ($globalDebug) { |
|
1930 | + echo "Owner Ireland: Download..."; |
|
1931 | + } |
|
1668 | 1932 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
1669 | 1933 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1670 | - if ($globalDebug) echo "Add to DB..."; |
|
1934 | + if ($globalDebug) { |
|
1935 | + echo "Add to DB..."; |
|
1936 | + } |
|
1671 | 1937 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
1672 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1938 | + } else { |
|
1939 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1940 | + } |
|
1673 | 1941 | if ($error != '') { |
1674 | 1942 | return $error; |
1675 | - } elseif ($globalDebug) echo "Done\n"; |
|
1676 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
1943 | + } elseif ($globalDebug) { |
|
1944 | + echo "Done\n"; |
|
1945 | + } |
|
1946 | + if ($globalDebug) { |
|
1947 | + echo "Owner Switzerland: Download..."; |
|
1948 | + } |
|
1677 | 1949 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
1678 | 1950 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1679 | - if ($globalDebug) echo "Add to DB..."; |
|
1951 | + if ($globalDebug) { |
|
1952 | + echo "Add to DB..."; |
|
1953 | + } |
|
1680 | 1954 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
1681 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1955 | + } else { |
|
1956 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1957 | + } |
|
1682 | 1958 | if ($error != '') { |
1683 | 1959 | return $error; |
1684 | - } elseif ($globalDebug) echo "Done\n"; |
|
1685 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
1960 | + } elseif ($globalDebug) { |
|
1961 | + echo "Done\n"; |
|
1962 | + } |
|
1963 | + if ($globalDebug) { |
|
1964 | + echo "Owner Czech Republic: Download..."; |
|
1965 | + } |
|
1686 | 1966 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
1687 | 1967 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1688 | - if ($globalDebug) echo "Add to DB..."; |
|
1968 | + if ($globalDebug) { |
|
1969 | + echo "Add to DB..."; |
|
1970 | + } |
|
1689 | 1971 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
1690 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
1972 | + } else { |
|
1973 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
1974 | + } |
|
1691 | 1975 | if ($error != '') { |
1692 | 1976 | return $error; |
1693 | - } elseif ($globalDebug) echo "Done\n"; |
|
1694 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
1977 | + } elseif ($globalDebug) { |
|
1978 | + echo "Done\n"; |
|
1979 | + } |
|
1980 | + if ($globalDebug) { |
|
1981 | + echo "Owner Australia: Download..."; |
|
1982 | + } |
|
1695 | 1983 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
1696 | 1984 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1697 | - if ($globalDebug) echo "Add to DB..."; |
|
1985 | + if ($globalDebug) { |
|
1986 | + echo "Add to DB..."; |
|
1987 | + } |
|
1698 | 1988 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
1699 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
1989 | + } else { |
|
1990 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
1991 | + } |
|
1700 | 1992 | if ($error != '') { |
1701 | 1993 | return $error; |
1702 | - } elseif ($globalDebug) echo "Done\n"; |
|
1703 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
1994 | + } elseif ($globalDebug) { |
|
1995 | + echo "Done\n"; |
|
1996 | + } |
|
1997 | + if ($globalDebug) { |
|
1998 | + echo "Owner Austria: Download..."; |
|
1999 | + } |
|
1704 | 2000 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
1705 | 2001 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1706 | - if ($globalDebug) echo "Add to DB..."; |
|
2002 | + if ($globalDebug) { |
|
2003 | + echo "Add to DB..."; |
|
2004 | + } |
|
1707 | 2005 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
1708 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2006 | + } else { |
|
2007 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2008 | + } |
|
1709 | 2009 | if ($error != '') { |
1710 | 2010 | return $error; |
1711 | - } elseif ($globalDebug) echo "Done\n"; |
|
1712 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
2011 | + } elseif ($globalDebug) { |
|
2012 | + echo "Done\n"; |
|
2013 | + } |
|
2014 | + if ($globalDebug) { |
|
2015 | + echo "Owner Chile: Download..."; |
|
2016 | + } |
|
1713 | 2017 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
1714 | 2018 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1715 | - if ($globalDebug) echo "Add to DB..."; |
|
2019 | + if ($globalDebug) { |
|
2020 | + echo "Add to DB..."; |
|
2021 | + } |
|
1716 | 2022 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
1717 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2023 | + } else { |
|
2024 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2025 | + } |
|
1718 | 2026 | if ($error != '') { |
1719 | 2027 | return $error; |
1720 | - } elseif ($globalDebug) echo "Done\n"; |
|
1721 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
2028 | + } elseif ($globalDebug) { |
|
2029 | + echo "Done\n"; |
|
2030 | + } |
|
2031 | + if ($globalDebug) { |
|
2032 | + echo "Owner Colombia: Download..."; |
|
2033 | + } |
|
1722 | 2034 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
1723 | 2035 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1724 | - if ($globalDebug) echo "Add to DB..."; |
|
2036 | + if ($globalDebug) { |
|
2037 | + echo "Add to DB..."; |
|
2038 | + } |
|
1725 | 2039 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
1726 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2040 | + } else { |
|
2041 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2042 | + } |
|
1727 | 2043 | if ($error != '') { |
1728 | 2044 | return $error; |
1729 | - } elseif ($globalDebug) echo "Done\n"; |
|
1730 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
2045 | + } elseif ($globalDebug) { |
|
2046 | + echo "Done\n"; |
|
2047 | + } |
|
2048 | + if ($globalDebug) { |
|
2049 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
2050 | + } |
|
1731 | 2051 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
1732 | 2052 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1733 | - if ($globalDebug) echo "Add to DB..."; |
|
2053 | + if ($globalDebug) { |
|
2054 | + echo "Add to DB..."; |
|
2055 | + } |
|
1734 | 2056 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
1735 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2057 | + } else { |
|
2058 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2059 | + } |
|
1736 | 2060 | if ($error != '') { |
1737 | 2061 | return $error; |
1738 | - } elseif ($globalDebug) echo "Done\n"; |
|
1739 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
2062 | + } elseif ($globalDebug) { |
|
2063 | + echo "Done\n"; |
|
2064 | + } |
|
2065 | + if ($globalDebug) { |
|
2066 | + echo "Owner Brazil: Download..."; |
|
2067 | + } |
|
1740 | 2068 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
1741 | 2069 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1742 | - if ($globalDebug) echo "Add to DB..."; |
|
2070 | + if ($globalDebug) { |
|
2071 | + echo "Add to DB..."; |
|
2072 | + } |
|
1743 | 2073 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
1744 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2074 | + } else { |
|
2075 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2076 | + } |
|
1745 | 2077 | if ($error != '') { |
1746 | 2078 | return $error; |
1747 | - } elseif ($globalDebug) echo "Done\n"; |
|
1748 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
2079 | + } elseif ($globalDebug) { |
|
2080 | + echo "Done\n"; |
|
2081 | + } |
|
2082 | + if ($globalDebug) { |
|
2083 | + echo "Owner Cayman Islands: Download..."; |
|
2084 | + } |
|
1749 | 2085 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
1750 | 2086 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1751 | - if ($globalDebug) echo "Add to DB..."; |
|
2087 | + if ($globalDebug) { |
|
2088 | + echo "Add to DB..."; |
|
2089 | + } |
|
1752 | 2090 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
1753 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2091 | + } else { |
|
2092 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2093 | + } |
|
1754 | 2094 | if ($error != '') { |
1755 | 2095 | return $error; |
1756 | - } elseif ($globalDebug) echo "Done\n"; |
|
1757 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
2096 | + } elseif ($globalDebug) { |
|
2097 | + echo "Done\n"; |
|
2098 | + } |
|
2099 | + if ($globalDebug) { |
|
2100 | + echo "Owner Croatia: Download..."; |
|
2101 | + } |
|
1758 | 2102 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
1759 | 2103 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1760 | - if ($globalDebug) echo "Add to DB..."; |
|
2104 | + if ($globalDebug) { |
|
2105 | + echo "Add to DB..."; |
|
2106 | + } |
|
1761 | 2107 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
1762 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2108 | + } else { |
|
2109 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2110 | + } |
|
1763 | 2111 | if ($error != '') { |
1764 | 2112 | return $error; |
1765 | - } elseif ($globalDebug) echo "Done\n"; |
|
1766 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
2113 | + } elseif ($globalDebug) { |
|
2114 | + echo "Done\n"; |
|
2115 | + } |
|
2116 | + if ($globalDebug) { |
|
2117 | + echo "Owner Luxembourg: Download..."; |
|
2118 | + } |
|
1767 | 2119 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
1768 | 2120 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1769 | - if ($globalDebug) echo "Add to DB..."; |
|
2121 | + if ($globalDebug) { |
|
2122 | + echo "Add to DB..."; |
|
2123 | + } |
|
1770 | 2124 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
1771 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2125 | + } else { |
|
2126 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2127 | + } |
|
1772 | 2128 | if ($error != '') { |
1773 | 2129 | return $error; |
1774 | - } elseif ($globalDebug) echo "Done\n"; |
|
1775 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
2130 | + } elseif ($globalDebug) { |
|
2131 | + echo "Done\n"; |
|
2132 | + } |
|
2133 | + if ($globalDebug) { |
|
2134 | + echo "Owner Maldives: Download..."; |
|
2135 | + } |
|
1776 | 2136 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
1777 | 2137 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1778 | - if ($globalDebug) echo "Add to DB..."; |
|
2138 | + if ($globalDebug) { |
|
2139 | + echo "Add to DB..."; |
|
2140 | + } |
|
1779 | 2141 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
1780 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2142 | + } else { |
|
2143 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2144 | + } |
|
1781 | 2145 | if ($error != '') { |
1782 | 2146 | return $error; |
1783 | - } elseif ($globalDebug) echo "Done\n"; |
|
1784 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
2147 | + } elseif ($globalDebug) { |
|
2148 | + echo "Done\n"; |
|
2149 | + } |
|
2150 | + if ($globalDebug) { |
|
2151 | + echo "Owner New Zealand: Download..."; |
|
2152 | + } |
|
1785 | 2153 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
1786 | 2154 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1787 | - if ($globalDebug) echo "Add to DB..."; |
|
2155 | + if ($globalDebug) { |
|
2156 | + echo "Add to DB..."; |
|
2157 | + } |
|
1788 | 2158 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
1789 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2159 | + } else { |
|
2160 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2161 | + } |
|
1790 | 2162 | if ($error != '') { |
1791 | 2163 | return $error; |
1792 | - } elseif ($globalDebug) echo "Done\n"; |
|
1793 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
2164 | + } elseif ($globalDebug) { |
|
2165 | + echo "Done\n"; |
|
2166 | + } |
|
2167 | + if ($globalDebug) { |
|
2168 | + echo "Owner Papua New Guinea: Download..."; |
|
2169 | + } |
|
1794 | 2170 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
1795 | 2171 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1796 | - if ($globalDebug) echo "Add to DB..."; |
|
2172 | + if ($globalDebug) { |
|
2173 | + echo "Add to DB..."; |
|
2174 | + } |
|
1797 | 2175 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
1798 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2176 | + } else { |
|
2177 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2178 | + } |
|
1799 | 2179 | if ($error != '') { |
1800 | 2180 | return $error; |
1801 | - } elseif ($globalDebug) echo "Done\n"; |
|
1802 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
2181 | + } elseif ($globalDebug) { |
|
2182 | + echo "Done\n"; |
|
2183 | + } |
|
2184 | + if ($globalDebug) { |
|
2185 | + echo "Owner Slovakia: Download..."; |
|
2186 | + } |
|
1803 | 2187 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
1804 | 2188 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1805 | - if ($globalDebug) echo "Add to DB..."; |
|
2189 | + if ($globalDebug) { |
|
2190 | + echo "Add to DB..."; |
|
2191 | + } |
|
1806 | 2192 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
1807 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2193 | + } else { |
|
2194 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2195 | + } |
|
1808 | 2196 | if ($error != '') { |
1809 | 2197 | return $error; |
1810 | - } elseif ($globalDebug) echo "Done\n"; |
|
1811 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
2198 | + } elseif ($globalDebug) { |
|
2199 | + echo "Done\n"; |
|
2200 | + } |
|
2201 | + if ($globalDebug) { |
|
2202 | + echo "Owner Ecuador: Download..."; |
|
2203 | + } |
|
1812 | 2204 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
1813 | 2205 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1814 | - if ($globalDebug) echo "Add to DB..."; |
|
2206 | + if ($globalDebug) { |
|
2207 | + echo "Add to DB..."; |
|
2208 | + } |
|
1815 | 2209 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
1816 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2210 | + } else { |
|
2211 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2212 | + } |
|
1817 | 2213 | if ($error != '') { |
1818 | 2214 | return $error; |
1819 | - } elseif ($globalDebug) echo "Done\n"; |
|
1820 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
2215 | + } elseif ($globalDebug) { |
|
2216 | + echo "Done\n"; |
|
2217 | + } |
|
2218 | + if ($globalDebug) { |
|
2219 | + echo "Owner Iceland: Download..."; |
|
2220 | + } |
|
1821 | 2221 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
1822 | 2222 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1823 | - if ($globalDebug) echo "Add to DB..."; |
|
2223 | + if ($globalDebug) { |
|
2224 | + echo "Add to DB..."; |
|
2225 | + } |
|
1824 | 2226 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
1825 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2227 | + } else { |
|
2228 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2229 | + } |
|
1826 | 2230 | if ($error != '') { |
1827 | 2231 | return $error; |
1828 | - } elseif ($globalDebug) echo "Done\n"; |
|
2232 | + } elseif ($globalDebug) { |
|
2233 | + echo "Done\n"; |
|
2234 | + } |
|
1829 | 2235 | return ''; |
1830 | 2236 | } |
1831 | 2237 | |
1832 | 2238 | public static function update_translation() { |
1833 | 2239 | global $tmp_dir, $globalDebug; |
1834 | 2240 | $error = ''; |
1835 | - if ($globalDebug) echo "Translation : Download..."; |
|
2241 | + if ($globalDebug) { |
|
2242 | + echo "Translation : Download..."; |
|
2243 | + } |
|
1836 | 2244 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
1837 | 2245 | if (file_exists($tmp_dir.'translation.zip')) { |
1838 | - if ($globalDebug) echo "Unzip..."; |
|
2246 | + if ($globalDebug) { |
|
2247 | + echo "Unzip..."; |
|
2248 | + } |
|
1839 | 2249 | update_db::unzip($tmp_dir.'translation.zip'); |
1840 | - if ($globalDebug) echo "Add to DB..."; |
|
2250 | + if ($globalDebug) { |
|
2251 | + echo "Add to DB..."; |
|
2252 | + } |
|
1841 | 2253 | $error = update_db::translation(); |
1842 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2254 | + } else { |
|
2255 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2256 | + } |
|
1843 | 2257 | if ($error != '') { |
1844 | 2258 | return $error; |
1845 | - } elseif ($globalDebug) echo "Done\n"; |
|
2259 | + } elseif ($globalDebug) { |
|
2260 | + echo "Done\n"; |
|
2261 | + } |
|
1846 | 2262 | return ''; |
1847 | 2263 | } |
1848 | 2264 | |
1849 | 2265 | public static function update_translation_fam() { |
1850 | 2266 | global $tmp_dir, $globalDebug; |
1851 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2267 | + if ($globalDebug) { |
|
2268 | + echo "Translation from FlightAirMap website : Download..."; |
|
2269 | + } |
|
1852 | 2270 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
1853 | 2271 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1854 | - if ($globalDebug) echo "Gunzip..."; |
|
2272 | + if ($globalDebug) { |
|
2273 | + echo "Gunzip..."; |
|
2274 | + } |
|
1855 | 2275 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
1856 | - if ($globalDebug) echo "Add to DB..."; |
|
2276 | + if ($globalDebug) { |
|
2277 | + echo "Add to DB..."; |
|
2278 | + } |
|
1857 | 2279 | $error = update_db::translation_fam(); |
1858 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2280 | + } else { |
|
2281 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2282 | + } |
|
1859 | 2283 | if ($error != '') { |
1860 | 2284 | return $error; |
1861 | - } elseif ($globalDebug) echo "Done\n"; |
|
2285 | + } elseif ($globalDebug) { |
|
2286 | + echo "Done\n"; |
|
2287 | + } |
|
1862 | 2288 | return ''; |
1863 | 2289 | } |
1864 | 2290 | public static function update_ModeS_fam() { |
1865 | 2291 | global $tmp_dir, $globalDebug; |
1866 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
2292 | + if ($globalDebug) { |
|
2293 | + echo "ModeS from FlightAirMap website : Download..."; |
|
2294 | + } |
|
1867 | 2295 | update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
1868 | 2296 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
1869 | - if ($globalDebug) echo "Gunzip..."; |
|
2297 | + if ($globalDebug) { |
|
2298 | + echo "Gunzip..."; |
|
2299 | + } |
|
1870 | 2300 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
1871 | - if ($globalDebug) echo "Add to DB..."; |
|
2301 | + if ($globalDebug) { |
|
2302 | + echo "Add to DB..."; |
|
2303 | + } |
|
1872 | 2304 | $error = update_db::modes_fam(); |
1873 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2305 | + } else { |
|
2306 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2307 | + } |
|
1874 | 2308 | if ($error != '') { |
1875 | 2309 | return $error; |
1876 | - } elseif ($globalDebug) echo "Done\n"; |
|
2310 | + } elseif ($globalDebug) { |
|
2311 | + echo "Done\n"; |
|
2312 | + } |
|
1877 | 2313 | return ''; |
1878 | 2314 | } |
1879 | 2315 | public static function update_owner_fam() { |
1880 | 2316 | global $tmp_dir, $globalDebug, $globalOwner; |
1881 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
2317 | + if ($globalDebug) { |
|
2318 | + echo "owner from FlightAirMap website : Download..."; |
|
2319 | + } |
|
1882 | 2320 | if ($globalOwner === TRUE) { |
1883 | 2321 | update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
1884 | 2322 | } else { |
1885 | 2323 | update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
1886 | 2324 | } |
1887 | 2325 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
1888 | - if ($globalDebug) echo "Gunzip..."; |
|
2326 | + if ($globalDebug) { |
|
2327 | + echo "Gunzip..."; |
|
2328 | + } |
|
1889 | 2329 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
1890 | - if ($globalDebug) echo "Add to DB..."; |
|
2330 | + if ($globalDebug) { |
|
2331 | + echo "Add to DB..."; |
|
2332 | + } |
|
1891 | 2333 | $error = update_db::owner_fam(); |
1892 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
2334 | + } else { |
|
2335 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
2336 | + } |
|
1893 | 2337 | if ($error != '') { |
1894 | 2338 | return $error; |
1895 | - } elseif ($globalDebug) echo "Done\n"; |
|
2339 | + } elseif ($globalDebug) { |
|
2340 | + echo "Done\n"; |
|
2341 | + } |
|
1896 | 2342 | return ''; |
1897 | 2343 | } |
1898 | 2344 | public static function update_routes_fam() { |
1899 | 2345 | global $tmp_dir, $globalDebug; |
1900 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
2346 | + if ($globalDebug) { |
|
2347 | + echo "Routes from FlightAirMap website : Download..."; |
|
2348 | + } |
|
1901 | 2349 | update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
1902 | 2350 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
1903 | - if ($globalDebug) echo "Gunzip..."; |
|
2351 | + if ($globalDebug) { |
|
2352 | + echo "Gunzip..."; |
|
2353 | + } |
|
1904 | 2354 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
1905 | - if ($globalDebug) echo "Add to DB..."; |
|
2355 | + if ($globalDebug) { |
|
2356 | + echo "Add to DB..."; |
|
2357 | + } |
|
1906 | 2358 | $error = update_db::routes_fam(); |
1907 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2359 | + } else { |
|
2360 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2361 | + } |
|
1908 | 2362 | if ($error != '') { |
1909 | 2363 | return $error; |
1910 | - } elseif ($globalDebug) echo "Done\n"; |
|
2364 | + } elseif ($globalDebug) { |
|
2365 | + echo "Done\n"; |
|
2366 | + } |
|
1911 | 2367 | return ''; |
1912 | 2368 | } |
1913 | 2369 | public static function update_banned_fam() { |
1914 | 2370 | global $tmp_dir, $globalDebug; |
1915 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
2371 | + if ($globalDebug) { |
|
2372 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
2373 | + } |
|
1916 | 2374 | update_db::download('http://data.flightairmap.fr/data/ban_ue.csv',$tmp_dir.'ban_ue.csv'); |
1917 | 2375 | if (file_exists($tmp_dir.'ban_ue.csv')) { |
1918 | 2376 | //if ($globalDebug) echo "Gunzip..."; |
1919 | 2377 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
1920 | - if ($globalDebug) echo "Add to DB..."; |
|
2378 | + if ($globalDebug) { |
|
2379 | + echo "Add to DB..."; |
|
2380 | + } |
|
1921 | 2381 | $error = update_db::banned_fam(); |
1922 | - } else $error = "File ".$tmp_dir.'ban_ue.csv'." doesn't exist. Download failed."; |
|
2382 | + } else { |
|
2383 | + $error = "File ".$tmp_dir.'ban_ue.csv'." doesn't exist. Download failed."; |
|
2384 | + } |
|
1923 | 2385 | if ($error != '') { |
1924 | 2386 | return $error; |
1925 | - } elseif ($globalDebug) echo "Done\n"; |
|
2387 | + } elseif ($globalDebug) { |
|
2388 | + echo "Done\n"; |
|
2389 | + } |
|
1926 | 2390 | return ''; |
1927 | 2391 | } |
1928 | 2392 | |
@@ -1930,7 +2394,9 @@ discard block |
||
1930 | 2394 | global $tmp_dir, $globalDebug, $globalDBdriver; |
1931 | 2395 | include_once('class.create_db.php'); |
1932 | 2396 | $error = ''; |
1933 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
2397 | + if ($globalDebug) { |
|
2398 | + echo "Airspace from FlightAirMap website : Download..."; |
|
2399 | + } |
|
1934 | 2400 | if ($globalDBdriver == 'mysql') { |
1935 | 2401 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
1936 | 2402 | } else { |
@@ -1946,9 +2412,13 @@ discard block |
||
1946 | 2412 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
1947 | 2413 | } |
1948 | 2414 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
1949 | - if ($globalDebug) echo "Gunzip..."; |
|
2415 | + if ($globalDebug) { |
|
2416 | + echo "Gunzip..."; |
|
2417 | + } |
|
1950 | 2418 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
1951 | - if ($globalDebug) echo "Add to DB..."; |
|
2419 | + if ($globalDebug) { |
|
2420 | + echo "Add to DB..."; |
|
2421 | + } |
|
1952 | 2422 | $Connection = new Connection(); |
1953 | 2423 | if ($Connection->tableExists('airspace')) { |
1954 | 2424 | $query = 'DROP TABLE airspace'; |
@@ -1961,31 +2431,47 @@ discard block |
||
1961 | 2431 | } |
1962 | 2432 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
1963 | 2433 | update_db::insert_airspace_version($airspace_md5); |
1964 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2434 | + } else { |
|
2435 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2436 | + } |
|
1965 | 2437 | } |
1966 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2438 | + } else { |
|
2439 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2440 | + } |
|
1967 | 2441 | if ($error != '') { |
1968 | 2442 | return $error; |
1969 | - } elseif ($globalDebug) echo "Done\n"; |
|
2443 | + } elseif ($globalDebug) { |
|
2444 | + echo "Done\n"; |
|
2445 | + } |
|
1970 | 2446 | return ''; |
1971 | 2447 | } |
1972 | 2448 | |
1973 | 2449 | public static function update_tle() { |
1974 | 2450 | global $tmp_dir, $globalDebug; |
1975 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
2451 | + if ($globalDebug) { |
|
2452 | + echo "Download TLE : Download..."; |
|
2453 | + } |
|
1976 | 2454 | $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
1977 | 2455 | 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
1978 | 2456 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
1979 | 2457 | foreach ($alltle as $filename) { |
1980 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
2458 | + if ($globalDebug) { |
|
2459 | + echo "downloading ".$filename.'...'; |
|
2460 | + } |
|
1981 | 2461 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
1982 | 2462 | if (file_exists($tmp_dir.$filename)) { |
1983 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
2463 | + if ($globalDebug) { |
|
2464 | + echo "Add to DB ".$filename."..."; |
|
2465 | + } |
|
1984 | 2466 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
1985 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2467 | + } else { |
|
2468 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2469 | + } |
|
1986 | 2470 | if ($error != '') { |
1987 | 2471 | echo $error."\n"; |
1988 | - } elseif ($globalDebug) echo "Done\n"; |
|
2472 | + } elseif ($globalDebug) { |
|
2473 | + echo "Done\n"; |
|
2474 | + } |
|
1989 | 2475 | } |
1990 | 2476 | return ''; |
1991 | 2477 | } |
@@ -1993,10 +2479,14 @@ discard block |
||
1993 | 2479 | public static function update_models() { |
1994 | 2480 | global $tmp_dir, $globalDebug; |
1995 | 2481 | $error = ''; |
1996 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
2482 | + if ($globalDebug) { |
|
2483 | + echo "Models from FlightAirMap website : Download..."; |
|
2484 | + } |
|
1997 | 2485 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
1998 | 2486 | if (file_exists($tmp_dir.'models.md5sum')) { |
1999 | - if ($globalDebug) echo "Check files...\n"; |
|
2487 | + if ($globalDebug) { |
|
2488 | + echo "Check files...\n"; |
|
2489 | + } |
|
2000 | 2490 | $newmodelsdb = array(); |
2001 | 2491 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
2002 | 2492 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2015,25 +2505,35 @@ discard block |
||
2015 | 2505 | } |
2016 | 2506 | $diff = array_diff($newmodelsdb,$modelsdb); |
2017 | 2507 | foreach ($diff as $key => $value) { |
2018 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
2508 | + if ($globalDebug) { |
|
2509 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
2510 | + } |
|
2019 | 2511 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
2020 | 2512 | |
2021 | 2513 | } |
2022 | 2514 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
2023 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2515 | + } else { |
|
2516 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2517 | + } |
|
2024 | 2518 | if ($error != '') { |
2025 | 2519 | return $error; |
2026 | - } elseif ($globalDebug) echo "Done\n"; |
|
2520 | + } elseif ($globalDebug) { |
|
2521 | + echo "Done\n"; |
|
2522 | + } |
|
2027 | 2523 | return ''; |
2028 | 2524 | } |
2029 | 2525 | |
2030 | 2526 | public static function update_space_models() { |
2031 | 2527 | global $tmp_dir, $globalDebug; |
2032 | 2528 | $error = ''; |
2033 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
2529 | + if ($globalDebug) { |
|
2530 | + echo "Space models from FlightAirMap website : Download..."; |
|
2531 | + } |
|
2034 | 2532 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
2035 | 2533 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2036 | - if ($globalDebug) echo "Check files...\n"; |
|
2534 | + if ($globalDebug) { |
|
2535 | + echo "Check files...\n"; |
|
2536 | + } |
|
2037 | 2537 | $newmodelsdb = array(); |
2038 | 2538 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
2039 | 2539 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2052,15 +2552,21 @@ discard block |
||
2052 | 2552 | } |
2053 | 2553 | $diff = array_diff($newmodelsdb,$modelsdb); |
2054 | 2554 | foreach ($diff as $key => $value) { |
2055 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
2555 | + if ($globalDebug) { |
|
2556 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
2557 | + } |
|
2056 | 2558 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
2057 | 2559 | |
2058 | 2560 | } |
2059 | 2561 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
2060 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2562 | + } else { |
|
2563 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2564 | + } |
|
2061 | 2565 | if ($error != '') { |
2062 | 2566 | return $error; |
2063 | - } elseif ($globalDebug) echo "Done\n"; |
|
2567 | + } elseif ($globalDebug) { |
|
2568 | + echo "Done\n"; |
|
2569 | + } |
|
2064 | 2570 | return ''; |
2065 | 2571 | } |
2066 | 2572 | |
@@ -2103,7 +2609,9 @@ discard block |
||
2103 | 2609 | } |
2104 | 2610 | |
2105 | 2611 | $error = ''; |
2106 | - if ($globalDebug) echo "Notam : Download..."; |
|
2612 | + if ($globalDebug) { |
|
2613 | + echo "Notam : Download..."; |
|
2614 | + } |
|
2107 | 2615 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
2108 | 2616 | if (file_exists($tmp_dir.'notam.rss')) { |
2109 | 2617 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2118,14 +2626,30 @@ discard block |
||
2118 | 2626 | $data['fir'] = $q[0]; |
2119 | 2627 | $data['code'] = $q[1]; |
2120 | 2628 | $ifrvfr = $q[2]; |
2121 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
2122 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
2123 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
2124 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
2125 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
2126 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
2127 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
2128 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
2629 | + if ($ifrvfr == 'IV') { |
|
2630 | + $data['rules'] = 'IFR/VFR'; |
|
2631 | + } |
|
2632 | + if ($ifrvfr == 'I') { |
|
2633 | + $data['rules'] = 'IFR'; |
|
2634 | + } |
|
2635 | + if ($ifrvfr == 'V') { |
|
2636 | + $data['rules'] = 'VFR'; |
|
2637 | + } |
|
2638 | + if ($q[4] == 'A') { |
|
2639 | + $data['scope'] = 'Airport warning'; |
|
2640 | + } |
|
2641 | + if ($q[4] == 'E') { |
|
2642 | + $data['scope'] = 'Enroute warning'; |
|
2643 | + } |
|
2644 | + if ($q[4] == 'W') { |
|
2645 | + $data['scope'] = 'Navigation warning'; |
|
2646 | + } |
|
2647 | + if ($q[4] == 'AE') { |
|
2648 | + $data['scope'] = 'Airport/Enroute warning'; |
|
2649 | + } |
|
2650 | + if ($q[4] == 'AW') { |
|
2651 | + $data['scope'] = 'Airport/Navigation warning'; |
|
2652 | + } |
|
2129 | 2653 | //$data['scope'] = $q[4]; |
2130 | 2654 | $data['lower_limit'] = $q[5]; |
2131 | 2655 | $data['upper_limit'] = $q[6]; |
@@ -2133,8 +2657,12 @@ discard block |
||
2133 | 2657 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
2134 | 2658 | $latitude = $Common->convertDec($las,'latitude'); |
2135 | 2659 | $longitude = $Common->convertDec($lns,'longitude'); |
2136 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
2137 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
2660 | + if ($lac == 'S') { |
|
2661 | + $latitude = '-'.$latitude; |
|
2662 | + } |
|
2663 | + if ($lnc == 'W') { |
|
2664 | + $longitude = '-'.$longitude; |
|
2665 | + } |
|
2138 | 2666 | $data['center_latitude'] = $latitude; |
2139 | 2667 | $data['center_longitude'] = $longitude; |
2140 | 2668 | $data['radius'] = intval($radius); |
@@ -2164,10 +2692,14 @@ discard block |
||
2164 | 2692 | $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
2165 | 2693 | unset($data); |
2166 | 2694 | } |
2167 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2695 | + } else { |
|
2696 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2697 | + } |
|
2168 | 2698 | if ($error != '') { |
2169 | 2699 | return $error; |
2170 | - } elseif ($globalDebug) echo "Done\n"; |
|
2700 | + } elseif ($globalDebug) { |
|
2701 | + echo "Done\n"; |
|
2702 | + } |
|
2171 | 2703 | return ''; |
2172 | 2704 | } |
2173 | 2705 | |
@@ -2192,7 +2724,9 @@ discard block |
||
2192 | 2724 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
2193 | 2725 | $airspace_json = json_decode($airspace_lst,true); |
2194 | 2726 | foreach ($airspace_json['records'] as $airspace) { |
2195 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
2727 | + if ($globalDebug) { |
|
2728 | + echo $airspace['name']."...\n"; |
|
2729 | + } |
|
2196 | 2730 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
2197 | 2731 | if (file_exists($tmp_dir.$airspace['name'])) { |
2198 | 2732 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -2221,8 +2755,11 @@ discard block |
||
2221 | 2755 | return "error : ".$e->getMessage(); |
2222 | 2756 | } |
2223 | 2757 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2224 | - if ($row['nb'] > 0) return false; |
|
2225 | - else return true; |
|
2758 | + if ($row['nb'] > 0) { |
|
2759 | + return false; |
|
2760 | + } else { |
|
2761 | + return true; |
|
2762 | + } |
|
2226 | 2763 | } |
2227 | 2764 | |
2228 | 2765 | public static function insert_last_update() { |
@@ -2247,8 +2784,11 @@ discard block |
||
2247 | 2784 | return "error : ".$e->getMessage(); |
2248 | 2785 | } |
2249 | 2786 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2250 | - if ($row['nb'] > 0) return true; |
|
2251 | - else return false; |
|
2787 | + if ($row['nb'] > 0) { |
|
2788 | + return true; |
|
2789 | + } else { |
|
2790 | + return false; |
|
2791 | + } |
|
2252 | 2792 | } |
2253 | 2793 | |
2254 | 2794 | |
@@ -2279,8 +2819,11 @@ discard block |
||
2279 | 2819 | return "error : ".$e->getMessage(); |
2280 | 2820 | } |
2281 | 2821 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2282 | - if ($row['nb'] > 0) return false; |
|
2283 | - else return true; |
|
2822 | + if ($row['nb'] > 0) { |
|
2823 | + return false; |
|
2824 | + } else { |
|
2825 | + return true; |
|
2826 | + } |
|
2284 | 2827 | } |
2285 | 2828 | |
2286 | 2829 | public static function insert_last_notam_update() { |
@@ -2309,8 +2852,11 @@ discard block |
||
2309 | 2852 | return "error : ".$e->getMessage(); |
2310 | 2853 | } |
2311 | 2854 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2312 | - if ($row['nb'] > 0) return false; |
|
2313 | - else return true; |
|
2855 | + if ($row['nb'] > 0) { |
|
2856 | + return false; |
|
2857 | + } else { |
|
2858 | + return true; |
|
2859 | + } |
|
2314 | 2860 | } |
2315 | 2861 | |
2316 | 2862 | public static function insert_last_airspace_update() { |
@@ -2340,8 +2886,11 @@ discard block |
||
2340 | 2886 | return "error : ".$e->getMessage(); |
2341 | 2887 | } |
2342 | 2888 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2343 | - if ($row['nb'] > 0) return false; |
|
2344 | - else return true; |
|
2889 | + if ($row['nb'] > 0) { |
|
2890 | + return false; |
|
2891 | + } else { |
|
2892 | + return true; |
|
2893 | + } |
|
2345 | 2894 | } |
2346 | 2895 | |
2347 | 2896 | public static function insert_last_owner_update() { |
@@ -2370,8 +2919,11 @@ discard block |
||
2370 | 2919 | return "error : ".$e->getMessage(); |
2371 | 2920 | } |
2372 | 2921 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2373 | - if ($row['nb'] > 0) return false; |
|
2374 | - else return true; |
|
2922 | + if ($row['nb'] > 0) { |
|
2923 | + return false; |
|
2924 | + } else { |
|
2925 | + return true; |
|
2926 | + } |
|
2375 | 2927 | } |
2376 | 2928 | |
2377 | 2929 | public static function insert_last_schedules_update() { |
@@ -2400,8 +2952,11 @@ discard block |
||
2400 | 2952 | return "error : ".$e->getMessage(); |
2401 | 2953 | } |
2402 | 2954 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2403 | - if ($row['nb'] > 0) return false; |
|
2404 | - else return true; |
|
2955 | + if ($row['nb'] > 0) { |
|
2956 | + return false; |
|
2957 | + } else { |
|
2958 | + return true; |
|
2959 | + } |
|
2405 | 2960 | } |
2406 | 2961 | |
2407 | 2962 | public static function insert_last_tle_update() { |
@@ -2430,8 +2985,11 @@ discard block |
||
2430 | 2985 | return "error : ".$e->getMessage(); |
2431 | 2986 | } |
2432 | 2987 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2433 | - if ($row['nb'] > 0) return false; |
|
2434 | - else return true; |
|
2988 | + if ($row['nb'] > 0) { |
|
2989 | + return false; |
|
2990 | + } else { |
|
2991 | + return true; |
|
2992 | + } |
|
2435 | 2993 | } |
2436 | 2994 | |
2437 | 2995 | public static function insert_last_banned_update() { |
@@ -258,7 +258,9 @@ discard block |
||
258 | 258 | // Update table countries |
259 | 259 | if ($Connection->tableExists('airspace')) { |
260 | 260 | $error .= update_db::update_countries(); |
261 | - if ($error != '') return $error; |
|
261 | + if ($error != '') { |
|
262 | + return $error; |
|
263 | + } |
|
262 | 264 | } |
263 | 265 | // Update schema_version to 7 |
264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
314 | 316 | $error = ''; |
315 | 317 | // Update table aircraft |
316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | - if ($error != '') return $error; |
|
319 | + if ($error != '') { |
|
320 | + return $error; |
|
321 | + } |
|
318 | 322 | // Update schema_version to 6 |
319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
331 | 335 | $error = ''; |
332 | 336 | // Update table aircraft |
333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
334 | - if ($error != '') return $error; |
|
338 | + if ($error != '') { |
|
339 | + return $error; |
|
340 | + } |
|
335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
365 | 371 | $error = ''; |
366 | 372 | // Update table atc |
367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
368 | - if ($error != '') return $error; |
|
374 | + if ($error != '') { |
|
375 | + return $error; |
|
376 | + } |
|
369 | 377 | |
370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
389 | 397 | $error = ''; |
390 | 398 | // Add tables |
391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | - if ($error != '') return $error; |
|
400 | + if ($error != '') { |
|
401 | + return $error; |
|
402 | + } |
|
393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
394 | - if ($error != '') return $error; |
|
404 | + if ($error != '') { |
|
405 | + return $error; |
|
406 | + } |
|
395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
396 | - if ($error != '') return $error; |
|
408 | + if ($error != '') { |
|
409 | + return $error; |
|
410 | + } |
|
397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
398 | - if ($error != '') return $error; |
|
412 | + if ($error != '') { |
|
413 | + return $error; |
|
414 | + } |
|
399 | 415 | |
400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
469 | 485 | $error = ''; |
470 | 486 | // Add tables |
471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
472 | - if ($error != '') return $error; |
|
488 | + if ($error != '') { |
|
489 | + return $error; |
|
490 | + } |
|
473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
474 | - if ($error != '') return $error; |
|
492 | + if ($error != '') { |
|
493 | + return $error; |
|
494 | + } |
|
475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
476 | - if ($error != '') return $error; |
|
496 | + if ($error != '') { |
|
497 | + return $error; |
|
498 | + } |
|
477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
478 | - if ($error != '') return $error; |
|
500 | + if ($error != '') { |
|
501 | + return $error; |
|
502 | + } |
|
479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
480 | - if ($error != '') return $error; |
|
504 | + if ($error != '') { |
|
505 | + return $error; |
|
506 | + } |
|
481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
482 | - if ($error != '') return $error; |
|
508 | + if ($error != '') { |
|
509 | + return $error; |
|
510 | + } |
|
483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
484 | - if ($error != '') return $error; |
|
512 | + if ($error != '') { |
|
513 | + return $error; |
|
514 | + } |
|
485 | 515 | |
486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
521 | 551 | // Add tables |
522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | - if ($error != '') return $error; |
|
554 | + if ($error != '') { |
|
555 | + return $error; |
|
556 | + } |
|
525 | 557 | } |
526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
545 | 577 | } catch(PDOException $e) { |
546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 579 | } |
548 | - if ($error != '') return $error; |
|
580 | + if ($error != '') { |
|
581 | + return $error; |
|
582 | + } |
|
549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | 584 | try { |
551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 602 | } |
569 | - if ($error != '') return $error; |
|
603 | + if ($error != '') { |
|
604 | + return $error; |
|
605 | + } |
|
570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | 607 | try { |
572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
584 | 620 | if (!$Connection->tableExists('stats_country')) { |
585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 622 | } |
587 | - if ($error != '') return $error; |
|
623 | + if ($error != '') { |
|
624 | + return $error; |
|
625 | + } |
|
588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | 627 | try { |
590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 646 | } |
609 | 647 | } |
610 | - if ($error != '') return $error; |
|
648 | + if ($error != '') { |
|
649 | + return $error; |
|
650 | + } |
|
611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | 652 | try { |
613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
623 | 663 | $error = ''; |
624 | 664 | // Update airport table |
625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
666 | + if ($error != '') { |
|
667 | + return 'Import airport.sql : '.$error; |
|
668 | + } |
|
627 | 669 | // Remove primary key on Spotter_Archive |
628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 742 | } |
701 | 743 | } |
702 | - if ($error != '') return $error; |
|
744 | + if ($error != '') { |
|
745 | + return $error; |
|
746 | + } |
|
703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | 748 | try { |
705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
717 | 761 | // Update airline table |
718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
764 | + if ($error != '') { |
|
765 | + return 'Import airlines.sql : '.$error; |
|
766 | + } |
|
721 | 767 | } |
722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 776 | } |
731 | 777 | } |
732 | - if ($error != '') return $error; |
|
778 | + if ($error != '') { |
|
779 | + return $error; |
|
780 | + } |
|
733 | 781 | /* |
734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
759 | 807 | } catch(PDOException $e) { |
760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 809 | } |
762 | - if ($error != '') return $error; |
|
810 | + if ($error != '') { |
|
811 | + return $error; |
|
812 | + } |
|
763 | 813 | } |
764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
782 | 832 | } else { |
783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 834 | } |
785 | - if ($error != '') return $error; |
|
835 | + if ($error != '') { |
|
836 | + return $error; |
|
837 | + } |
|
786 | 838 | } |
787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | 840 | try { |
@@ -804,12 +856,16 @@ discard block |
||
804 | 856 | if ($globalDBdriver == 'mysql') { |
805 | 857 | if (!$Connection->tableExists('tle')) { |
806 | 858 | $error .= create_db::import_file('../db/tle.sql'); |
807 | - if ($error != '') return $error; |
|
859 | + if ($error != '') { |
|
860 | + return $error; |
|
861 | + } |
|
808 | 862 | } |
809 | 863 | } else { |
810 | 864 | if (!$Connection->tableExists('tle')) { |
811 | 865 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
812 | - if ($error != '') return $error; |
|
866 | + if ($error != '') { |
|
867 | + return $error; |
|
868 | + } |
|
813 | 869 | } |
814 | 870 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
815 | 871 | try { |
@@ -849,7 +905,9 @@ discard block |
||
849 | 905 | } else { |
850 | 906 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 907 | } |
852 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
908 | + if ($error != '') { |
|
909 | + return 'Import airlines.sql : '.$error; |
|
910 | + } |
|
853 | 911 | if (!$Connection->checkColumnName('airlines','forsource')) { |
854 | 912 | // Add forsource to airlines |
855 | 913 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1332,20 +1390,28 @@ discard block |
||
1332 | 1390 | } |
1333 | 1391 | if ($globalDBdriver == 'mysql') { |
1334 | 1392 | $error .= create_db::import_file('../db/airlines.sql'); |
1335 | - if ($error != '') return $error; |
|
1393 | + if ($error != '') { |
|
1394 | + return $error; |
|
1395 | + } |
|
1336 | 1396 | } else { |
1337 | 1397 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
1338 | - if ($error != '') return $error; |
|
1398 | + if ($error != '') { |
|
1399 | + return $error; |
|
1400 | + } |
|
1339 | 1401 | } |
1340 | 1402 | if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { |
1341 | 1403 | include_once('class/class.update_db.php'); |
1342 | 1404 | if (isset($globalVATSIM) && $globalVATSIM) { |
1343 | 1405 | $error .= update_db::update_vatsim(); |
1344 | - if ($error != '') return $error; |
|
1406 | + if ($error != '') { |
|
1407 | + return $error; |
|
1408 | + } |
|
1345 | 1409 | } |
1346 | 1410 | if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { |
1347 | 1411 | $error .= update_db::update_IVAO(); |
1348 | - if ($error != '') return $error; |
|
1412 | + if ($error != '') { |
|
1413 | + return $error; |
|
1414 | + } |
|
1349 | 1415 | } |
1350 | 1416 | } |
1351 | 1417 | |
@@ -1391,8 +1457,11 @@ discard block |
||
1391 | 1457 | if ($Connection->tableExists('aircraft')) { |
1392 | 1458 | if (!$Connection->tableExists('config')) { |
1393 | 1459 | $version = '1'; |
1394 | - if ($update) return self::update_from_1(); |
|
1395 | - else return $version; |
|
1460 | + if ($update) { |
|
1461 | + return self::update_from_1(); |
|
1462 | + } else { |
|
1463 | + return $version; |
|
1464 | + } |
|
1396 | 1465 | } else { |
1397 | 1466 | $Connection = new Connection(); |
1398 | 1467 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -1406,138 +1475,239 @@ discard block |
||
1406 | 1475 | if ($update) { |
1407 | 1476 | if ($result['value'] == '2') { |
1408 | 1477 | $error = self::update_from_2(); |
1409 | - if ($error != '') return $error; |
|
1410 | - else return self::check_version(true); |
|
1478 | + if ($error != '') { |
|
1479 | + return $error; |
|
1480 | + } else { |
|
1481 | + return self::check_version(true); |
|
1482 | + } |
|
1411 | 1483 | } elseif ($result['value'] == '3') { |
1412 | 1484 | $error = self::update_from_3(); |
1413 | - if ($error != '') return $error; |
|
1414 | - else return self::check_version(true); |
|
1485 | + if ($error != '') { |
|
1486 | + return $error; |
|
1487 | + } else { |
|
1488 | + return self::check_version(true); |
|
1489 | + } |
|
1415 | 1490 | } elseif ($result['value'] == '4') { |
1416 | 1491 | $error = self::update_from_4(); |
1417 | - if ($error != '') return $error; |
|
1418 | - else return self::check_version(true); |
|
1492 | + if ($error != '') { |
|
1493 | + return $error; |
|
1494 | + } else { |
|
1495 | + return self::check_version(true); |
|
1496 | + } |
|
1419 | 1497 | } elseif ($result['value'] == '5') { |
1420 | 1498 | $error = self::update_from_5(); |
1421 | - if ($error != '') return $error; |
|
1422 | - else return self::check_version(true); |
|
1499 | + if ($error != '') { |
|
1500 | + return $error; |
|
1501 | + } else { |
|
1502 | + return self::check_version(true); |
|
1503 | + } |
|
1423 | 1504 | } elseif ($result['value'] == '6') { |
1424 | 1505 | $error = self::update_from_6(); |
1425 | - if ($error != '') return $error; |
|
1426 | - else return self::check_version(true); |
|
1506 | + if ($error != '') { |
|
1507 | + return $error; |
|
1508 | + } else { |
|
1509 | + return self::check_version(true); |
|
1510 | + } |
|
1427 | 1511 | } elseif ($result['value'] == '7') { |
1428 | 1512 | $error = self::update_from_7(); |
1429 | - if ($error != '') return $error; |
|
1430 | - else return self::check_version(true); |
|
1513 | + if ($error != '') { |
|
1514 | + return $error; |
|
1515 | + } else { |
|
1516 | + return self::check_version(true); |
|
1517 | + } |
|
1431 | 1518 | } elseif ($result['value'] == '8') { |
1432 | 1519 | $error = self::update_from_8(); |
1433 | - if ($error != '') return $error; |
|
1434 | - else return self::check_version(true); |
|
1520 | + if ($error != '') { |
|
1521 | + return $error; |
|
1522 | + } else { |
|
1523 | + return self::check_version(true); |
|
1524 | + } |
|
1435 | 1525 | } elseif ($result['value'] == '9') { |
1436 | 1526 | $error = self::update_from_9(); |
1437 | - if ($error != '') return $error; |
|
1438 | - else return self::check_version(true); |
|
1527 | + if ($error != '') { |
|
1528 | + return $error; |
|
1529 | + } else { |
|
1530 | + return self::check_version(true); |
|
1531 | + } |
|
1439 | 1532 | } elseif ($result['value'] == '10') { |
1440 | 1533 | $error = self::update_from_10(); |
1441 | - if ($error != '') return $error; |
|
1442 | - else return self::check_version(true); |
|
1534 | + if ($error != '') { |
|
1535 | + return $error; |
|
1536 | + } else { |
|
1537 | + return self::check_version(true); |
|
1538 | + } |
|
1443 | 1539 | } elseif ($result['value'] == '11') { |
1444 | 1540 | $error = self::update_from_11(); |
1445 | - if ($error != '') return $error; |
|
1446 | - else return self::check_version(true); |
|
1541 | + if ($error != '') { |
|
1542 | + return $error; |
|
1543 | + } else { |
|
1544 | + return self::check_version(true); |
|
1545 | + } |
|
1447 | 1546 | } elseif ($result['value'] == '12') { |
1448 | 1547 | $error = self::update_from_12(); |
1449 | - if ($error != '') return $error; |
|
1450 | - else return self::check_version(true); |
|
1548 | + if ($error != '') { |
|
1549 | + return $error; |
|
1550 | + } else { |
|
1551 | + return self::check_version(true); |
|
1552 | + } |
|
1451 | 1553 | } elseif ($result['value'] == '13') { |
1452 | 1554 | $error = self::update_from_13(); |
1453 | - if ($error != '') return $error; |
|
1454 | - else return self::check_version(true); |
|
1555 | + if ($error != '') { |
|
1556 | + return $error; |
|
1557 | + } else { |
|
1558 | + return self::check_version(true); |
|
1559 | + } |
|
1455 | 1560 | } elseif ($result['value'] == '14') { |
1456 | 1561 | $error = self::update_from_14(); |
1457 | - if ($error != '') return $error; |
|
1458 | - else return self::check_version(true); |
|
1562 | + if ($error != '') { |
|
1563 | + return $error; |
|
1564 | + } else { |
|
1565 | + return self::check_version(true); |
|
1566 | + } |
|
1459 | 1567 | } elseif ($result['value'] == '15') { |
1460 | 1568 | $error = self::update_from_15(); |
1461 | - if ($error != '') return $error; |
|
1462 | - else return self::check_version(true); |
|
1569 | + if ($error != '') { |
|
1570 | + return $error; |
|
1571 | + } else { |
|
1572 | + return self::check_version(true); |
|
1573 | + } |
|
1463 | 1574 | } elseif ($result['value'] == '16') { |
1464 | 1575 | $error = self::update_from_16(); |
1465 | - if ($error != '') return $error; |
|
1466 | - else return self::check_version(true); |
|
1576 | + if ($error != '') { |
|
1577 | + return $error; |
|
1578 | + } else { |
|
1579 | + return self::check_version(true); |
|
1580 | + } |
|
1467 | 1581 | } elseif ($result['value'] == '17') { |
1468 | 1582 | $error = self::update_from_17(); |
1469 | - if ($error != '') return $error; |
|
1470 | - else return self::check_version(true); |
|
1583 | + if ($error != '') { |
|
1584 | + return $error; |
|
1585 | + } else { |
|
1586 | + return self::check_version(true); |
|
1587 | + } |
|
1471 | 1588 | } elseif ($result['value'] == '18') { |
1472 | 1589 | $error = self::update_from_18(); |
1473 | - if ($error != '') return $error; |
|
1474 | - else return self::check_version(true); |
|
1590 | + if ($error != '') { |
|
1591 | + return $error; |
|
1592 | + } else { |
|
1593 | + return self::check_version(true); |
|
1594 | + } |
|
1475 | 1595 | } elseif ($result['value'] == '19') { |
1476 | 1596 | $error = self::update_from_19(); |
1477 | - if ($error != '') return $error; |
|
1478 | - else return self::check_version(true); |
|
1597 | + if ($error != '') { |
|
1598 | + return $error; |
|
1599 | + } else { |
|
1600 | + return self::check_version(true); |
|
1601 | + } |
|
1479 | 1602 | } elseif ($result['value'] == '20') { |
1480 | 1603 | $error = self::update_from_20(); |
1481 | - if ($error != '') return $error; |
|
1482 | - else return self::check_version(true); |
|
1604 | + if ($error != '') { |
|
1605 | + return $error; |
|
1606 | + } else { |
|
1607 | + return self::check_version(true); |
|
1608 | + } |
|
1483 | 1609 | } elseif ($result['value'] == '21') { |
1484 | 1610 | $error = self::update_from_21(); |
1485 | - if ($error != '') return $error; |
|
1486 | - else return self::check_version(true); |
|
1611 | + if ($error != '') { |
|
1612 | + return $error; |
|
1613 | + } else { |
|
1614 | + return self::check_version(true); |
|
1615 | + } |
|
1487 | 1616 | } elseif ($result['value'] == '22') { |
1488 | 1617 | $error = self::update_from_22(); |
1489 | - if ($error != '') return $error; |
|
1490 | - else return self::check_version(true); |
|
1618 | + if ($error != '') { |
|
1619 | + return $error; |
|
1620 | + } else { |
|
1621 | + return self::check_version(true); |
|
1622 | + } |
|
1491 | 1623 | } elseif ($result['value'] == '23') { |
1492 | 1624 | $error = self::update_from_23(); |
1493 | - if ($error != '') return $error; |
|
1494 | - else return self::check_version(true); |
|
1625 | + if ($error != '') { |
|
1626 | + return $error; |
|
1627 | + } else { |
|
1628 | + return self::check_version(true); |
|
1629 | + } |
|
1495 | 1630 | } elseif ($result['value'] == '24') { |
1496 | 1631 | $error = self::update_from_24(); |
1497 | - if ($error != '') return $error; |
|
1498 | - else return self::check_version(true); |
|
1632 | + if ($error != '') { |
|
1633 | + return $error; |
|
1634 | + } else { |
|
1635 | + return self::check_version(true); |
|
1636 | + } |
|
1499 | 1637 | } elseif ($result['value'] == '25') { |
1500 | 1638 | $error = self::update_from_25(); |
1501 | - if ($error != '') return $error; |
|
1502 | - else return self::check_version(true); |
|
1639 | + if ($error != '') { |
|
1640 | + return $error; |
|
1641 | + } else { |
|
1642 | + return self::check_version(true); |
|
1643 | + } |
|
1503 | 1644 | } elseif ($result['value'] == '26') { |
1504 | 1645 | $error = self::update_from_26(); |
1505 | - if ($error != '') return $error; |
|
1506 | - else return self::check_version(true); |
|
1646 | + if ($error != '') { |
|
1647 | + return $error; |
|
1648 | + } else { |
|
1649 | + return self::check_version(true); |
|
1650 | + } |
|
1507 | 1651 | } elseif ($result['value'] == '27') { |
1508 | 1652 | $error = self::update_from_27(); |
1509 | - if ($error != '') return $error; |
|
1510 | - else return self::check_version(true); |
|
1653 | + if ($error != '') { |
|
1654 | + return $error; |
|
1655 | + } else { |
|
1656 | + return self::check_version(true); |
|
1657 | + } |
|
1511 | 1658 | } elseif ($result['value'] == '28') { |
1512 | 1659 | $error = self::update_from_28(); |
1513 | - if ($error != '') return $error; |
|
1514 | - else return self::check_version(true); |
|
1660 | + if ($error != '') { |
|
1661 | + return $error; |
|
1662 | + } else { |
|
1663 | + return self::check_version(true); |
|
1664 | + } |
|
1515 | 1665 | } elseif ($result['value'] == '29') { |
1516 | 1666 | $error = self::update_from_29(); |
1517 | - if ($error != '') return $error; |
|
1518 | - else return self::check_version(true); |
|
1667 | + if ($error != '') { |
|
1668 | + return $error; |
|
1669 | + } else { |
|
1670 | + return self::check_version(true); |
|
1671 | + } |
|
1519 | 1672 | } elseif ($result['value'] == '30') { |
1520 | 1673 | $error = self::update_from_30(); |
1521 | - if ($error != '') return $error; |
|
1522 | - else return self::check_version(true); |
|
1674 | + if ($error != '') { |
|
1675 | + return $error; |
|
1676 | + } else { |
|
1677 | + return self::check_version(true); |
|
1678 | + } |
|
1523 | 1679 | } elseif ($result['value'] == '31') { |
1524 | 1680 | $error = self::update_from_31(); |
1525 | - if ($error != '') return $error; |
|
1526 | - else return self::check_version(true); |
|
1681 | + if ($error != '') { |
|
1682 | + return $error; |
|
1683 | + } else { |
|
1684 | + return self::check_version(true); |
|
1685 | + } |
|
1527 | 1686 | } elseif ($result['value'] == '32') { |
1528 | 1687 | $error = self::update_from_32(); |
1529 | - if ($error != '') return $error; |
|
1530 | - else return self::check_version(true); |
|
1688 | + if ($error != '') { |
|
1689 | + return $error; |
|
1690 | + } else { |
|
1691 | + return self::check_version(true); |
|
1692 | + } |
|
1531 | 1693 | } elseif ($result['value'] == '33') { |
1532 | 1694 | $error = self::update_from_33(); |
1533 | - if ($error != '') return $error; |
|
1534 | - else return self::check_version(true); |
|
1535 | - } else return ''; |
|
1695 | + if ($error != '') { |
|
1696 | + return $error; |
|
1697 | + } else { |
|
1698 | + return self::check_version(true); |
|
1699 | + } |
|
1700 | + } else { |
|
1701 | + return ''; |
|
1702 | + } |
|
1703 | + } else { |
|
1704 | + return $result['value']; |
|
1536 | 1705 | } |
1537 | - else return $result['value']; |
|
1538 | 1706 | } |
1539 | 1707 | |
1540 | - } else return $version; |
|
1708 | + } else { |
|
1709 | + return $version; |
|
1710 | + } |
|
1541 | 1711 | } |
1542 | 1712 | |
1543 | 1713 | } |