@@ -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>'; |
@@ -75,38 +75,38 @@ discard block |
||
75 | 75 | try { |
76 | 76 | //$Connection = new Connection(); |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | - $sth->execute(array(':source' => $database_file)); |
|
79 | - } catch(PDOException $e) { |
|
80 | - return "error : ".$e->getMessage(); |
|
81 | - } |
|
78 | + $sth->execute(array(':source' => $database_file)); |
|
79 | + } catch(PDOException $e) { |
|
80 | + return "error : ".$e->getMessage(); |
|
81 | + } |
|
82 | 82 | |
83 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
84 | - update_db::connect_sqlite($database_file); |
|
83 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
84 | + update_db::connect_sqlite($database_file); |
|
85 | 85 | //$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 | 86 | $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"; |
87 | 87 | try { |
88 | - $sth = update_db::$db_sqlite->prepare($query); |
|
89 | - $sth->execute(); |
|
90 | - } catch(PDOException $e) { |
|
91 | - return "error : ".$e->getMessage(); |
|
92 | - } |
|
88 | + $sth = update_db::$db_sqlite->prepare($query); |
|
89 | + $sth->execute(); |
|
90 | + } catch(PDOException $e) { |
|
91 | + return "error : ".$e->getMessage(); |
|
92 | + } |
|
93 | 93 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
94 | 94 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
95 | 95 | $Connection = new Connection(); |
96 | 96 | $sth_dest = $Connection->db->prepare($query_dest); |
97 | 97 | try { |
98 | 98 | if ($globalTransaction) $Connection->db->beginTransaction(); |
99 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
99 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
100 | 100 | //$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 | 101 | $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 | 102 | $sth_dest->execute($query_dest_values); |
103 | - } |
|
103 | + } |
|
104 | 104 | if ($globalTransaction) $Connection->db->commit(); |
105 | 105 | } catch(PDOException $e) { |
106 | 106 | if ($globalTransaction) $Connection->db->rollBack(); |
107 | 107 | return "error : ".$e->getMessage(); |
108 | 108 | } |
109 | - return ''; |
|
109 | + return ''; |
|
110 | 110 | } |
111 | 111 | public static function retrieve_route_oneworld($database_file) { |
112 | 112 | global $globalDebug, $globalTransaction; |
@@ -117,12 +117,12 @@ discard block |
||
117 | 117 | try { |
118 | 118 | //$Connection = new Connection(); |
119 | 119 | $sth = $Connection->db->prepare($query); |
120 | - $sth->execute(array(':source' => 'oneworld')); |
|
121 | - } catch(PDOException $e) { |
|
122 | - return "error : ".$e->getMessage(); |
|
123 | - } |
|
120 | + $sth->execute(array(':source' => 'oneworld')); |
|
121 | + } catch(PDOException $e) { |
|
122 | + return "error : ".$e->getMessage(); |
|
123 | + } |
|
124 | 124 | |
125 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
125 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
126 | 126 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
127 | 127 | $Spotter = new Spotter(); |
128 | 128 | if ($fh = fopen($database_file,"r")) { |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | } |
147 | 147 | if ($globalTransaction) $Connection->db->commit(); |
148 | 148 | } |
149 | - return ''; |
|
149 | + return ''; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | public static function retrieve_route_skyteam($database_file) { |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | try { |
159 | 159 | //$Connection = new Connection(); |
160 | 160 | $sth = $Connection->db->prepare($query); |
161 | - $sth->execute(array(':source' => 'skyteam')); |
|
162 | - } catch(PDOException $e) { |
|
163 | - return "error : ".$e->getMessage(); |
|
164 | - } |
|
161 | + $sth->execute(array(':source' => 'skyteam')); |
|
162 | + } catch(PDOException $e) { |
|
163 | + return "error : ".$e->getMessage(); |
|
164 | + } |
|
165 | 165 | |
166 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
166 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
167 | 167 | |
168 | 168 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
169 | 169 | $Spotter = new Spotter(); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | return "error : ".$e->getMessage(); |
190 | 190 | } |
191 | 191 | } |
192 | - return ''; |
|
192 | + return ''; |
|
193 | 193 | } |
194 | 194 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
195 | 195 | global $globalTransaction; |
@@ -198,27 +198,27 @@ discard block |
||
198 | 198 | try { |
199 | 199 | $Connection = new Connection(); |
200 | 200 | $sth = $Connection->db->prepare($query); |
201 | - $sth->execute(array(':source' => $database_file)); |
|
202 | - } catch(PDOException $e) { |
|
203 | - return "error : ".$e->getMessage(); |
|
204 | - } |
|
201 | + $sth->execute(array(':source' => $database_file)); |
|
202 | + } catch(PDOException $e) { |
|
203 | + return "error : ".$e->getMessage(); |
|
204 | + } |
|
205 | 205 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
206 | 206 | try { |
207 | 207 | $Connection = new Connection(); |
208 | 208 | $sth = $Connection->db->prepare($query); |
209 | - $sth->execute(array(':source' => $database_file)); |
|
210 | - } catch(PDOException $e) { |
|
211 | - return "error : ".$e->getMessage(); |
|
212 | - } |
|
209 | + $sth->execute(array(':source' => $database_file)); |
|
210 | + } catch(PDOException $e) { |
|
211 | + return "error : ".$e->getMessage(); |
|
212 | + } |
|
213 | 213 | |
214 | - update_db::connect_sqlite($database_file); |
|
214 | + update_db::connect_sqlite($database_file); |
|
215 | 215 | $query = 'select * from Aircraft'; |
216 | 216 | try { |
217 | - $sth = update_db::$db_sqlite->prepare($query); |
|
218 | - $sth->execute(); |
|
219 | - } catch(PDOException $e) { |
|
220 | - return "error : ".$e->getMessage(); |
|
221 | - } |
|
217 | + $sth = update_db::$db_sqlite->prepare($query); |
|
218 | + $sth->execute(); |
|
219 | + } catch(PDOException $e) { |
|
220 | + return "error : ".$e->getMessage(); |
|
221 | + } |
|
222 | 222 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
223 | 223 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
224 | 224 | |
@@ -229,17 +229,17 @@ discard block |
||
229 | 229 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
230 | 230 | try { |
231 | 231 | if ($globalTransaction) $Connection->db->beginTransaction(); |
232 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
232 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
233 | 233 | //$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 | 234 | if ($values['UserString4'] == 'M') $type = 'military'; |
235 | 235 | else $type = null; |
236 | 236 | $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 | 237 | $sth_dest->execute($query_dest_values); |
238 | 238 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
239 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
240 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
239 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
240 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
241 | 241 | } |
242 | - } |
|
242 | + } |
|
243 | 243 | if ($globalTransaction) $Connection->db->commit(); |
244 | 244 | } catch(PDOException $e) { |
245 | 245 | return "error : ".$e->getMessage(); |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $Connection = new Connection(); |
252 | 252 | $sth = $Connection->db->prepare($query); |
253 | - $sth->execute(array(':source' => $database_file)); |
|
254 | - } catch(PDOException $e) { |
|
255 | - return "error : ".$e->getMessage(); |
|
256 | - } |
|
253 | + $sth->execute(array(':source' => $database_file)); |
|
254 | + } catch(PDOException $e) { |
|
255 | + return "error : ".$e->getMessage(); |
|
256 | + } |
|
257 | 257 | return ''; |
258 | 258 | } |
259 | 259 | |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $Connection = new Connection(); |
267 | 267 | $sth = $Connection->db->prepare($query); |
268 | - $sth->execute(array(':source' => $database_file)); |
|
269 | - } catch(PDOException $e) { |
|
270 | - return "error : ".$e->getMessage(); |
|
271 | - } |
|
268 | + $sth->execute(array(':source' => $database_file)); |
|
269 | + } catch(PDOException $e) { |
|
270 | + return "error : ".$e->getMessage(); |
|
271 | + } |
|
272 | 272 | |
273 | 273 | if ($fh = fopen($database_file,"r")) { |
274 | 274 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -278,26 +278,26 @@ discard block |
||
278 | 278 | $sth_dest = $Connection->db->prepare($query_dest); |
279 | 279 | try { |
280 | 280 | if ($globalTransaction) $Connection->db->beginTransaction(); |
281 | - while (!feof($fh)) { |
|
282 | - $values = array(); |
|
283 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
281 | + while (!feof($fh)) { |
|
282 | + $values = array(); |
|
283 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
284 | 284 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
285 | - $values['ModeS'] = substr($line,0,6); |
|
286 | - $values['Registration'] = trim(substr($line,69,6)); |
|
287 | - $aircraft_name = trim(substr($line,48,6)); |
|
288 | - // Check if we can find ICAO, else set it to GLID |
|
289 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
290 | - $search_more = ''; |
|
291 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
292 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
293 | - $sth_search = $Connection->db->prepare($query_search); |
|
285 | + $values['ModeS'] = substr($line,0,6); |
|
286 | + $values['Registration'] = trim(substr($line,69,6)); |
|
287 | + $aircraft_name = trim(substr($line,48,6)); |
|
288 | + // Check if we can find ICAO, else set it to GLID |
|
289 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
290 | + $search_more = ''; |
|
291 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
292 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
293 | + $sth_search = $Connection->db->prepare($query_search); |
|
294 | 294 | try { |
295 | - $sth_search->execute(); |
|
296 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
297 | - //if (count($result) > 0) { |
|
298 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
299 | - $values['ICAOTypeCode'] = $result['icao']; |
|
300 | - } |
|
295 | + $sth_search->execute(); |
|
296 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
297 | + //if (count($result) > 0) { |
|
298 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
299 | + $values['ICAOTypeCode'] = $result['icao']; |
|
300 | + } |
|
301 | 301 | } catch(PDOException $e) { |
302 | 302 | return "error : ".$e->getMessage(); |
303 | 303 | } |
@@ -320,10 +320,10 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $Connection = new Connection(); |
322 | 322 | $sth = $Connection->db->prepare($query); |
323 | - $sth->execute(array(':source' => $database_file)); |
|
324 | - } catch(PDOException $e) { |
|
325 | - return "error : ".$e->getMessage(); |
|
326 | - } |
|
323 | + $sth->execute(array(':source' => $database_file)); |
|
324 | + } catch(PDOException $e) { |
|
325 | + return "error : ".$e->getMessage(); |
|
326 | + } |
|
327 | 327 | return ''; |
328 | 328 | } |
329 | 329 | |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | try { |
335 | 335 | $Connection = new Connection(); |
336 | 336 | $sth = $Connection->db->prepare($query); |
337 | - $sth->execute(array(':source' => $database_file)); |
|
338 | - } catch(PDOException $e) { |
|
339 | - return "error : ".$e->getMessage(); |
|
340 | - } |
|
337 | + $sth->execute(array(':source' => $database_file)); |
|
338 | + } catch(PDOException $e) { |
|
339 | + return "error : ".$e->getMessage(); |
|
340 | + } |
|
341 | 341 | |
342 | 342 | if ($fh = fopen($database_file,"r")) { |
343 | 343 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -348,24 +348,24 @@ discard block |
||
348 | 348 | try { |
349 | 349 | if ($globalTransaction) $Connection->db->beginTransaction(); |
350 | 350 | $tmp = fgetcsv($fh,9999,',',"'"); |
351 | - while (!feof($fh)) { |
|
352 | - $line = fgetcsv($fh,9999,',',"'"); |
|
351 | + while (!feof($fh)) { |
|
352 | + $line = fgetcsv($fh,9999,',',"'"); |
|
353 | 353 | |
354 | 354 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
355 | 355 | //print_r($line); |
356 | - $values['ModeS'] = $line[1]; |
|
357 | - $values['Registration'] = $line[3]; |
|
358 | - $aircraft_name = $line[2]; |
|
359 | - // Check if we can find ICAO, else set it to GLID |
|
360 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
361 | - $search_more = ''; |
|
362 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
363 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
364 | - $sth_search = $Connection->db->prepare($query_search); |
|
356 | + $values['ModeS'] = $line[1]; |
|
357 | + $values['Registration'] = $line[3]; |
|
358 | + $aircraft_name = $line[2]; |
|
359 | + // Check if we can find ICAO, else set it to GLID |
|
360 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
361 | + $search_more = ''; |
|
362 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
363 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
364 | + $sth_search = $Connection->db->prepare($query_search); |
|
365 | 365 | try { |
366 | - $sth_search->execute(); |
|
367 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
368 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
366 | + $sth_search->execute(); |
|
367 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
368 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
369 | 369 | } catch(PDOException $e) { |
370 | 370 | return "error : ".$e->getMessage(); |
371 | 371 | } |
@@ -388,10 +388,10 @@ discard block |
||
388 | 388 | try { |
389 | 389 | $Connection = new Connection(); |
390 | 390 | $sth = $Connection->db->prepare($query); |
391 | - $sth->execute(array(':source' => $database_file)); |
|
392 | - } catch(PDOException $e) { |
|
393 | - return "error : ".$e->getMessage(); |
|
394 | - } |
|
391 | + $sth->execute(array(':source' => $database_file)); |
|
392 | + } catch(PDOException $e) { |
|
393 | + return "error : ".$e->getMessage(); |
|
394 | + } |
|
395 | 395 | return ''; |
396 | 396 | } |
397 | 397 | |
@@ -402,10 +402,10 @@ discard block |
||
402 | 402 | try { |
403 | 403 | $Connection = new Connection(); |
404 | 404 | $sth = $Connection->db->prepare($query); |
405 | - $sth->execute(array(':source' => $database_file)); |
|
406 | - } catch(PDOException $e) { |
|
407 | - return "error : ".$e->getMessage(); |
|
408 | - } |
|
405 | + $sth->execute(array(':source' => $database_file)); |
|
406 | + } catch(PDOException $e) { |
|
407 | + return "error : ".$e->getMessage(); |
|
408 | + } |
|
409 | 409 | |
410 | 410 | if ($fh = fopen($database_file,"r")) { |
411 | 411 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -416,95 +416,95 @@ discard block |
||
416 | 416 | try { |
417 | 417 | if ($globalTransaction) $Connection->db->beginTransaction(); |
418 | 418 | $tmp = fgetcsv($fh,9999,',','"'); |
419 | - while (!feof($fh)) { |
|
420 | - $line = fgetcsv($fh,9999,',','"'); |
|
421 | - $values = array(); |
|
422 | - //print_r($line); |
|
423 | - if ($country == 'F') { |
|
424 | - $values['registration'] = $line[0]; |
|
425 | - $values['base'] = $line[4]; |
|
426 | - $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])); |
|
429 | - $values['cancel'] = $line[7]; |
|
419 | + while (!feof($fh)) { |
|
420 | + $line = fgetcsv($fh,9999,',','"'); |
|
421 | + $values = array(); |
|
422 | + //print_r($line); |
|
423 | + if ($country == 'F') { |
|
424 | + $values['registration'] = $line[0]; |
|
425 | + $values['base'] = $line[4]; |
|
426 | + $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])); |
|
429 | + $values['cancel'] = $line[7]; |
|
430 | 430 | } elseif ($country == 'EI') { |
431 | - // TODO : add modeS & reg to aircraft_modes |
|
432 | - $values['registration'] = $line[0]; |
|
433 | - $values['base'] = $line[3]; |
|
434 | - $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])); |
|
437 | - $values['cancel'] = ''; |
|
431 | + // TODO : add modeS & reg to aircraft_modes |
|
432 | + $values['registration'] = $line[0]; |
|
433 | + $values['base'] = $line[3]; |
|
434 | + $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])); |
|
437 | + $values['cancel'] = ''; |
|
438 | 438 | } elseif ($country == 'HB') { |
439 | - // TODO : add modeS & reg to aircraft_modes |
|
440 | - $values['registration'] = $line[0]; |
|
441 | - $values['base'] = null; |
|
442 | - $values['owner'] = $line[5]; |
|
443 | - $values['date_first_reg'] = null; |
|
444 | - $values['cancel'] = ''; |
|
439 | + // TODO : add modeS & reg to aircraft_modes |
|
440 | + $values['registration'] = $line[0]; |
|
441 | + $values['base'] = null; |
|
442 | + $values['owner'] = $line[5]; |
|
443 | + $values['date_first_reg'] = null; |
|
444 | + $values['cancel'] = ''; |
|
445 | 445 | } elseif ($country == 'OK') { |
446 | - // TODO : add modeS & reg to aircraft_modes |
|
447 | - $values['registration'] = $line[3]; |
|
448 | - $values['base'] = null; |
|
449 | - $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])); |
|
452 | - $values['cancel'] = ''; |
|
446 | + // TODO : add modeS & reg to aircraft_modes |
|
447 | + $values['registration'] = $line[3]; |
|
448 | + $values['base'] = null; |
|
449 | + $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])); |
|
452 | + $values['cancel'] = ''; |
|
453 | 453 | } elseif ($country == 'VH') { |
454 | - // TODO : add modeS & reg to aircraft_modes |
|
455 | - $values['registration'] = $line[0]; |
|
456 | - $values['base'] = null; |
|
457 | - $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])); |
|
460 | - |
|
461 | - $values['cancel'] = $line[39]; |
|
454 | + // TODO : add modeS & reg to aircraft_modes |
|
455 | + $values['registration'] = $line[0]; |
|
456 | + $values['base'] = null; |
|
457 | + $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])); |
|
460 | + |
|
461 | + $values['cancel'] = $line[39]; |
|
462 | 462 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
463 | - $values['registration'] = $line[0]; |
|
464 | - $values['base'] = null; |
|
465 | - $values['owner'] = $line[4]; |
|
466 | - $values['date_first_reg'] = null; |
|
467 | - $values['cancel'] = ''; |
|
463 | + $values['registration'] = $line[0]; |
|
464 | + $values['base'] = null; |
|
465 | + $values['owner'] = $line[4]; |
|
466 | + $values['date_first_reg'] = null; |
|
467 | + $values['cancel'] = ''; |
|
468 | 468 | } elseif ($country == 'CC') { |
469 | - $values['registration'] = $line[0]; |
|
470 | - $values['base'] = null; |
|
471 | - $values['owner'] = $line[6]; |
|
472 | - $values['date_first_reg'] = null; |
|
473 | - $values['cancel'] = ''; |
|
469 | + $values['registration'] = $line[0]; |
|
470 | + $values['base'] = null; |
|
471 | + $values['owner'] = $line[6]; |
|
472 | + $values['date_first_reg'] = null; |
|
473 | + $values['cancel'] = ''; |
|
474 | 474 | } elseif ($country == 'HJ') { |
475 | - $values['registration'] = $line[0]; |
|
476 | - $values['base'] = null; |
|
477 | - $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])); |
|
480 | - $values['cancel'] = ''; |
|
475 | + $values['registration'] = $line[0]; |
|
476 | + $values['base'] = null; |
|
477 | + $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])); |
|
480 | + $values['cancel'] = ''; |
|
481 | 481 | } elseif ($country == 'PP') { |
482 | - $values['registration'] = $line[0]; |
|
483 | - $values['base'] = null; |
|
484 | - $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])); |
|
487 | - $values['cancel'] = $line[7]; |
|
482 | + $values['registration'] = $line[0]; |
|
483 | + $values['base'] = null; |
|
484 | + $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])); |
|
487 | + $values['cancel'] = $line[7]; |
|
488 | 488 | } elseif ($country == 'E7') { |
489 | - $values['registration'] = $line[0]; |
|
490 | - $values['base'] = null; |
|
491 | - $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])); |
|
494 | - $values['cancel'] = ''; |
|
489 | + $values['registration'] = $line[0]; |
|
490 | + $values['base'] = null; |
|
491 | + $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])); |
|
494 | + $values['cancel'] = ''; |
|
495 | 495 | } elseif ($country == '8Q') { |
496 | - $values['registration'] = $line[0]; |
|
497 | - $values['base'] = null; |
|
498 | - $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])); |
|
501 | - $values['cancel'] = ''; |
|
496 | + $values['registration'] = $line[0]; |
|
497 | + $values['base'] = null; |
|
498 | + $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])); |
|
501 | + $values['cancel'] = ''; |
|
502 | 502 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
503 | - $values['registration'] = $line[0]; |
|
504 | - $values['base'] = null; |
|
505 | - $values['owner'] = $line[3]; |
|
506 | - $values['date_first_reg'] = null; |
|
507 | - $values['cancel'] = ''; |
|
503 | + $values['registration'] = $line[0]; |
|
504 | + $values['base'] = null; |
|
505 | + $values['owner'] = $line[3]; |
|
506 | + $values['date_first_reg'] = null; |
|
507 | + $values['cancel'] = ''; |
|
508 | 508 | } |
509 | 509 | if ($values['cancel'] == '' && $values['registration'] != null) { |
510 | 510 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -626,20 +626,20 @@ discard block |
||
626 | 626 | try { |
627 | 627 | $Connection = new Connection(); |
628 | 628 | $sth = $Connection->db->prepare($query); |
629 | - $sth->execute(); |
|
630 | - } catch(PDOException $e) { |
|
631 | - return "error : ".$e->getMessage(); |
|
632 | - } |
|
629 | + $sth->execute(); |
|
630 | + } catch(PDOException $e) { |
|
631 | + return "error : ".$e->getMessage(); |
|
632 | + } |
|
633 | 633 | |
634 | 634 | |
635 | 635 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
636 | 636 | try { |
637 | 637 | $Connection = new Connection(); |
638 | 638 | $sth = $Connection->db->prepare($query); |
639 | - $sth->execute(); |
|
640 | - } catch(PDOException $e) { |
|
641 | - return "error : ".$e->getMessage(); |
|
642 | - } |
|
639 | + $sth->execute(); |
|
640 | + } catch(PDOException $e) { |
|
641 | + return "error : ".$e->getMessage(); |
|
642 | + } |
|
643 | 643 | |
644 | 644 | $query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`) |
645 | 645 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
@@ -705,10 +705,10 @@ discard block |
||
705 | 705 | try { |
706 | 706 | $Connection = new Connection(); |
707 | 707 | $sth = $Connection->db->prepare($query); |
708 | - $sth->execute(); |
|
709 | - } catch(PDOException $e) { |
|
710 | - return "error : ".$e->getMessage(); |
|
711 | - } |
|
708 | + $sth->execute(); |
|
709 | + } catch(PDOException $e) { |
|
710 | + return "error : ".$e->getMessage(); |
|
711 | + } |
|
712 | 712 | |
713 | 713 | |
714 | 714 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
@@ -718,10 +718,10 @@ discard block |
||
718 | 718 | try { |
719 | 719 | $Connection = new Connection(); |
720 | 720 | $sth = $Connection->db->prepare($query); |
721 | - $sth->execute($query_values); |
|
722 | - } catch(PDOException $e) { |
|
723 | - return "error : ".$e->getMessage(); |
|
724 | - } |
|
721 | + $sth->execute($query_values); |
|
722 | + } catch(PDOException $e) { |
|
723 | + return "error : ".$e->getMessage(); |
|
724 | + } |
|
725 | 725 | $i++; |
726 | 726 | /* |
727 | 727 | $query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)'; |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | |
836 | 836 | |
837 | 837 | |
838 | - return "success"; |
|
838 | + return "success"; |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | public static function translation() { |
@@ -851,10 +851,10 @@ discard block |
||
851 | 851 | try { |
852 | 852 | $Connection = new Connection(); |
853 | 853 | $sth = $Connection->db->prepare($query); |
854 | - $sth->execute(array(':source' => 'translation.csv')); |
|
855 | - } catch(PDOException $e) { |
|
856 | - return "error : ".$e->getMessage(); |
|
857 | - } |
|
854 | + $sth->execute(array(':source' => 'translation.csv')); |
|
855 | + } catch(PDOException $e) { |
|
856 | + return "error : ".$e->getMessage(); |
|
857 | + } |
|
858 | 858 | |
859 | 859 | |
860 | 860 | //update_db::unzip($out_file); |
@@ -873,21 +873,21 @@ discard block |
||
873 | 873 | $data = $row; |
874 | 874 | $operator = $data[2]; |
875 | 875 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
876 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
877 | - //echo substr($operator, 0, 2)."\n";; |
|
878 | - if (count($airline_array) > 0) { |
|
876 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
877 | + //echo substr($operator, 0, 2)."\n";; |
|
878 | + if (count($airline_array) > 0) { |
|
879 | 879 | //print_r($airline_array); |
880 | 880 | $operator = $airline_array[0]['icao'].substr($operator,2); |
881 | - } |
|
882 | - } |
|
881 | + } |
|
882 | + } |
|
883 | 883 | |
884 | 884 | $operator_correct = $data[3]; |
885 | 885 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
886 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
887 | - if (count($airline_array) > 0) { |
|
888 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
889 | - } |
|
890 | - } |
|
886 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
887 | + if (count($airline_array) > 0) { |
|
888 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
889 | + } |
|
890 | + } |
|
891 | 891 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
892 | 892 | try { |
893 | 893 | $sth = $Connection->db->prepare($query); |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | //$Connection->db->commit(); |
902 | 902 | } |
903 | 903 | return ''; |
904 | - } |
|
904 | + } |
|
905 | 905 | |
906 | 906 | public static function translation_fam() { |
907 | 907 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -911,10 +911,10 @@ discard block |
||
911 | 911 | try { |
912 | 912 | $Connection = new Connection(); |
913 | 913 | $sth = $Connection->db->prepare($query); |
914 | - $sth->execute(array(':source' => 'website_fam')); |
|
915 | - } catch(PDOException $e) { |
|
916 | - return "error : ".$e->getMessage(); |
|
917 | - } |
|
914 | + $sth->execute(array(':source' => 'website_fam')); |
|
915 | + } catch(PDOException $e) { |
|
916 | + return "error : ".$e->getMessage(); |
|
917 | + } |
|
918 | 918 | |
919 | 919 | |
920 | 920 | //update_db::unzip($out_file); |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | //$Connection->db->commit(); |
944 | 944 | } |
945 | 945 | return ''; |
946 | - } |
|
946 | + } |
|
947 | 947 | |
948 | 948 | /* |
949 | 949 | * This function use FAA public data. |
@@ -955,19 +955,19 @@ discard block |
||
955 | 955 | try { |
956 | 956 | $Connection = new Connection(); |
957 | 957 | $sth = $Connection->db->prepare($query); |
958 | - $sth->execute(array(':source' => 'website_faa')); |
|
959 | - } catch(PDOException $e) { |
|
960 | - return "error : ".$e->getMessage(); |
|
961 | - } |
|
958 | + $sth->execute(array(':source' => 'website_faa')); |
|
959 | + } catch(PDOException $e) { |
|
960 | + return "error : ".$e->getMessage(); |
|
961 | + } |
|
962 | 962 | |
963 | 963 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; |
964 | 964 | try { |
965 | 965 | $Connection = new Connection(); |
966 | 966 | $sth = $Connection->db->prepare($query); |
967 | - $sth->execute(array(':source' => 'website_faa')); |
|
968 | - } catch(PDOException $e) { |
|
969 | - return "error : ".$e->getMessage(); |
|
970 | - } |
|
967 | + $sth->execute(array(':source' => 'website_faa')); |
|
968 | + } catch(PDOException $e) { |
|
969 | + return "error : ".$e->getMessage(); |
|
970 | + } |
|
971 | 971 | |
972 | 972 | $delimiter = ","; |
973 | 973 | $mfr = array(); |
@@ -1043,17 +1043,17 @@ discard block |
||
1043 | 1043 | } |
1044 | 1044 | print_r($mfr); |
1045 | 1045 | return ''; |
1046 | - } |
|
1046 | + } |
|
1047 | 1047 | public static function modes_fam() { |
1048 | 1048 | global $tmp_dir, $globalTransaction; |
1049 | 1049 | $query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source"; |
1050 | 1050 | try { |
1051 | 1051 | $Connection = new Connection(); |
1052 | 1052 | $sth = $Connection->db->prepare($query); |
1053 | - $sth->execute(array(':source' => 'website_fam')); |
|
1054 | - } catch(PDOException $e) { |
|
1055 | - return "error : ".$e->getMessage(); |
|
1056 | - } |
|
1053 | + $sth->execute(array(':source' => 'website_fam')); |
|
1054 | + } catch(PDOException $e) { |
|
1055 | + return "error : ".$e->getMessage(); |
|
1056 | + } |
|
1057 | 1057 | |
1058 | 1058 | |
1059 | 1059 | //update_db::unzip($out_file); |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | if ($globalTransaction) $Connection->db->commit(); |
1083 | 1083 | } |
1084 | 1084 | return ''; |
1085 | - } |
|
1085 | + } |
|
1086 | 1086 | |
1087 | 1087 | public static function owner_fam() { |
1088 | 1088 | global $tmp_dir, $globalTransaction; |
@@ -1090,10 +1090,10 @@ discard block |
||
1090 | 1090 | try { |
1091 | 1091 | $Connection = new Connection(); |
1092 | 1092 | $sth = $Connection->db->prepare($query); |
1093 | - $sth->execute(array(':source' => 'website_fam')); |
|
1094 | - } catch(PDOException $e) { |
|
1095 | - return "error : ".$e->getMessage(); |
|
1096 | - } |
|
1093 | + $sth->execute(array(':source' => 'website_fam')); |
|
1094 | + } catch(PDOException $e) { |
|
1095 | + return "error : ".$e->getMessage(); |
|
1096 | + } |
|
1097 | 1097 | |
1098 | 1098 | $delimiter = "\t"; |
1099 | 1099 | $Connection = new Connection(); |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | if ($globalTransaction) $Connection->db->commit(); |
1120 | 1120 | } |
1121 | 1121 | return ''; |
1122 | - } |
|
1122 | + } |
|
1123 | 1123 | |
1124 | 1124 | public static function routes_fam() { |
1125 | 1125 | global $tmp_dir, $globalTransaction; |
@@ -1127,10 +1127,10 @@ discard block |
||
1127 | 1127 | try { |
1128 | 1128 | $Connection = new Connection(); |
1129 | 1129 | $sth = $Connection->db->prepare($query); |
1130 | - $sth->execute(array(':source' => 'website_fam')); |
|
1131 | - } catch(PDOException $e) { |
|
1132 | - return "error : ".$e->getMessage(); |
|
1133 | - } |
|
1130 | + $sth->execute(array(':source' => 'website_fam')); |
|
1131 | + } catch(PDOException $e) { |
|
1132 | + return "error : ".$e->getMessage(); |
|
1133 | + } |
|
1134 | 1134 | |
1135 | 1135 | |
1136 | 1136 | //update_db::unzip($out_file); |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | if ($globalTransaction) $Connection->db->commit(); |
1160 | 1160 | } |
1161 | 1161 | return ''; |
1162 | - } |
|
1162 | + } |
|
1163 | 1163 | |
1164 | 1164 | public static function banned_fam() { |
1165 | 1165 | global $tmp_dir, $globalTransaction; |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | if ($globalTransaction) $Connection->db->commit(); |
1192 | 1192 | } |
1193 | 1193 | return ''; |
1194 | - } |
|
1194 | + } |
|
1195 | 1195 | |
1196 | 1196 | public static function tle($filename,$tletype) { |
1197 | 1197 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1202,10 +1202,10 @@ discard block |
||
1202 | 1202 | try { |
1203 | 1203 | $Connection = new Connection(); |
1204 | 1204 | $sth = $Connection->db->prepare($query); |
1205 | - $sth->execute(array(':source' => $filename)); |
|
1206 | - } catch(PDOException $e) { |
|
1207 | - return "error : ".$e->getMessage(); |
|
1208 | - } |
|
1205 | + $sth->execute(array(':source' => $filename)); |
|
1206 | + } catch(PDOException $e) { |
|
1207 | + return "error : ".$e->getMessage(); |
|
1208 | + } |
|
1209 | 1209 | |
1210 | 1210 | $Connection = new Connection(); |
1211 | 1211 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1240,54 +1240,54 @@ discard block |
||
1240 | 1240 | //$Connection->db->commit(); |
1241 | 1241 | } |
1242 | 1242 | return ''; |
1243 | - } |
|
1243 | + } |
|
1244 | 1244 | |
1245 | 1245 | /** |
1246 | - * Convert a HTML table to an array |
|
1247 | - * @param String $data HTML page |
|
1248 | - * @return Array array of the tables in HTML page |
|
1249 | - */ |
|
1250 | - private static function table2array($data) { |
|
1251 | - $html = str_get_html($data); |
|
1252 | - $tabledata=array(); |
|
1253 | - foreach($html->find('tr') as $element) |
|
1254 | - { |
|
1255 | - $td = array(); |
|
1256 | - foreach( $element->find('th') as $row) |
|
1257 | - { |
|
1258 | - $td [] = trim($row->plaintext); |
|
1259 | - } |
|
1260 | - $td=array_filter($td); |
|
1261 | - $tabledata[] = $td; |
|
1262 | - |
|
1263 | - $td = array(); |
|
1264 | - $tdi = array(); |
|
1265 | - foreach( $element->find('td') as $row) |
|
1266 | - { |
|
1267 | - $td [] = trim($row->plaintext); |
|
1268 | - $tdi [] = trim($row->innertext); |
|
1269 | - } |
|
1270 | - $td=array_filter($td); |
|
1271 | - $tdi=array_filter($tdi); |
|
1272 | - // $tabledata[]=array_merge($td,$tdi); |
|
1273 | - $tabledata[]=$td; |
|
1274 | - } |
|
1275 | - return(array_filter($tabledata)); |
|
1276 | - } |
|
1277 | - |
|
1278 | - /** |
|
1279 | - * Get data from form result |
|
1280 | - * @param String $url form URL |
|
1281 | - * @return String the result |
|
1282 | - */ |
|
1283 | - private static function getData($url) { |
|
1284 | - $ch = curl_init(); |
|
1285 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
1286 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1287 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1288 | - 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'); |
|
1289 | - return curl_exec($ch); |
|
1290 | - } |
|
1246 | + * Convert a HTML table to an array |
|
1247 | + * @param String $data HTML page |
|
1248 | + * @return Array array of the tables in HTML page |
|
1249 | + */ |
|
1250 | + private static function table2array($data) { |
|
1251 | + $html = str_get_html($data); |
|
1252 | + $tabledata=array(); |
|
1253 | + foreach($html->find('tr') as $element) |
|
1254 | + { |
|
1255 | + $td = array(); |
|
1256 | + foreach( $element->find('th') as $row) |
|
1257 | + { |
|
1258 | + $td [] = trim($row->plaintext); |
|
1259 | + } |
|
1260 | + $td=array_filter($td); |
|
1261 | + $tabledata[] = $td; |
|
1262 | + |
|
1263 | + $td = array(); |
|
1264 | + $tdi = array(); |
|
1265 | + foreach( $element->find('td') as $row) |
|
1266 | + { |
|
1267 | + $td [] = trim($row->plaintext); |
|
1268 | + $tdi [] = trim($row->innertext); |
|
1269 | + } |
|
1270 | + $td=array_filter($td); |
|
1271 | + $tdi=array_filter($tdi); |
|
1272 | + // $tabledata[]=array_merge($td,$tdi); |
|
1273 | + $tabledata[]=$td; |
|
1274 | + } |
|
1275 | + return(array_filter($tabledata)); |
|
1276 | + } |
|
1277 | + |
|
1278 | + /** |
|
1279 | + * Get data from form result |
|
1280 | + * @param String $url form URL |
|
1281 | + * @return String the result |
|
1282 | + */ |
|
1283 | + private static function getData($url) { |
|
1284 | + $ch = curl_init(); |
|
1285 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
1286 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
1287 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
1288 | + 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'); |
|
1289 | + return curl_exec($ch); |
|
1290 | + } |
|
1291 | 1291 | /* |
1292 | 1292 | public static function waypoints() { |
1293 | 1293 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -1370,7 +1370,7 @@ discard block |
||
1370 | 1370 | if ($globalTransaction) $Connection->db->commit(); |
1371 | 1371 | } |
1372 | 1372 | return ''; |
1373 | - } |
|
1373 | + } |
|
1374 | 1374 | |
1375 | 1375 | public static function ivao_airlines($filename) { |
1376 | 1376 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1380,10 +1380,10 @@ discard block |
||
1380 | 1380 | try { |
1381 | 1381 | $Connection = new Connection(); |
1382 | 1382 | $sth = $Connection->db->prepare($query); |
1383 | - $sth->execute(); |
|
1384 | - } catch(PDOException $e) { |
|
1385 | - return "error : ".$e->getMessage(); |
|
1386 | - } |
|
1383 | + $sth->execute(); |
|
1384 | + } catch(PDOException $e) { |
|
1385 | + return "error : ".$e->getMessage(); |
|
1386 | + } |
|
1387 | 1387 | |
1388 | 1388 | $header = NULL; |
1389 | 1389 | $delimiter = ':'; |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | if ($globalTransaction) $Connection->db->commit(); |
1408 | 1408 | } |
1409 | 1409 | return ''; |
1410 | - } |
|
1410 | + } |
|
1411 | 1411 | |
1412 | 1412 | public static function update_airspace() { |
1413 | 1413 | global $tmp_dir, $globalDBdriver; |
@@ -1417,11 +1417,11 @@ discard block |
||
1417 | 1417 | $query = 'DROP TABLE airspace'; |
1418 | 1418 | try { |
1419 | 1419 | $sth = $Connection->db->prepare($query); |
1420 | - $sth->execute(); |
|
1421 | - } catch(PDOException $e) { |
|
1420 | + $sth->execute(); |
|
1421 | + } catch(PDOException $e) { |
|
1422 | 1422 | return "error : ".$e->getMessage(); |
1423 | - } |
|
1424 | - } |
|
1423 | + } |
|
1424 | + } |
|
1425 | 1425 | |
1426 | 1426 | |
1427 | 1427 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1476,10 +1476,10 @@ discard block |
||
1476 | 1476 | $query = 'DROP TABLE countries'; |
1477 | 1477 | try { |
1478 | 1478 | $sth = $Connection->db->prepare($query); |
1479 | - $sth->execute(); |
|
1480 | - } catch(PDOException $e) { |
|
1481 | - echo "error : ".$e->getMessage(); |
|
1482 | - } |
|
1479 | + $sth->execute(); |
|
1480 | + } catch(PDOException $e) { |
|
1481 | + echo "error : ".$e->getMessage(); |
|
1482 | + } |
|
1483 | 1483 | } |
1484 | 1484 | if ($globalDBdriver == 'mysql') { |
1485 | 1485 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -1954,11 +1954,11 @@ discard block |
||
1954 | 1954 | $query = 'DROP TABLE airspace'; |
1955 | 1955 | try { |
1956 | 1956 | $sth = $Connection->db->prepare($query); |
1957 | - $sth->execute(); |
|
1958 | - } catch(PDOException $e) { |
|
1957 | + $sth->execute(); |
|
1958 | + } catch(PDOException $e) { |
|
1959 | 1959 | return "error : ".$e->getMessage(); |
1960 | - } |
|
1961 | - } |
|
1960 | + } |
|
1961 | + } |
|
1962 | 1962 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
1963 | 1963 | update_db::insert_airspace_version($airspace_md5); |
1964 | 1964 | } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
@@ -2078,12 +2078,12 @@ discard block |
||
2078 | 2078 | echo $data; |
2079 | 2079 | */ |
2080 | 2080 | if (file_exists($tmp_dir.'aircrafts.html')) { |
2081 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2082 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2083 | - $result = fread($fh,100000000); |
|
2084 | - //echo $result; |
|
2085 | - //var_dump(str_get_html($result)); |
|
2086 | - //print_r(self::table2array($result)); |
|
2081 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
2082 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2083 | + $result = fread($fh,100000000); |
|
2084 | + //echo $result; |
|
2085 | + //var_dump(str_get_html($result)); |
|
2086 | + //print_r(self::table2array($result)); |
|
2087 | 2087 | } |
2088 | 2088 | |
2089 | 2089 | } |
@@ -2097,10 +2097,10 @@ discard block |
||
2097 | 2097 | try { |
2098 | 2098 | $Connection = new Connection(); |
2099 | 2099 | $sth = $Connection->db->prepare($query); |
2100 | - $sth->execute(); |
|
2101 | - } catch(PDOException $e) { |
|
2102 | - return "error : ".$e->getMessage(); |
|
2103 | - } |
|
2100 | + $sth->execute(); |
|
2101 | + } catch(PDOException $e) { |
|
2102 | + return "error : ".$e->getMessage(); |
|
2103 | + } |
|
2104 | 2104 | |
2105 | 2105 | $error = ''; |
2106 | 2106 | if ($globalDebug) echo "Notam : Download..."; |
@@ -2156,8 +2156,8 @@ discard block |
||
2156 | 2156 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
2157 | 2157 | $data['permanent'] = 0; |
2158 | 2158 | } else { |
2159 | - $data['date_end'] = NULL; |
|
2160 | - $data['permanent'] = 1; |
|
2159 | + $data['date_end'] = NULL; |
|
2160 | + $data['permanent'] = 1; |
|
2161 | 2161 | } |
2162 | 2162 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
2163 | 2163 | $NOTAM = new NOTAM(); |
@@ -2216,13 +2216,13 @@ discard block |
||
2216 | 2216 | try { |
2217 | 2217 | $Connection = new Connection(); |
2218 | 2218 | $sth = $Connection->db->prepare($query); |
2219 | - $sth->execute(); |
|
2220 | - } catch(PDOException $e) { |
|
2221 | - return "error : ".$e->getMessage(); |
|
2222 | - } |
|
2223 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2224 | - if ($row['nb'] > 0) return false; |
|
2225 | - else return true; |
|
2219 | + $sth->execute(); |
|
2220 | + } catch(PDOException $e) { |
|
2221 | + return "error : ".$e->getMessage(); |
|
2222 | + } |
|
2223 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2224 | + if ($row['nb'] > 0) return false; |
|
2225 | + else return true; |
|
2226 | 2226 | } |
2227 | 2227 | |
2228 | 2228 | public static function insert_last_update() { |
@@ -2231,10 +2231,10 @@ discard block |
||
2231 | 2231 | try { |
2232 | 2232 | $Connection = new Connection(); |
2233 | 2233 | $sth = $Connection->db->prepare($query); |
2234 | - $sth->execute(); |
|
2235 | - } catch(PDOException $e) { |
|
2236 | - return "error : ".$e->getMessage(); |
|
2237 | - } |
|
2234 | + $sth->execute(); |
|
2235 | + } catch(PDOException $e) { |
|
2236 | + return "error : ".$e->getMessage(); |
|
2237 | + } |
|
2238 | 2238 | } |
2239 | 2239 | |
2240 | 2240 | public static function check_airspace_version($version) { |
@@ -2242,13 +2242,13 @@ discard block |
||
2242 | 2242 | try { |
2243 | 2243 | $Connection = new Connection(); |
2244 | 2244 | $sth = $Connection->db->prepare($query); |
2245 | - $sth->execute(array(':version' => $version)); |
|
2246 | - } catch(PDOException $e) { |
|
2247 | - return "error : ".$e->getMessage(); |
|
2248 | - } |
|
2249 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2250 | - if ($row['nb'] > 0) return true; |
|
2251 | - else return false; |
|
2245 | + $sth->execute(array(':version' => $version)); |
|
2246 | + } catch(PDOException $e) { |
|
2247 | + return "error : ".$e->getMessage(); |
|
2248 | + } |
|
2249 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2250 | + if ($row['nb'] > 0) return true; |
|
2251 | + else return false; |
|
2252 | 2252 | } |
2253 | 2253 | |
2254 | 2254 | |
@@ -2258,10 +2258,10 @@ discard block |
||
2258 | 2258 | try { |
2259 | 2259 | $Connection = new Connection(); |
2260 | 2260 | $sth = $Connection->db->prepare($query); |
2261 | - $sth->execute(array(':version' => $version)); |
|
2262 | - } catch(PDOException $e) { |
|
2263 | - return "error : ".$e->getMessage(); |
|
2264 | - } |
|
2261 | + $sth->execute(array(':version' => $version)); |
|
2262 | + } catch(PDOException $e) { |
|
2263 | + return "error : ".$e->getMessage(); |
|
2264 | + } |
|
2265 | 2265 | } |
2266 | 2266 | |
2267 | 2267 | public static function check_last_notam_update() { |
@@ -2274,13 +2274,13 @@ discard block |
||
2274 | 2274 | try { |
2275 | 2275 | $Connection = new Connection(); |
2276 | 2276 | $sth = $Connection->db->prepare($query); |
2277 | - $sth->execute(); |
|
2278 | - } catch(PDOException $e) { |
|
2279 | - return "error : ".$e->getMessage(); |
|
2280 | - } |
|
2281 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2282 | - if ($row['nb'] > 0) return false; |
|
2283 | - else return true; |
|
2277 | + $sth->execute(); |
|
2278 | + } catch(PDOException $e) { |
|
2279 | + return "error : ".$e->getMessage(); |
|
2280 | + } |
|
2281 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2282 | + if ($row['nb'] > 0) return false; |
|
2283 | + else return true; |
|
2284 | 2284 | } |
2285 | 2285 | |
2286 | 2286 | public static function insert_last_notam_update() { |
@@ -2289,10 +2289,10 @@ discard block |
||
2289 | 2289 | try { |
2290 | 2290 | $Connection = new Connection(); |
2291 | 2291 | $sth = $Connection->db->prepare($query); |
2292 | - $sth->execute(); |
|
2293 | - } catch(PDOException $e) { |
|
2294 | - return "error : ".$e->getMessage(); |
|
2295 | - } |
|
2292 | + $sth->execute(); |
|
2293 | + } catch(PDOException $e) { |
|
2294 | + return "error : ".$e->getMessage(); |
|
2295 | + } |
|
2296 | 2296 | } |
2297 | 2297 | public static function check_last_airspace_update() { |
2298 | 2298 | global $globalDBdriver; |
@@ -2304,13 +2304,13 @@ discard block |
||
2304 | 2304 | try { |
2305 | 2305 | $Connection = new Connection(); |
2306 | 2306 | $sth = $Connection->db->prepare($query); |
2307 | - $sth->execute(); |
|
2308 | - } catch(PDOException $e) { |
|
2309 | - return "error : ".$e->getMessage(); |
|
2310 | - } |
|
2311 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2312 | - if ($row['nb'] > 0) return false; |
|
2313 | - else return true; |
|
2307 | + $sth->execute(); |
|
2308 | + } catch(PDOException $e) { |
|
2309 | + return "error : ".$e->getMessage(); |
|
2310 | + } |
|
2311 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2312 | + if ($row['nb'] > 0) return false; |
|
2313 | + else return true; |
|
2314 | 2314 | } |
2315 | 2315 | |
2316 | 2316 | public static function insert_last_airspace_update() { |
@@ -2319,10 +2319,10 @@ discard block |
||
2319 | 2319 | try { |
2320 | 2320 | $Connection = new Connection(); |
2321 | 2321 | $sth = $Connection->db->prepare($query); |
2322 | - $sth->execute(); |
|
2323 | - } catch(PDOException $e) { |
|
2324 | - return "error : ".$e->getMessage(); |
|
2325 | - } |
|
2322 | + $sth->execute(); |
|
2323 | + } catch(PDOException $e) { |
|
2324 | + return "error : ".$e->getMessage(); |
|
2325 | + } |
|
2326 | 2326 | } |
2327 | 2327 | |
2328 | 2328 | public static function check_last_owner_update() { |
@@ -2335,13 +2335,13 @@ discard block |
||
2335 | 2335 | try { |
2336 | 2336 | $Connection = new Connection(); |
2337 | 2337 | $sth = $Connection->db->prepare($query); |
2338 | - $sth->execute(); |
|
2339 | - } catch(PDOException $e) { |
|
2340 | - return "error : ".$e->getMessage(); |
|
2341 | - } |
|
2342 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2343 | - if ($row['nb'] > 0) return false; |
|
2344 | - else return true; |
|
2338 | + $sth->execute(); |
|
2339 | + } catch(PDOException $e) { |
|
2340 | + return "error : ".$e->getMessage(); |
|
2341 | + } |
|
2342 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2343 | + if ($row['nb'] > 0) return false; |
|
2344 | + else return true; |
|
2345 | 2345 | } |
2346 | 2346 | |
2347 | 2347 | public static function insert_last_owner_update() { |
@@ -2350,10 +2350,10 @@ discard block |
||
2350 | 2350 | try { |
2351 | 2351 | $Connection = new Connection(); |
2352 | 2352 | $sth = $Connection->db->prepare($query); |
2353 | - $sth->execute(); |
|
2354 | - } catch(PDOException $e) { |
|
2355 | - return "error : ".$e->getMessage(); |
|
2356 | - } |
|
2353 | + $sth->execute(); |
|
2354 | + } catch(PDOException $e) { |
|
2355 | + return "error : ".$e->getMessage(); |
|
2356 | + } |
|
2357 | 2357 | } |
2358 | 2358 | public static function check_last_schedules_update() { |
2359 | 2359 | global $globalDBdriver; |
@@ -2365,13 +2365,13 @@ discard block |
||
2365 | 2365 | try { |
2366 | 2366 | $Connection = new Connection(); |
2367 | 2367 | $sth = $Connection->db->prepare($query); |
2368 | - $sth->execute(); |
|
2369 | - } catch(PDOException $e) { |
|
2370 | - return "error : ".$e->getMessage(); |
|
2371 | - } |
|
2372 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2373 | - if ($row['nb'] > 0) return false; |
|
2374 | - else return true; |
|
2368 | + $sth->execute(); |
|
2369 | + } catch(PDOException $e) { |
|
2370 | + return "error : ".$e->getMessage(); |
|
2371 | + } |
|
2372 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2373 | + if ($row['nb'] > 0) return false; |
|
2374 | + else return true; |
|
2375 | 2375 | } |
2376 | 2376 | |
2377 | 2377 | public static function insert_last_schedules_update() { |
@@ -2380,10 +2380,10 @@ discard block |
||
2380 | 2380 | try { |
2381 | 2381 | $Connection = new Connection(); |
2382 | 2382 | $sth = $Connection->db->prepare($query); |
2383 | - $sth->execute(); |
|
2384 | - } catch(PDOException $e) { |
|
2385 | - return "error : ".$e->getMessage(); |
|
2386 | - } |
|
2383 | + $sth->execute(); |
|
2384 | + } catch(PDOException $e) { |
|
2385 | + return "error : ".$e->getMessage(); |
|
2386 | + } |
|
2387 | 2387 | } |
2388 | 2388 | public static function check_last_tle_update() { |
2389 | 2389 | global $globalDBdriver; |
@@ -2395,13 +2395,13 @@ discard block |
||
2395 | 2395 | try { |
2396 | 2396 | $Connection = new Connection(); |
2397 | 2397 | $sth = $Connection->db->prepare($query); |
2398 | - $sth->execute(); |
|
2399 | - } catch(PDOException $e) { |
|
2400 | - return "error : ".$e->getMessage(); |
|
2401 | - } |
|
2402 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2403 | - if ($row['nb'] > 0) return false; |
|
2404 | - else return true; |
|
2398 | + $sth->execute(); |
|
2399 | + } catch(PDOException $e) { |
|
2400 | + return "error : ".$e->getMessage(); |
|
2401 | + } |
|
2402 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2403 | + if ($row['nb'] > 0) return false; |
|
2404 | + else return true; |
|
2405 | 2405 | } |
2406 | 2406 | |
2407 | 2407 | public static function insert_last_tle_update() { |
@@ -2410,10 +2410,10 @@ discard block |
||
2410 | 2410 | try { |
2411 | 2411 | $Connection = new Connection(); |
2412 | 2412 | $sth = $Connection->db->prepare($query); |
2413 | - $sth->execute(); |
|
2414 | - } catch(PDOException $e) { |
|
2415 | - return "error : ".$e->getMessage(); |
|
2416 | - } |
|
2413 | + $sth->execute(); |
|
2414 | + } catch(PDOException $e) { |
|
2415 | + return "error : ".$e->getMessage(); |
|
2416 | + } |
|
2417 | 2417 | } |
2418 | 2418 | public static function check_last_banned_update() { |
2419 | 2419 | global $globalDBdriver; |
@@ -2425,13 +2425,13 @@ discard block |
||
2425 | 2425 | try { |
2426 | 2426 | $Connection = new Connection(); |
2427 | 2427 | $sth = $Connection->db->prepare($query); |
2428 | - $sth->execute(); |
|
2429 | - } catch(PDOException $e) { |
|
2430 | - return "error : ".$e->getMessage(); |
|
2431 | - } |
|
2432 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2433 | - if ($row['nb'] > 0) return false; |
|
2434 | - else return true; |
|
2428 | + $sth->execute(); |
|
2429 | + } catch(PDOException $e) { |
|
2430 | + return "error : ".$e->getMessage(); |
|
2431 | + } |
|
2432 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
2433 | + if ($row['nb'] > 0) return false; |
|
2434 | + else return true; |
|
2435 | 2435 | } |
2436 | 2436 | |
2437 | 2437 | public static function insert_last_banned_update() { |
@@ -2440,10 +2440,10 @@ discard block |
||
2440 | 2440 | try { |
2441 | 2441 | $Connection = new Connection(); |
2442 | 2442 | $sth = $Connection->db->prepare($query); |
2443 | - $sth->execute(); |
|
2444 | - } catch(PDOException $e) { |
|
2445 | - return "error : ".$e->getMessage(); |
|
2446 | - } |
|
2443 | + $sth->execute(); |
|
2444 | + } catch(PDOException $e) { |
|
2445 | + return "error : ".$e->getMessage(); |
|
2446 | + } |
|
2447 | 2447 | } |
2448 | 2448 | public static function delete_duplicatemodes() { |
2449 | 2449 | global $globalDBdriver; |
@@ -2455,10 +2455,10 @@ discard block |
||
2455 | 2455 | try { |
2456 | 2456 | $Connection = new Connection(); |
2457 | 2457 | $sth = $Connection->db->prepare($query); |
2458 | - $sth->execute(); |
|
2459 | - } catch(PDOException $e) { |
|
2460 | - return "error : ".$e->getMessage(); |
|
2461 | - } |
|
2458 | + $sth->execute(); |
|
2459 | + } catch(PDOException $e) { |
|
2460 | + return "error : ".$e->getMessage(); |
|
2461 | + } |
|
2462 | 2462 | } |
2463 | 2463 | public static function delete_duplicateowner() { |
2464 | 2464 | global $globalDBdriver; |
@@ -2470,10 +2470,10 @@ discard block |
||
2470 | 2470 | try { |
2471 | 2471 | $Connection = new Connection(); |
2472 | 2472 | $sth = $Connection->db->prepare($query); |
2473 | - $sth->execute(); |
|
2474 | - } catch(PDOException $e) { |
|
2475 | - return "error : ".$e->getMessage(); |
|
2476 | - } |
|
2473 | + $sth->execute(); |
|
2474 | + } catch(PDOException $e) { |
|
2475 | + return "error : ".$e->getMessage(); |
|
2476 | + } |
|
2477 | 2477 | } |
2478 | 2478 | |
2479 | 2479 | public static function update_all() { |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | fclose($fp); |
25 | 25 | } |
26 | 26 | |
27 | - public static function gunzip($in_file,$out_file_name = '') { |
|
27 | + public static function gunzip($in_file, $out_file_name = '') { |
|
28 | 28 | //echo $in_file.' -> '.$out_file_name."\n"; |
29 | 29 | $buffer_size = 4096; // read 4kb at a time |
30 | 30 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
31 | 31 | if ($in_file != '' && file_exists($in_file)) { |
32 | 32 | // 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'); |
|
33 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
34 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
35 | 35 | else { |
36 | 36 | echo 'gzopen not available'; |
37 | 37 | die; |
38 | 38 | } |
39 | 39 | $out_file = fopen($out_file_name, 'wb'); |
40 | - while(!gzeof($file)) { |
|
40 | + while (!gzeof($file)) { |
|
41 | 41 | fwrite($out_file, gzread($file, $buffer_size)); |
42 | 42 | } |
43 | 43 | fclose($out_file); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | try { |
62 | 62 | self::$db_sqlite = new PDO('sqlite:'.$database); |
63 | 63 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
64 | - } catch(PDOException $e) { |
|
64 | + } catch (PDOException $e) { |
|
65 | 65 | return "error : ".$e->getMessage(); |
66 | 66 | } |
67 | 67 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | //$Connection = new Connection(); |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(array(':source' => $database_file)); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error : ".$e->getMessage(); |
81 | 81 | } |
82 | 82 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | try { |
88 | 88 | $sth = update_db::$db_sqlite->prepare($query); |
89 | 89 | $sth->execute(); |
90 | - } catch(PDOException $e) { |
|
90 | + } catch (PDOException $e) { |
|
91 | 91 | return "error : ".$e->getMessage(); |
92 | 92 | } |
93 | 93 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | if ($globalTransaction) $Connection->db->beginTransaction(); |
99 | 99 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
100 | 100 | //$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 | - $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); |
|
101 | + $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 | 102 | $sth_dest->execute($query_dest_values); |
103 | 103 | } |
104 | 104 | if ($globalTransaction) $Connection->db->commit(); |
105 | - } catch(PDOException $e) { |
|
105 | + } catch (PDOException $e) { |
|
106 | 106 | if ($globalTransaction) $Connection->db->rollBack(); |
107 | 107 | return "error : ".$e->getMessage(); |
108 | 108 | } |
@@ -118,26 +118,26 @@ discard block |
||
118 | 118 | //$Connection = new Connection(); |
119 | 119 | $sth = $Connection->db->prepare($query); |
120 | 120 | $sth->execute(array(':source' => 'oneworld')); |
121 | - } catch(PDOException $e) { |
|
121 | + } catch (PDOException $e) { |
|
122 | 122 | return "error : ".$e->getMessage(); |
123 | 123 | } |
124 | 124 | |
125 | 125 | if ($globalDebug) echo " - Add routes to DB -"; |
126 | 126 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
127 | 127 | $Spotter = new Spotter(); |
128 | - if ($fh = fopen($database_file,"r")) { |
|
128 | + if ($fh = fopen($database_file, "r")) { |
|
129 | 129 | $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 | 130 | $Connection = new Connection(); |
131 | 131 | $sth_dest = $Connection->db->prepare($query_dest); |
132 | 132 | if ($globalTransaction) $Connection->db->beginTransaction(); |
133 | 133 | while (!feof($fh)) { |
134 | - $line = fgetcsv($fh,9999,','); |
|
134 | + $line = fgetcsv($fh, 9999, ','); |
|
135 | 135 | if ($line[0] != '') { |
136 | 136 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
137 | 137 | try { |
138 | - $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'); |
|
138 | + $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 | 139 | $sth_dest->execute($query_dest_values); |
140 | - } catch(PDOException $e) { |
|
140 | + } catch (PDOException $e) { |
|
141 | 141 | if ($globalTransaction) $Connection->db->rollBack(); |
142 | 142 | return "error : ".$e->getMessage(); |
143 | 143 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | //$Connection = new Connection(); |
160 | 160 | $sth = $Connection->db->prepare($query); |
161 | 161 | $sth->execute(array(':source' => 'skyteam')); |
162 | - } catch(PDOException $e) { |
|
162 | + } catch (PDOException $e) { |
|
163 | 163 | return "error : ".$e->getMessage(); |
164 | 164 | } |
165 | 165 | |
@@ -167,24 +167,24 @@ discard block |
||
167 | 167 | |
168 | 168 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
169 | 169 | $Spotter = new Spotter(); |
170 | - if ($fh = fopen($database_file,"r")) { |
|
170 | + if ($fh = fopen($database_file, "r")) { |
|
171 | 171 | $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)'; |
172 | 172 | $Connection = new Connection(); |
173 | 173 | $sth_dest = $Connection->db->prepare($query_dest); |
174 | 174 | try { |
175 | 175 | if ($globalTransaction) $Connection->db->beginTransaction(); |
176 | 176 | while (!feof($fh)) { |
177 | - $line = fgetcsv($fh,9999,','); |
|
177 | + $line = fgetcsv($fh, 9999, ','); |
|
178 | 178 | if ($line[0] != '') { |
179 | - $datebe = explode(' - ',$line[2]); |
|
179 | + $datebe = explode(' - ', $line[2]); |
|
180 | 180 | if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
181 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); |
|
181 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam'); |
|
182 | 182 | $sth_dest->execute($query_dest_values); |
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
186 | 186 | if ($globalTransaction) $Connection->db->commit(); |
187 | - } catch(PDOException $e) { |
|
187 | + } catch (PDOException $e) { |
|
188 | 188 | if ($globalTransaction) $Connection->db->rollBack(); |
189 | 189 | return "error : ".$e->getMessage(); |
190 | 190 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $Connection = new Connection(); |
200 | 200 | $sth = $Connection->db->prepare($query); |
201 | 201 | $sth->execute(array(':source' => $database_file)); |
202 | - } catch(PDOException $e) { |
|
202 | + } catch (PDOException $e) { |
|
203 | 203 | return "error : ".$e->getMessage(); |
204 | 204 | } |
205 | 205 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $Connection = new Connection(); |
208 | 208 | $sth = $Connection->db->prepare($query); |
209 | 209 | $sth->execute(array(':source' => $database_file)); |
210 | - } catch(PDOException $e) { |
|
210 | + } catch (PDOException $e) { |
|
211 | 211 | return "error : ".$e->getMessage(); |
212 | 212 | } |
213 | 213 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | try { |
217 | 217 | $sth = update_db::$db_sqlite->prepare($query); |
218 | 218 | $sth->execute(); |
219 | - } catch(PDOException $e) { |
|
219 | + } catch (PDOException $e) { |
|
220 | 220 | return "error : ".$e->getMessage(); |
221 | 221 | } |
222 | 222 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -233,15 +233,15 @@ discard block |
||
233 | 233 | //$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 | 234 | if ($values['UserString4'] == 'M') $type = 'military'; |
235 | 235 | else $type = null; |
236 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
236 | + $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 | 237 | $sth_dest->execute($query_dest_values); |
238 | 238 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
239 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
239 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
240 | 240 | $sth_dest_owner->execute($query_dest_owner_values); |
241 | 241 | } |
242 | 242 | } |
243 | 243 | if ($globalTransaction) $Connection->db->commit(); |
244 | - } catch(PDOException $e) { |
|
244 | + } catch (PDOException $e) { |
|
245 | 245 | return "error : ".$e->getMessage(); |
246 | 246 | } |
247 | 247 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $Connection = new Connection(); |
252 | 252 | $sth = $Connection->db->prepare($query); |
253 | 253 | $sth->execute(array(':source' => $database_file)); |
254 | - } catch(PDOException $e) { |
|
254 | + } catch (PDOException $e) { |
|
255 | 255 | return "error : ".$e->getMessage(); |
256 | 256 | } |
257 | 257 | return ''; |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | $Connection = new Connection(); |
267 | 267 | $sth = $Connection->db->prepare($query); |
268 | 268 | $sth->execute(array(':source' => $database_file)); |
269 | - } catch(PDOException $e) { |
|
269 | + } catch (PDOException $e) { |
|
270 | 270 | return "error : ".$e->getMessage(); |
271 | 271 | } |
272 | 272 | |
273 | - if ($fh = fopen($database_file,"r")) { |
|
273 | + if ($fh = fopen($database_file, "r")) { |
|
274 | 274 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
275 | 275 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
276 | 276 | |
@@ -280,13 +280,13 @@ discard block |
||
280 | 280 | if ($globalTransaction) $Connection->db->beginTransaction(); |
281 | 281 | while (!feof($fh)) { |
282 | 282 | $values = array(); |
283 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
283 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
284 | 284 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
285 | - $values['ModeS'] = substr($line,0,6); |
|
286 | - $values['Registration'] = trim(substr($line,69,6)); |
|
287 | - $aircraft_name = trim(substr($line,48,6)); |
|
285 | + $values['ModeS'] = substr($line, 0, 6); |
|
286 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
287 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
288 | 288 | // Check if we can find ICAO, else set it to GLID |
289 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
289 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
290 | 290 | $search_more = ''; |
291 | 291 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
292 | 292 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -298,20 +298,20 @@ discard block |
||
298 | 298 | if (isset($result['icao']) && $result['icao'] != '') { |
299 | 299 | $values['ICAOTypeCode'] = $result['icao']; |
300 | 300 | } |
301 | - } catch(PDOException $e) { |
|
301 | + } catch (PDOException $e) { |
|
302 | 302 | return "error : ".$e->getMessage(); |
303 | 303 | } |
304 | 304 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
305 | 305 | // Add data to db |
306 | 306 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
307 | 307 | //$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']); |
308 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
308 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
309 | 309 | //print_r($query_dest_values); |
310 | 310 | $sth_dest->execute($query_dest_values); |
311 | 311 | } |
312 | 312 | } |
313 | 313 | if ($globalTransaction) $Connection->db->commit(); |
314 | - } catch(PDOException $e) { |
|
314 | + } catch (PDOException $e) { |
|
315 | 315 | return "error : ".$e->getMessage(); |
316 | 316 | } |
317 | 317 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $Connection = new Connection(); |
322 | 322 | $sth = $Connection->db->prepare($query); |
323 | 323 | $sth->execute(array(':source' => $database_file)); |
324 | - } catch(PDOException $e) { |
|
324 | + } catch (PDOException $e) { |
|
325 | 325 | return "error : ".$e->getMessage(); |
326 | 326 | } |
327 | 327 | return ''; |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | $Connection = new Connection(); |
336 | 336 | $sth = $Connection->db->prepare($query); |
337 | 337 | $sth->execute(array(':source' => $database_file)); |
338 | - } catch(PDOException $e) { |
|
338 | + } catch (PDOException $e) { |
|
339 | 339 | return "error : ".$e->getMessage(); |
340 | 340 | } |
341 | 341 | |
342 | - if ($fh = fopen($database_file,"r")) { |
|
342 | + if ($fh = fopen($database_file, "r")) { |
|
343 | 343 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
344 | 344 | $query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source)'; |
345 | 345 | |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | $sth_dest = $Connection->db->prepare($query_dest); |
348 | 348 | try { |
349 | 349 | if ($globalTransaction) $Connection->db->beginTransaction(); |
350 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
350 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
351 | 351 | while (!feof($fh)) { |
352 | - $line = fgetcsv($fh,9999,',',"'"); |
|
352 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
353 | 353 | |
354 | 354 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
355 | 355 | //print_r($line); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $values['Registration'] = $line[3]; |
358 | 358 | $aircraft_name = $line[2]; |
359 | 359 | // Check if we can find ICAO, else set it to GLID |
360 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
360 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
361 | 361 | $search_more = ''; |
362 | 362 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
363 | 363 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -366,20 +366,20 @@ discard block |
||
366 | 366 | $sth_search->execute(); |
367 | 367 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
368 | 368 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
369 | - } catch(PDOException $e) { |
|
369 | + } catch (PDOException $e) { |
|
370 | 370 | return "error : ".$e->getMessage(); |
371 | 371 | } |
372 | 372 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
373 | 373 | // Add data to db |
374 | 374 | if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
375 | 375 | //$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']); |
376 | - $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
376 | + $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
377 | 377 | //print_r($query_dest_values); |
378 | 378 | $sth_dest->execute($query_dest_values); |
379 | 379 | } |
380 | 380 | } |
381 | 381 | if ($globalTransaction) $Connection->db->commit(); |
382 | - } catch(PDOException $e) { |
|
382 | + } catch (PDOException $e) { |
|
383 | 383 | return "error : ".$e->getMessage(); |
384 | 384 | } |
385 | 385 | } |
@@ -389,13 +389,13 @@ discard block |
||
389 | 389 | $Connection = new Connection(); |
390 | 390 | $sth = $Connection->db->prepare($query); |
391 | 391 | $sth->execute(array(':source' => $database_file)); |
392 | - } catch(PDOException $e) { |
|
392 | + } catch (PDOException $e) { |
|
393 | 393 | return "error : ".$e->getMessage(); |
394 | 394 | } |
395 | 395 | return ''; |
396 | 396 | } |
397 | 397 | |
398 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
398 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
399 | 399 | global $globalTransaction; |
400 | 400 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
401 | 401 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | $Connection = new Connection(); |
404 | 404 | $sth = $Connection->db->prepare($query); |
405 | 405 | $sth->execute(array(':source' => $database_file)); |
406 | - } catch(PDOException $e) { |
|
406 | + } catch (PDOException $e) { |
|
407 | 407 | return "error : ".$e->getMessage(); |
408 | 408 | } |
409 | 409 | |
410 | - if ($fh = fopen($database_file,"r")) { |
|
410 | + if ($fh = fopen($database_file, "r")) { |
|
411 | 411 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
412 | 412 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
413 | 413 | |
@@ -415,9 +415,9 @@ discard block |
||
415 | 415 | $sth_dest = $Connection->db->prepare($query_dest); |
416 | 416 | try { |
417 | 417 | if ($globalTransaction) $Connection->db->beginTransaction(); |
418 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
418 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
419 | 419 | while (!feof($fh)) { |
420 | - $line = fgetcsv($fh,9999,',','"'); |
|
420 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
421 | 421 | $values = array(); |
422 | 422 | //print_r($line); |
423 | 423 | if ($country == 'F') { |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | $values['base'] = $line[4]; |
426 | 426 | $values['owner'] = $line[5]; |
427 | 427 | if ($line[6] == '') $values['date_first_reg'] = null; |
428 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
428 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
429 | 429 | $values['cancel'] = $line[7]; |
430 | 430 | } elseif ($country == 'EI') { |
431 | 431 | // TODO : add modeS & reg to aircraft_modes |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | $values['base'] = $line[3]; |
434 | 434 | $values['owner'] = $line[2]; |
435 | 435 | if ($line[1] == '') $values['date_first_reg'] = null; |
436 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
436 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
437 | 437 | $values['cancel'] = ''; |
438 | 438 | } elseif ($country == 'HB') { |
439 | 439 | // TODO : add modeS & reg to aircraft_modes |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | $values['base'] = null; |
449 | 449 | $values['owner'] = $line[5]; |
450 | 450 | if ($line[18] == '') $values['date_first_reg'] = null; |
451 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
451 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
452 | 452 | $values['cancel'] = ''; |
453 | 453 | } elseif ($country == 'VH') { |
454 | 454 | // TODO : add modeS & reg to aircraft_modes |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $values['base'] = null; |
457 | 457 | $values['owner'] = $line[12]; |
458 | 458 | if ($line[28] == '') $values['date_first_reg'] = null; |
459 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
459 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
460 | 460 | |
461 | 461 | $values['cancel'] = $line[39]; |
462 | 462 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -476,28 +476,28 @@ discard block |
||
476 | 476 | $values['base'] = null; |
477 | 477 | $values['owner'] = $line[8]; |
478 | 478 | if ($line[7] == '') $values['date_first_reg'] = null; |
479 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
479 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
480 | 480 | $values['cancel'] = ''; |
481 | 481 | } elseif ($country == 'PP') { |
482 | 482 | $values['registration'] = $line[0]; |
483 | 483 | $values['base'] = null; |
484 | 484 | $values['owner'] = $line[4]; |
485 | 485 | if ($line[6] == '') $values['date_first_reg'] = null; |
486 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
486 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
487 | 487 | $values['cancel'] = $line[7]; |
488 | 488 | } elseif ($country == 'E7') { |
489 | 489 | $values['registration'] = $line[0]; |
490 | 490 | $values['base'] = null; |
491 | 491 | $values['owner'] = $line[4]; |
492 | 492 | if ($line[5] == '') $values['date_first_reg'] = null; |
493 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
493 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
494 | 494 | $values['cancel'] = ''; |
495 | 495 | } elseif ($country == '8Q') { |
496 | 496 | $values['registration'] = $line[0]; |
497 | 497 | $values['base'] = null; |
498 | 498 | $values['owner'] = $line[3]; |
499 | 499 | if ($line[7] == '') $values['date_first_reg'] = null; |
500 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
500 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
501 | 501 | $values['cancel'] = ''; |
502 | 502 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
503 | 503 | $values['registration'] = $line[0]; |
@@ -507,12 +507,12 @@ discard block |
||
507 | 507 | $values['cancel'] = ''; |
508 | 508 | } |
509 | 509 | if ($values['cancel'] == '' && $values['registration'] != null) { |
510 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
510 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
511 | 511 | $sth_dest->execute($query_dest_values); |
512 | 512 | } |
513 | 513 | } |
514 | 514 | if ($globalTransaction) $Connection->db->commit(); |
515 | - } catch(PDOException $e) { |
|
515 | + } catch (PDOException $e) { |
|
516 | 516 | return "error : ".$e->getMessage(); |
517 | 517 | } |
518 | 518 | } |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | $Connection = new Connection(); |
628 | 628 | $sth = $Connection->db->prepare($query); |
629 | 629 | $sth->execute(); |
630 | - } catch(PDOException $e) { |
|
630 | + } catch (PDOException $e) { |
|
631 | 631 | return "error : ".$e->getMessage(); |
632 | 632 | } |
633 | 633 | |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | $Connection = new Connection(); |
638 | 638 | $sth = $Connection->db->prepare($query); |
639 | 639 | $sth->execute(); |
640 | - } catch(PDOException $e) { |
|
640 | + } catch (PDOException $e) { |
|
641 | 641 | return "error : ".$e->getMessage(); |
642 | 642 | } |
643 | 643 | |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | if ($globalTransaction) $Connection->db->beginTransaction(); |
649 | 649 | |
650 | 650 | $i = 0; |
651 | - while($row = sparql_fetch_array($result)) |
|
651 | + while ($row = sparql_fetch_array($result)) |
|
652 | 652 | { |
653 | 653 | if ($i >= 1) { |
654 | 654 | //print_r($row); |
@@ -668,31 +668,31 @@ discard block |
||
668 | 668 | $row['image'] = ''; |
669 | 669 | $row['image_thumb'] = ''; |
670 | 670 | } else { |
671 | - $image = str_replace(' ','_',$row['image']); |
|
671 | + $image = str_replace(' ', '_', $row['image']); |
|
672 | 672 | $digest = md5($image); |
673 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
674 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
675 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
676 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
673 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
674 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
675 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
676 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
677 | 677 | } |
678 | 678 | |
679 | - $country = explode('-',$row['country']); |
|
679 | + $country = explode('-', $row['country']); |
|
680 | 680 | $row['country'] = $country[0]; |
681 | 681 | |
682 | 682 | $row['type'] = trim($row['type']); |
683 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
683 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
684 | 684 | $row['type'] = 'Military'; |
685 | 685 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
686 | 686 | $row['type'] = 'small_airport'; |
687 | 687 | } |
688 | 688 | |
689 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
690 | - $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
689 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
690 | + $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
691 | 691 | //print_r($query_dest_values); |
692 | 692 | |
693 | 693 | try { |
694 | 694 | $sth_dest->execute($query_dest_values); |
695 | - } catch(PDOException $e) { |
|
695 | + } catch (PDOException $e) { |
|
696 | 696 | return "error : ".$e->getMessage(); |
697 | 697 | } |
698 | 698 | } |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | $Connection = new Connection(); |
707 | 707 | $sth = $Connection->db->prepare($query); |
708 | 708 | $sth->execute(); |
709 | - } catch(PDOException $e) { |
|
709 | + } catch (PDOException $e) { |
|
710 | 710 | return "error : ".$e->getMessage(); |
711 | 711 | } |
712 | 712 | |
@@ -714,12 +714,12 @@ discard block |
||
714 | 714 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
715 | 715 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
716 | 716 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
717 | - $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' => ''); |
|
717 | + $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' => ''); |
|
718 | 718 | try { |
719 | 719 | $Connection = new Connection(); |
720 | 720 | $sth = $Connection->db->prepare($query); |
721 | 721 | $sth->execute($query_values); |
722 | - } catch(PDOException $e) { |
|
722 | + } catch (PDOException $e) { |
|
723 | 723 | return "error : ".$e->getMessage(); |
724 | 724 | } |
725 | 725 | $i++; |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | echo "Download data from ourairports.com...\n"; |
738 | 738 | $delimiter = ','; |
739 | 739 | $out_file = $tmp_dir.'airports.csv'; |
740 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
740 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
741 | 741 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
742 | 742 | echo "Add data from ourairports.com...\n"; |
743 | 743 | |
@@ -748,32 +748,32 @@ discard block |
||
748 | 748 | //$Connection->db->beginTransaction(); |
749 | 749 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
750 | 750 | { |
751 | - if(!$header) $header = $row; |
|
751 | + if (!$header) $header = $row; |
|
752 | 752 | else { |
753 | 753 | $data = array(); |
754 | 754 | $data = array_combine($header, $row); |
755 | 755 | try { |
756 | 756 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); |
757 | 757 | $sth->execute(array(':icao' => $data['gps_code'])); |
758 | - } catch(PDOException $e) { |
|
758 | + } catch (PDOException $e) { |
|
759 | 759 | return "error : ".$e->getMessage(); |
760 | 760 | } |
761 | 761 | if ($sth->fetchColumn() > 0) { |
762 | 762 | $query = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
763 | 763 | try { |
764 | 764 | $sth = $Connection->db->prepare($query); |
765 | - $sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); |
|
766 | - } catch(PDOException $e) { |
|
765 | + $sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type'])); |
|
766 | + } catch (PDOException $e) { |
|
767 | 767 | return "error : ".$e->getMessage(); |
768 | 768 | } |
769 | 769 | } else { |
770 | 770 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`) |
771 | 771 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
772 | - $query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
772 | + $query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
773 | 773 | try { |
774 | 774 | $sth = $Connection->db->prepare($query); |
775 | 775 | $sth->execute($query_values); |
776 | - } catch(PDOException $e) { |
|
776 | + } catch (PDOException $e) { |
|
777 | 777 | return "error : ".$e->getMessage(); |
778 | 778 | } |
779 | 779 | $i++; |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | |
787 | 787 | echo "Download data from another free database...\n"; |
788 | 788 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
789 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
789 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
790 | 790 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
791 | 791 | update_db::unzip($out_file); |
792 | 792 | $header = NULL; |
@@ -798,15 +798,15 @@ discard block |
||
798 | 798 | //$Connection->db->beginTransaction(); |
799 | 799 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
800 | 800 | { |
801 | - if(!$header) $header = $row; |
|
801 | + if (!$header) $header = $row; |
|
802 | 802 | else { |
803 | 803 | $data = $row; |
804 | 804 | |
805 | 805 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
806 | 806 | try { |
807 | 807 | $sth = $Connection->db->prepare($query); |
808 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
809 | - } catch(PDOException $e) { |
|
808 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
809 | + } catch (PDOException $e) { |
|
810 | 810 | return "error : ".$e->getMessage(); |
811 | 811 | } |
812 | 812 | } |
@@ -820,15 +820,15 @@ discard block |
||
820 | 820 | try { |
821 | 821 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); |
822 | 822 | $sth->execute(); |
823 | - } catch(PDOException $e) { |
|
823 | + } catch (PDOException $e) { |
|
824 | 824 | return "error : ".$e->getMessage(); |
825 | 825 | } |
826 | 826 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
827 | 827 | $query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
828 | 828 | try { |
829 | 829 | $sth2 = $Connection->db->prepare($query2); |
830 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
831 | - } catch(PDOException $e) { |
|
830 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
831 | + } catch (PDOException $e) { |
|
832 | 832 | return "error : ".$e->getMessage(); |
833 | 833 | } |
834 | 834 | } |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | $Connection = new Connection(); |
853 | 853 | $sth = $Connection->db->prepare($query); |
854 | 854 | $sth->execute(array(':source' => 'translation.csv')); |
855 | - } catch(PDOException $e) { |
|
855 | + } catch (PDOException $e) { |
|
856 | 856 | return "error : ".$e->getMessage(); |
857 | 857 | } |
858 | 858 | |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
870 | 870 | { |
871 | 871 | $i++; |
872 | - if($i > 12) { |
|
872 | + if ($i > 12) { |
|
873 | 873 | $data = $row; |
874 | 874 | $operator = $data[2]; |
875 | 875 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | //echo substr($operator, 0, 2)."\n";; |
878 | 878 | if (count($airline_array) > 0) { |
879 | 879 | //print_r($airline_array); |
880 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
880 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
881 | 881 | } |
882 | 882 | } |
883 | 883 | |
@@ -885,14 +885,14 @@ discard block |
||
885 | 885 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
886 | 886 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
887 | 887 | if (count($airline_array) > 0) { |
888 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
888 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
889 | 889 | } |
890 | 890 | } |
891 | 891 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
892 | 892 | try { |
893 | 893 | $sth = $Connection->db->prepare($query); |
894 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
895 | - } catch(PDOException $e) { |
|
894 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
895 | + } catch (PDOException $e) { |
|
896 | 896 | return "error : ".$e->getMessage(); |
897 | 897 | } |
898 | 898 | } |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | $Connection = new Connection(); |
913 | 913 | $sth = $Connection->db->prepare($query); |
914 | 914 | $sth->execute(array(':source' => 'website_fam')); |
915 | - } catch(PDOException $e) { |
|
915 | + } catch (PDOException $e) { |
|
916 | 916 | return "error : ".$e->getMessage(); |
917 | 917 | } |
918 | 918 | |
@@ -932,8 +932,8 @@ discard block |
||
932 | 932 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
933 | 933 | try { |
934 | 934 | $sth = $Connection->db->prepare($query); |
935 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
936 | - } catch(PDOException $e) { |
|
935 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
936 | + } catch (PDOException $e) { |
|
937 | 937 | return "error : ".$e->getMessage(); |
938 | 938 | } |
939 | 939 | } |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | $Connection = new Connection(); |
957 | 957 | $sth = $Connection->db->prepare($query); |
958 | 958 | $sth->execute(array(':source' => 'website_faa')); |
959 | - } catch(PDOException $e) { |
|
959 | + } catch (PDOException $e) { |
|
960 | 960 | return "error : ".$e->getMessage(); |
961 | 961 | } |
962 | 962 | |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | $Connection = new Connection(); |
966 | 966 | $sth = $Connection->db->prepare($query); |
967 | 967 | $sth->execute(array(':source' => 'website_faa')); |
968 | - } catch(PDOException $e) { |
|
968 | + } catch (PDOException $e) { |
|
969 | 969 | return "error : ".$e->getMessage(); |
970 | 970 | } |
971 | 971 | |
@@ -982,8 +982,8 @@ discard block |
||
982 | 982 | $query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1'; |
983 | 983 | try { |
984 | 984 | $sths = $Connection->db->prepare($query_search); |
985 | - $sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa')); |
|
986 | - } catch(PDOException $e) { |
|
985 | + $sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa')); |
|
986 | + } catch (PDOException $e) { |
|
987 | 987 | return "error s : ".$e->getMessage(); |
988 | 988 | } |
989 | 989 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
@@ -996,8 +996,8 @@ discard block |
||
996 | 996 | //} |
997 | 997 | try { |
998 | 998 | $sthi = $Connection->db->prepare($queryi); |
999 | - $sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode'])); |
|
1000 | - } catch(PDOException $e) { |
|
999 | + $sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode'])); |
|
1000 | + } catch (PDOException $e) { |
|
1001 | 1001 | return "error u : ".$e->getMessage(); |
1002 | 1002 | } |
1003 | 1003 | } else { |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | try { |
1006 | 1006 | $sthsm = $Connection->db->prepare($query_search_mfr); |
1007 | 1007 | $sthsm->execute(array(':mfr' => $data[2])); |
1008 | - } catch(PDOException $e) { |
|
1008 | + } catch (PDOException $e) { |
|
1009 | 1009 | return "error mfr : ".$e->getMessage(); |
1010 | 1010 | } |
1011 | 1011 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
@@ -1015,8 +1015,8 @@ discard block |
||
1015 | 1015 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1016 | 1016 | try { |
1017 | 1017 | $sthf = $Connection->db->prepare($queryf); |
1018 | - $sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa')); |
|
1019 | - } catch(PDOException $e) { |
|
1018 | + $sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa')); |
|
1019 | + } catch (PDOException $e) { |
|
1020 | 1020 | return "error f : ".$e->getMessage(); |
1021 | 1021 | } |
1022 | 1022 | } |
@@ -1026,13 +1026,13 @@ discard block |
||
1026 | 1026 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1027 | 1027 | try { |
1028 | 1028 | $sth = $Connection->db->prepare($query); |
1029 | - $sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa')); |
|
1030 | - } catch(PDOException $e) { |
|
1029 | + $sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa')); |
|
1030 | + } catch (PDOException $e) { |
|
1031 | 1031 | return "error i : ".$e->getMessage(); |
1032 | 1032 | } |
1033 | 1033 | } |
1034 | 1034 | } |
1035 | - if ($i % 90 == 0) { |
|
1035 | + if ($i%90 == 0) { |
|
1036 | 1036 | if ($globalTransaction) $Connection->db->commit(); |
1037 | 1037 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1038 | 1038 | } |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | $Connection = new Connection(); |
1052 | 1052 | $sth = $Connection->db->prepare($query); |
1053 | 1053 | $sth->execute(array(':source' => 'website_fam')); |
1054 | - } catch(PDOException $e) { |
|
1054 | + } catch (PDOException $e) { |
|
1055 | 1055 | return "error : ".$e->getMessage(); |
1056 | 1056 | } |
1057 | 1057 | |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1072 | 1072 | try { |
1073 | 1073 | $sth = $Connection->db->prepare($query); |
1074 | - $sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam')); |
|
1075 | - } catch(PDOException $e) { |
|
1074 | + $sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam')); |
|
1075 | + } catch (PDOException $e) { |
|
1076 | 1076 | return "error : ".$e->getMessage(); |
1077 | 1077 | } |
1078 | 1078 | } |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | $Connection = new Connection(); |
1092 | 1092 | $sth = $Connection->db->prepare($query); |
1093 | 1093 | $sth->execute(array(':source' => 'website_fam')); |
1094 | - } catch(PDOException $e) { |
|
1094 | + } catch (PDOException $e) { |
|
1095 | 1095 | return "error : ".$e->getMessage(); |
1096 | 1096 | } |
1097 | 1097 | |
@@ -1107,8 +1107,8 @@ discard block |
||
1107 | 1107 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)'; |
1108 | 1108 | try { |
1109 | 1109 | $sth = $Connection->db->prepare($query); |
1110 | - $sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam')); |
|
1111 | - } catch(PDOException $e) { |
|
1110 | + $sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam')); |
|
1111 | + } catch (PDOException $e) { |
|
1112 | 1112 | print_r($data); |
1113 | 1113 | return "error : ".$e->getMessage(); |
1114 | 1114 | } |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | $Connection = new Connection(); |
1129 | 1129 | $sth = $Connection->db->prepare($query); |
1130 | 1130 | $sth->execute(array(':source' => 'website_fam')); |
1131 | - } catch(PDOException $e) { |
|
1131 | + } catch (PDOException $e) { |
|
1132 | 1132 | return "error : ".$e->getMessage(); |
1133 | 1133 | } |
1134 | 1134 | |
@@ -1148,8 +1148,8 @@ discard block |
||
1148 | 1148 | $query = '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)'; |
1149 | 1149 | try { |
1150 | 1150 | $sth = $Connection->db->prepare($query); |
1151 | - $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
|
1152 | - } catch(PDOException $e) { |
|
1151 | + $sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam')); |
|
1152 | + } catch (PDOException $e) { |
|
1153 | 1153 | return "error : ".$e->getMessage(); |
1154 | 1154 | } |
1155 | 1155 | } |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | $Connection = new Connection(); |
1169 | 1169 | $sth = $Connection->db->prepare($query); |
1170 | 1170 | $sth->execute(); |
1171 | - } catch(PDOException $e) { |
|
1171 | + } catch (PDOException $e) { |
|
1172 | 1172 | return "error : ".$e->getMessage(); |
1173 | 1173 | } |
1174 | 1174 | |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | try { |
1184 | 1184 | $sth = $Connection->db->prepare($query); |
1185 | 1185 | $sth->execute(array(':icao' => $icao)); |
1186 | - } catch(PDOException $e) { |
|
1186 | + } catch (PDOException $e) { |
|
1187 | 1187 | return "error : ".$e->getMessage(); |
1188 | 1188 | } |
1189 | 1189 | } |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | return ''; |
1194 | 1194 | } |
1195 | 1195 | |
1196 | - public static function tle($filename,$tletype) { |
|
1196 | + public static function tle($filename, $tletype) { |
|
1197 | 1197 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
1198 | 1198 | global $tmp_dir, $globalTransaction; |
1199 | 1199 | //$Spotter = new Spotter(); |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | $Connection = new Connection(); |
1204 | 1204 | $sth = $Connection->db->prepare($query); |
1205 | 1205 | $sth->execute(array(':source' => $filename)); |
1206 | - } catch(PDOException $e) { |
|
1206 | + } catch (PDOException $e) { |
|
1207 | 1207 | return "error : ".$e->getMessage(); |
1208 | 1208 | } |
1209 | 1209 | |
@@ -1228,8 +1228,8 @@ discard block |
||
1228 | 1228 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
1229 | 1229 | try { |
1230 | 1230 | $sth = $Connection->db->prepare($query); |
1231 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
1232 | - } catch(PDOException $e) { |
|
1231 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
1232 | + } catch (PDOException $e) { |
|
1233 | 1233 | return "error : ".$e->getMessage(); |
1234 | 1234 | } |
1235 | 1235 | |
@@ -1249,28 +1249,28 @@ discard block |
||
1249 | 1249 | */ |
1250 | 1250 | private static function table2array($data) { |
1251 | 1251 | $html = str_get_html($data); |
1252 | - $tabledata=array(); |
|
1253 | - foreach($html->find('tr') as $element) |
|
1252 | + $tabledata = array(); |
|
1253 | + foreach ($html->find('tr') as $element) |
|
1254 | 1254 | { |
1255 | 1255 | $td = array(); |
1256 | - foreach( $element->find('th') as $row) |
|
1256 | + foreach ($element->find('th') as $row) |
|
1257 | 1257 | { |
1258 | 1258 | $td [] = trim($row->plaintext); |
1259 | 1259 | } |
1260 | - $td=array_filter($td); |
|
1260 | + $td = array_filter($td); |
|
1261 | 1261 | $tabledata[] = $td; |
1262 | 1262 | |
1263 | 1263 | $td = array(); |
1264 | 1264 | $tdi = array(); |
1265 | - foreach( $element->find('td') as $row) |
|
1265 | + foreach ($element->find('td') as $row) |
|
1266 | 1266 | { |
1267 | 1267 | $td [] = trim($row->plaintext); |
1268 | 1268 | $tdi [] = trim($row->innertext); |
1269 | 1269 | } |
1270 | - $td=array_filter($td); |
|
1271 | - $tdi=array_filter($tdi); |
|
1270 | + $td = array_filter($td); |
|
1271 | + $tdi = array_filter($tdi); |
|
1272 | 1272 | // $tabledata[]=array_merge($td,$tdi); |
1273 | - $tabledata[]=$td; |
|
1273 | + $tabledata[] = $td; |
|
1274 | 1274 | } |
1275 | 1275 | return(array_filter($tabledata)); |
1276 | 1276 | } |
@@ -1343,13 +1343,13 @@ discard block |
||
1343 | 1343 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1344 | 1344 | { |
1345 | 1345 | $i++; |
1346 | - if($i > 3 && count($row) > 2) { |
|
1346 | + if ($i > 3 && count($row) > 2) { |
|
1347 | 1347 | $data = array_values(array_filter($row)); |
1348 | 1348 | $cntdata = count($data); |
1349 | 1349 | if ($cntdata > 10) { |
1350 | 1350 | $value = $data[9]; |
1351 | 1351 | |
1352 | - for ($i =10;$i < $cntdata;$i++) { |
|
1352 | + for ($i = 10; $i < $cntdata; $i++) { |
|
1353 | 1353 | $value .= ' '.$data[$i]; |
1354 | 1354 | } |
1355 | 1355 | $data[9] = $value; |
@@ -1359,8 +1359,8 @@ discard block |
||
1359 | 1359 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; |
1360 | 1360 | try { |
1361 | 1361 | $sth = $Connection->db->prepare($query); |
1362 | - $sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
1363 | - } catch(PDOException $e) { |
|
1362 | + $sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
1363 | + } catch (PDOException $e) { |
|
1364 | 1364 | return "error : ".$e->getMessage(); |
1365 | 1365 | } |
1366 | 1366 | } |
@@ -1381,7 +1381,7 @@ discard block |
||
1381 | 1381 | $Connection = new Connection(); |
1382 | 1382 | $sth = $Connection->db->prepare($query); |
1383 | 1383 | $sth->execute(); |
1384 | - } catch(PDOException $e) { |
|
1384 | + } catch (PDOException $e) { |
|
1385 | 1385 | return "error : ".$e->getMessage(); |
1386 | 1386 | } |
1387 | 1387 | |
@@ -1393,12 +1393,12 @@ discard block |
||
1393 | 1393 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1394 | 1394 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1395 | 1395 | { |
1396 | - if(count($row) > 1) { |
|
1396 | + if (count($row) > 1) { |
|
1397 | 1397 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
1398 | 1398 | try { |
1399 | 1399 | $sth = $Connection->db->prepare($query); |
1400 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
1401 | - } catch(PDOException $e) { |
|
1400 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
1401 | + } catch (PDOException $e) { |
|
1402 | 1402 | return "error : ".$e->getMessage(); |
1403 | 1403 | } |
1404 | 1404 | } |
@@ -1418,21 +1418,21 @@ discard block |
||
1418 | 1418 | try { |
1419 | 1419 | $sth = $Connection->db->prepare($query); |
1420 | 1420 | $sth->execute(); |
1421 | - } catch(PDOException $e) { |
|
1421 | + } catch (PDOException $e) { |
|
1422 | 1422 | return "error : ".$e->getMessage(); |
1423 | 1423 | } |
1424 | 1424 | } |
1425 | 1425 | |
1426 | 1426 | |
1427 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1427 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1428 | 1428 | else { |
1429 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1429 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1430 | 1430 | $query = "CREATE EXTENSION postgis"; |
1431 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
1431 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
1432 | 1432 | try { |
1433 | 1433 | $sth = $Connection->db->prepare($query); |
1434 | 1434 | $sth->execute(); |
1435 | - } catch(PDOException $e) { |
|
1435 | + } catch (PDOException $e) { |
|
1436 | 1436 | return "error : ".$e->getMessage(); |
1437 | 1437 | } |
1438 | 1438 | } |
@@ -1445,7 +1445,7 @@ discard block |
||
1445 | 1445 | include_once('class.create_db.php'); |
1446 | 1446 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1447 | 1447 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
1448 | - update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
1448 | + update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
1449 | 1449 | $error = ''; |
1450 | 1450 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1451 | 1451 | if ($globalDebug) echo "Gunzip..."; |
@@ -1477,14 +1477,14 @@ discard block |
||
1477 | 1477 | try { |
1478 | 1478 | $sth = $Connection->db->prepare($query); |
1479 | 1479 | $sth->execute(); |
1480 | - } catch(PDOException $e) { |
|
1480 | + } catch (PDOException $e) { |
|
1481 | 1481 | echo "error : ".$e->getMessage(); |
1482 | 1482 | } |
1483 | 1483 | } |
1484 | 1484 | if ($globalDBdriver == 'mysql') { |
1485 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1485 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1486 | 1486 | } else { |
1487 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1487 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1488 | 1488 | } |
1489 | 1489 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
1490 | 1490 | return $error; |
@@ -1497,7 +1497,7 @@ discard block |
||
1497 | 1497 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
1498 | 1498 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
1499 | 1499 | // update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
1500 | - update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
|
1500 | + update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); |
|
1501 | 1501 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
1502 | 1502 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
1503 | 1503 | return $error; |
@@ -1517,7 +1517,7 @@ discard block |
||
1517 | 1517 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1518 | 1518 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
1519 | 1519 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1520 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1520 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1521 | 1521 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
1522 | 1522 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
1523 | 1523 | if ($error != '') { |
@@ -1530,7 +1530,7 @@ discard block |
||
1530 | 1530 | global $tmp_dir, $globalDebug; |
1531 | 1531 | $error = ''; |
1532 | 1532 | if ($globalDebug) echo "Routes : Download..."; |
1533 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
1533 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
1534 | 1534 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1535 | 1535 | if ($globalDebug) echo "Gunzip..."; |
1536 | 1536 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1546,7 +1546,7 @@ discard block |
||
1546 | 1546 | global $tmp_dir, $globalDebug; |
1547 | 1547 | $error = ''; |
1548 | 1548 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
1549 | - update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
1549 | + update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
1550 | 1550 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1551 | 1551 | if ($globalDebug) echo "Gunzip..."; |
1552 | 1552 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1562,7 +1562,7 @@ discard block |
||
1562 | 1562 | global $tmp_dir, $globalDebug; |
1563 | 1563 | $error = ''; |
1564 | 1564 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
1565 | - update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
1565 | + update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
1566 | 1566 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1567 | 1567 | if ($globalDebug) echo "Gunzip..."; |
1568 | 1568 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -1590,7 +1590,7 @@ discard block |
||
1590 | 1590 | */ |
1591 | 1591 | if ($globalDebug) echo "Modes : Download..."; |
1592 | 1592 | // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
1593 | - update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
|
1593 | + update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz'); |
|
1594 | 1594 | |
1595 | 1595 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1596 | 1596 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | public static function update_ModeS_faa() { |
1611 | 1611 | global $tmp_dir, $globalDebug; |
1612 | 1612 | if ($globalDebug) echo "Modes FAA: Download..."; |
1613 | - update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
|
1613 | + update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip'); |
|
1614 | 1614 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
1615 | 1615 | if ($globalDebug) echo "Unzip..."; |
1616 | 1616 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
@@ -1626,7 +1626,7 @@ discard block |
||
1626 | 1626 | public static function update_ModeS_flarm() { |
1627 | 1627 | global $tmp_dir, $globalDebug; |
1628 | 1628 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
1629 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
1629 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
1630 | 1630 | if (file_exists($tmp_dir.'data.fln')) { |
1631 | 1631 | if ($globalDebug) echo "Add to DB..."; |
1632 | 1632 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1640,7 +1640,7 @@ discard block |
||
1640 | 1640 | public static function update_ModeS_ogn() { |
1641 | 1641 | global $tmp_dir, $globalDebug; |
1642 | 1642 | if ($globalDebug) echo "Modes OGN: Download..."; |
1643 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
1643 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
1644 | 1644 | if (file_exists($tmp_dir.'ogn.csv')) { |
1645 | 1645 | if ($globalDebug) echo "Add to DB..."; |
1646 | 1646 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1655,173 +1655,173 @@ discard block |
||
1655 | 1655 | global $tmp_dir, $globalDebug; |
1656 | 1656 | |
1657 | 1657 | if ($globalDebug) echo "Owner France: Download..."; |
1658 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
1658 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
1659 | 1659 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1660 | 1660 | if ($globalDebug) echo "Add to DB..."; |
1661 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
1661 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
1662 | 1662 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
1663 | 1663 | if ($error != '') { |
1664 | 1664 | return $error; |
1665 | 1665 | } elseif ($globalDebug) echo "Done\n"; |
1666 | 1666 | |
1667 | 1667 | if ($globalDebug) echo "Owner Ireland: Download..."; |
1668 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
1668 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
1669 | 1669 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1670 | 1670 | if ($globalDebug) echo "Add to DB..."; |
1671 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
1671 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
1672 | 1672 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
1673 | 1673 | if ($error != '') { |
1674 | 1674 | return $error; |
1675 | 1675 | } elseif ($globalDebug) echo "Done\n"; |
1676 | 1676 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
1677 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
1677 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
1678 | 1678 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1679 | 1679 | if ($globalDebug) echo "Add to DB..."; |
1680 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
1680 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
1681 | 1681 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
1682 | 1682 | if ($error != '') { |
1683 | 1683 | return $error; |
1684 | 1684 | } elseif ($globalDebug) echo "Done\n"; |
1685 | 1685 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
1686 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
1686 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
1687 | 1687 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1688 | 1688 | if ($globalDebug) echo "Add to DB..."; |
1689 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
1689 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
1690 | 1690 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
1691 | 1691 | if ($error != '') { |
1692 | 1692 | return $error; |
1693 | 1693 | } elseif ($globalDebug) echo "Done\n"; |
1694 | 1694 | if ($globalDebug) echo "Owner Australia: Download..."; |
1695 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
1695 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
1696 | 1696 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1697 | 1697 | if ($globalDebug) echo "Add to DB..."; |
1698 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
1698 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
1699 | 1699 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
1700 | 1700 | if ($error != '') { |
1701 | 1701 | return $error; |
1702 | 1702 | } elseif ($globalDebug) echo "Done\n"; |
1703 | 1703 | if ($globalDebug) echo "Owner Austria: Download..."; |
1704 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
1704 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
1705 | 1705 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1706 | 1706 | if ($globalDebug) echo "Add to DB..."; |
1707 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
1707 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
1708 | 1708 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
1709 | 1709 | if ($error != '') { |
1710 | 1710 | return $error; |
1711 | 1711 | } elseif ($globalDebug) echo "Done\n"; |
1712 | 1712 | if ($globalDebug) echo "Owner Chile: Download..."; |
1713 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
1713 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
1714 | 1714 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1715 | 1715 | if ($globalDebug) echo "Add to DB..."; |
1716 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
1716 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
1717 | 1717 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
1718 | 1718 | if ($error != '') { |
1719 | 1719 | return $error; |
1720 | 1720 | } elseif ($globalDebug) echo "Done\n"; |
1721 | 1721 | if ($globalDebug) echo "Owner Colombia: Download..."; |
1722 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
1722 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
1723 | 1723 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1724 | 1724 | if ($globalDebug) echo "Add to DB..."; |
1725 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
1725 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
1726 | 1726 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
1727 | 1727 | if ($error != '') { |
1728 | 1728 | return $error; |
1729 | 1729 | } elseif ($globalDebug) echo "Done\n"; |
1730 | 1730 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
1731 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
1731 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
1732 | 1732 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1733 | 1733 | if ($globalDebug) echo "Add to DB..."; |
1734 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
1734 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
1735 | 1735 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
1736 | 1736 | if ($error != '') { |
1737 | 1737 | return $error; |
1738 | 1738 | } elseif ($globalDebug) echo "Done\n"; |
1739 | 1739 | if ($globalDebug) echo "Owner Brazil: Download..."; |
1740 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
1740 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
1741 | 1741 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1742 | 1742 | if ($globalDebug) echo "Add to DB..."; |
1743 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
1743 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
1744 | 1744 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
1745 | 1745 | if ($error != '') { |
1746 | 1746 | return $error; |
1747 | 1747 | } elseif ($globalDebug) echo "Done\n"; |
1748 | 1748 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
1749 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
1749 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
1750 | 1750 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1751 | 1751 | if ($globalDebug) echo "Add to DB..."; |
1752 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
1752 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
1753 | 1753 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
1754 | 1754 | if ($error != '') { |
1755 | 1755 | return $error; |
1756 | 1756 | } elseif ($globalDebug) echo "Done\n"; |
1757 | 1757 | if ($globalDebug) echo "Owner Croatia: Download..."; |
1758 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
1758 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
1759 | 1759 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1760 | 1760 | if ($globalDebug) echo "Add to DB..."; |
1761 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
1761 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
1762 | 1762 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
1763 | 1763 | if ($error != '') { |
1764 | 1764 | return $error; |
1765 | 1765 | } elseif ($globalDebug) echo "Done\n"; |
1766 | 1766 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
1767 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
1767 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
1768 | 1768 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1769 | 1769 | if ($globalDebug) echo "Add to DB..."; |
1770 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
1770 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
1771 | 1771 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
1772 | 1772 | if ($error != '') { |
1773 | 1773 | return $error; |
1774 | 1774 | } elseif ($globalDebug) echo "Done\n"; |
1775 | 1775 | if ($globalDebug) echo "Owner Maldives: Download..."; |
1776 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
1776 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
1777 | 1777 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1778 | 1778 | if ($globalDebug) echo "Add to DB..."; |
1779 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
1779 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
1780 | 1780 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
1781 | 1781 | if ($error != '') { |
1782 | 1782 | return $error; |
1783 | 1783 | } elseif ($globalDebug) echo "Done\n"; |
1784 | 1784 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
1785 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
1785 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
1786 | 1786 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1787 | 1787 | if ($globalDebug) echo "Add to DB..."; |
1788 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
1788 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
1789 | 1789 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
1790 | 1790 | if ($error != '') { |
1791 | 1791 | return $error; |
1792 | 1792 | } elseif ($globalDebug) echo "Done\n"; |
1793 | 1793 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
1794 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
1794 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
1795 | 1795 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1796 | 1796 | if ($globalDebug) echo "Add to DB..."; |
1797 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
1797 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
1798 | 1798 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
1799 | 1799 | if ($error != '') { |
1800 | 1800 | return $error; |
1801 | 1801 | } elseif ($globalDebug) echo "Done\n"; |
1802 | 1802 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
1803 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
1803 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
1804 | 1804 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1805 | 1805 | if ($globalDebug) echo "Add to DB..."; |
1806 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
1806 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
1807 | 1807 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
1808 | 1808 | if ($error != '') { |
1809 | 1809 | return $error; |
1810 | 1810 | } elseif ($globalDebug) echo "Done\n"; |
1811 | 1811 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
1812 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
1812 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
1813 | 1813 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1814 | 1814 | if ($globalDebug) echo "Add to DB..."; |
1815 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
1815 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
1816 | 1816 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
1817 | 1817 | if ($error != '') { |
1818 | 1818 | return $error; |
1819 | 1819 | } elseif ($globalDebug) echo "Done\n"; |
1820 | 1820 | if ($globalDebug) echo "Owner Iceland: Download..."; |
1821 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
1821 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
1822 | 1822 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1823 | 1823 | if ($globalDebug) echo "Add to DB..."; |
1824 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
1824 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
1825 | 1825 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
1826 | 1826 | if ($error != '') { |
1827 | 1827 | return $error; |
@@ -1833,7 +1833,7 @@ discard block |
||
1833 | 1833 | global $tmp_dir, $globalDebug; |
1834 | 1834 | $error = ''; |
1835 | 1835 | if ($globalDebug) echo "Translation : Download..."; |
1836 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
1836 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
1837 | 1837 | if (file_exists($tmp_dir.'translation.zip')) { |
1838 | 1838 | if ($globalDebug) echo "Unzip..."; |
1839 | 1839 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1849,7 +1849,7 @@ discard block |
||
1849 | 1849 | public static function update_translation_fam() { |
1850 | 1850 | global $tmp_dir, $globalDebug; |
1851 | 1851 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
1852 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
1852 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
1853 | 1853 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1854 | 1854 | if ($globalDebug) echo "Gunzip..."; |
1855 | 1855 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1864,7 +1864,7 @@ discard block |
||
1864 | 1864 | public static function update_ModeS_fam() { |
1865 | 1865 | global $tmp_dir, $globalDebug; |
1866 | 1866 | if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
1867 | - update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
|
1867 | + update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz'); |
|
1868 | 1868 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
1869 | 1869 | if ($globalDebug) echo "Gunzip..."; |
1870 | 1870 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
@@ -1880,9 +1880,9 @@ discard block |
||
1880 | 1880 | global $tmp_dir, $globalDebug, $globalOwner; |
1881 | 1881 | if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
1882 | 1882 | if ($globalOwner === TRUE) { |
1883 | - update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
1883 | + update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
1884 | 1884 | } else { |
1885 | - update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
1885 | + update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
1886 | 1886 | } |
1887 | 1887 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
1888 | 1888 | if ($globalDebug) echo "Gunzip..."; |
@@ -1898,7 +1898,7 @@ discard block |
||
1898 | 1898 | public static function update_routes_fam() { |
1899 | 1899 | global $tmp_dir, $globalDebug; |
1900 | 1900 | if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
1901 | - update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
|
1901 | + update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz'); |
|
1902 | 1902 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
1903 | 1903 | if ($globalDebug) echo "Gunzip..."; |
1904 | 1904 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
@@ -1913,7 +1913,7 @@ discard block |
||
1913 | 1913 | public static function update_banned_fam() { |
1914 | 1914 | global $tmp_dir, $globalDebug; |
1915 | 1915 | if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
1916 | - update_db::download('http://data.flightairmap.fr/data/ban_ue.csv',$tmp_dir.'ban_ue.csv'); |
|
1916 | + update_db::download('http://data.flightairmap.fr/data/ban_ue.csv', $tmp_dir.'ban_ue.csv'); |
|
1917 | 1917 | if (file_exists($tmp_dir.'ban_ue.csv')) { |
1918 | 1918 | //if ($globalDebug) echo "Gunzip..."; |
1919 | 1919 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
@@ -1932,18 +1932,18 @@ discard block |
||
1932 | 1932 | $error = ''; |
1933 | 1933 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
1934 | 1934 | if ($globalDBdriver == 'mysql') { |
1935 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
1935 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
1936 | 1936 | } else { |
1937 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
1937 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
1938 | 1938 | } |
1939 | 1939 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
1940 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
1940 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
1941 | 1941 | $airspace_md5 = $airspace_md5_file[0]; |
1942 | 1942 | if (!update_db::check_airspace_version($airspace_md5)) { |
1943 | 1943 | if ($globalDBdriver == 'mysql') { |
1944 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
1944 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
1945 | 1945 | } else { |
1946 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
1946 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
1947 | 1947 | } |
1948 | 1948 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
1949 | 1949 | if ($globalDebug) echo "Gunzip..."; |
@@ -1955,7 +1955,7 @@ discard block |
||
1955 | 1955 | try { |
1956 | 1956 | $sth = $Connection->db->prepare($query); |
1957 | 1957 | $sth->execute(); |
1958 | - } catch(PDOException $e) { |
|
1958 | + } catch (PDOException $e) { |
|
1959 | 1959 | return "error : ".$e->getMessage(); |
1960 | 1960 | } |
1961 | 1961 | } |
@@ -1973,15 +1973,15 @@ discard block |
||
1973 | 1973 | public static function update_tle() { |
1974 | 1974 | global $tmp_dir, $globalDebug; |
1975 | 1975 | if ($globalDebug) echo "Download TLE : Download..."; |
1976 | - $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 | - '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 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
1976 | + $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 | + '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 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
1979 | 1979 | foreach ($alltle as $filename) { |
1980 | 1980 | if ($globalDebug) echo "downloading ".$filename.'...'; |
1981 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
1981 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
1982 | 1982 | if (file_exists($tmp_dir.$filename)) { |
1983 | 1983 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
1984 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
1984 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
1985 | 1985 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
1986 | 1986 | if ($error != '') { |
1987 | 1987 | echo $error."\n"; |
@@ -1994,32 +1994,32 @@ discard block |
||
1994 | 1994 | global $tmp_dir, $globalDebug; |
1995 | 1995 | $error = ''; |
1996 | 1996 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
1997 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
1997 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
1998 | 1998 | if (file_exists($tmp_dir.'models.md5sum')) { |
1999 | 1999 | if ($globalDebug) echo "Check files...\n"; |
2000 | 2000 | $newmodelsdb = array(); |
2001 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
2002 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2001 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
2002 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2003 | 2003 | $model = trim($row[2]); |
2004 | 2004 | $newmodelsdb[$model] = trim($row[0]); |
2005 | 2005 | } |
2006 | 2006 | } |
2007 | 2007 | $modelsdb = array(); |
2008 | 2008 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
2009 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
2010 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2009 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
2010 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2011 | 2011 | $model = trim($row[2]); |
2012 | 2012 | $modelsdb[$model] = trim($row[0]); |
2013 | 2013 | } |
2014 | 2014 | } |
2015 | 2015 | } |
2016 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2016 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2017 | 2017 | foreach ($diff as $key => $value) { |
2018 | 2018 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
2019 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
2019 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
2020 | 2020 | |
2021 | 2021 | } |
2022 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
2022 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
2023 | 2023 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2024 | 2024 | if ($error != '') { |
2025 | 2025 | return $error; |
@@ -2031,32 +2031,32 @@ discard block |
||
2031 | 2031 | global $tmp_dir, $globalDebug; |
2032 | 2032 | $error = ''; |
2033 | 2033 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
2034 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
2034 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
2035 | 2035 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2036 | 2036 | if ($globalDebug) echo "Check files...\n"; |
2037 | 2037 | $newmodelsdb = array(); |
2038 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
2039 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2038 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
2039 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2040 | 2040 | $model = trim($row[2]); |
2041 | 2041 | $newmodelsdb[$model] = trim($row[0]); |
2042 | 2042 | } |
2043 | 2043 | } |
2044 | 2044 | $modelsdb = array(); |
2045 | 2045 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
2046 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
2047 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
2046 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
2047 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
2048 | 2048 | $model = trim($row[2]); |
2049 | 2049 | $modelsdb[$model] = trim($row[0]); |
2050 | 2050 | } |
2051 | 2051 | } |
2052 | 2052 | } |
2053 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
2053 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
2054 | 2054 | foreach ($diff as $key => $value) { |
2055 | 2055 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
2056 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
2056 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
2057 | 2057 | |
2058 | 2058 | } |
2059 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
2059 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
2060 | 2060 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
2061 | 2061 | if ($error != '') { |
2062 | 2062 | return $error; |
@@ -2079,8 +2079,8 @@ discard block |
||
2079 | 2079 | */ |
2080 | 2080 | if (file_exists($tmp_dir.'aircrafts.html')) { |
2081 | 2081 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
2082 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
2083 | - $result = fread($fh,100000000); |
|
2082 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
2083 | + $result = fread($fh, 100000000); |
|
2084 | 2084 | //echo $result; |
2085 | 2085 | //var_dump(str_get_html($result)); |
2086 | 2086 | //print_r(self::table2array($result)); |
@@ -2098,23 +2098,23 @@ discard block |
||
2098 | 2098 | $Connection = new Connection(); |
2099 | 2099 | $sth = $Connection->db->prepare($query); |
2100 | 2100 | $sth->execute(); |
2101 | - } catch(PDOException $e) { |
|
2101 | + } catch (PDOException $e) { |
|
2102 | 2102 | return "error : ".$e->getMessage(); |
2103 | 2103 | } |
2104 | 2104 | |
2105 | 2105 | $error = ''; |
2106 | 2106 | if ($globalDebug) echo "Notam : Download..."; |
2107 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
2107 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
2108 | 2108 | if (file_exists($tmp_dir.'notam.rss')) { |
2109 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
2109 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
2110 | 2110 | foreach ($notams['channel']['item'] as $notam) { |
2111 | - $title = explode(':',$notam['title']); |
|
2111 | + $title = explode(':', $notam['title']); |
|
2112 | 2112 | $data['ref'] = trim($title[0]); |
2113 | 2113 | unset($title[0]); |
2114 | - $data['title'] = trim(implode(':',$title)); |
|
2115 | - $description = strip_tags($notam['description'],'<pre>'); |
|
2116 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
2117 | - $q = explode('/',$match[1]); |
|
2114 | + $data['title'] = trim(implode(':', $title)); |
|
2115 | + $description = strip_tags($notam['description'], '<pre>'); |
|
2116 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
2117 | + $q = explode('/', $match[1]); |
|
2118 | 2118 | $data['fir'] = $q[0]; |
2119 | 2119 | $data['code'] = $q[1]; |
2120 | 2120 | $ifrvfr = $q[2]; |
@@ -2130,30 +2130,30 @@ discard block |
||
2130 | 2130 | $data['lower_limit'] = $q[5]; |
2131 | 2131 | $data['upper_limit'] = $q[6]; |
2132 | 2132 | $latlonrad = $q[7]; |
2133 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
2134 | - $latitude = $Common->convertDec($las,'latitude'); |
|
2135 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
2133 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
2134 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
2135 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
2136 | 2136 | if ($lac == 'S') $latitude = '-'.$latitude; |
2137 | 2137 | if ($lnc == 'W') $longitude = '-'.$longitude; |
2138 | 2138 | $data['center_latitude'] = $latitude; |
2139 | 2139 | $data['center_longitude'] = $longitude; |
2140 | 2140 | $data['radius'] = intval($radius); |
2141 | 2141 | |
2142 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
2142 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
2143 | 2143 | $data['text'] = $match[1]; |
2144 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
2144 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
2145 | 2145 | $fromto = $match[1]; |
2146 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
2146 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
2147 | 2147 | $fromall = trim($match[1]); |
2148 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
2148 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
2149 | 2149 | $from = trim($match[1]); |
2150 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
2151 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
2150 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
2151 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
2152 | 2152 | $toall = trim($match[1]); |
2153 | - if (!preg_match(':Permanent:',$toall)) { |
|
2154 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
2153 | + if (!preg_match(':Permanent:', $toall)) { |
|
2154 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
2155 | 2155 | $to = trim($match[1]); |
2156 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
2156 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
2157 | 2157 | $data['permanent'] = 0; |
2158 | 2158 | } else { |
2159 | 2159 | $data['date_end'] = NULL; |
@@ -2161,7 +2161,7 @@ discard block |
||
2161 | 2161 | } |
2162 | 2162 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
2163 | 2163 | $NOTAM = new NOTAM(); |
2164 | - $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']); |
|
2164 | + $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 | 2165 | unset($data); |
2166 | 2166 | } |
2167 | 2167 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -2184,16 +2184,16 @@ discard block |
||
2184 | 2184 | $Connection = new Connection(); |
2185 | 2185 | $sth = $Connection->db->prepare($query); |
2186 | 2186 | $sth->execute(); |
2187 | - } catch(PDOException $e) { |
|
2187 | + } catch (PDOException $e) { |
|
2188 | 2188 | return "error : ".$e->getMessage(); |
2189 | 2189 | } |
2190 | 2190 | } |
2191 | 2191 | $Common = new Common(); |
2192 | 2192 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
2193 | - $airspace_json = json_decode($airspace_lst,true); |
|
2193 | + $airspace_json = json_decode($airspace_lst, true); |
|
2194 | 2194 | foreach ($airspace_json['records'] as $airspace) { |
2195 | 2195 | if ($globalDebug) echo $airspace['name']."...\n"; |
2196 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
2196 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
2197 | 2197 | if (file_exists($tmp_dir.$airspace['name'])) { |
2198 | 2198 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
2199 | 2199 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -2217,7 +2217,7 @@ discard block |
||
2217 | 2217 | $Connection = new Connection(); |
2218 | 2218 | $sth = $Connection->db->prepare($query); |
2219 | 2219 | $sth->execute(); |
2220 | - } catch(PDOException $e) { |
|
2220 | + } catch (PDOException $e) { |
|
2221 | 2221 | return "error : ".$e->getMessage(); |
2222 | 2222 | } |
2223 | 2223 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2232,7 +2232,7 @@ discard block |
||
2232 | 2232 | $Connection = new Connection(); |
2233 | 2233 | $sth = $Connection->db->prepare($query); |
2234 | 2234 | $sth->execute(); |
2235 | - } catch(PDOException $e) { |
|
2235 | + } catch (PDOException $e) { |
|
2236 | 2236 | return "error : ".$e->getMessage(); |
2237 | 2237 | } |
2238 | 2238 | } |
@@ -2243,7 +2243,7 @@ discard block |
||
2243 | 2243 | $Connection = new Connection(); |
2244 | 2244 | $sth = $Connection->db->prepare($query); |
2245 | 2245 | $sth->execute(array(':version' => $version)); |
2246 | - } catch(PDOException $e) { |
|
2246 | + } catch (PDOException $e) { |
|
2247 | 2247 | return "error : ".$e->getMessage(); |
2248 | 2248 | } |
2249 | 2249 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2259,7 +2259,7 @@ discard block |
||
2259 | 2259 | $Connection = new Connection(); |
2260 | 2260 | $sth = $Connection->db->prepare($query); |
2261 | 2261 | $sth->execute(array(':version' => $version)); |
2262 | - } catch(PDOException $e) { |
|
2262 | + } catch (PDOException $e) { |
|
2263 | 2263 | return "error : ".$e->getMessage(); |
2264 | 2264 | } |
2265 | 2265 | } |
@@ -2275,7 +2275,7 @@ discard block |
||
2275 | 2275 | $Connection = new Connection(); |
2276 | 2276 | $sth = $Connection->db->prepare($query); |
2277 | 2277 | $sth->execute(); |
2278 | - } catch(PDOException $e) { |
|
2278 | + } catch (PDOException $e) { |
|
2279 | 2279 | return "error : ".$e->getMessage(); |
2280 | 2280 | } |
2281 | 2281 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2290,7 +2290,7 @@ discard block |
||
2290 | 2290 | $Connection = new Connection(); |
2291 | 2291 | $sth = $Connection->db->prepare($query); |
2292 | 2292 | $sth->execute(); |
2293 | - } catch(PDOException $e) { |
|
2293 | + } catch (PDOException $e) { |
|
2294 | 2294 | return "error : ".$e->getMessage(); |
2295 | 2295 | } |
2296 | 2296 | } |
@@ -2305,7 +2305,7 @@ discard block |
||
2305 | 2305 | $Connection = new Connection(); |
2306 | 2306 | $sth = $Connection->db->prepare($query); |
2307 | 2307 | $sth->execute(); |
2308 | - } catch(PDOException $e) { |
|
2308 | + } catch (PDOException $e) { |
|
2309 | 2309 | return "error : ".$e->getMessage(); |
2310 | 2310 | } |
2311 | 2311 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2320,7 +2320,7 @@ discard block |
||
2320 | 2320 | $Connection = new Connection(); |
2321 | 2321 | $sth = $Connection->db->prepare($query); |
2322 | 2322 | $sth->execute(); |
2323 | - } catch(PDOException $e) { |
|
2323 | + } catch (PDOException $e) { |
|
2324 | 2324 | return "error : ".$e->getMessage(); |
2325 | 2325 | } |
2326 | 2326 | } |
@@ -2336,7 +2336,7 @@ discard block |
||
2336 | 2336 | $Connection = new Connection(); |
2337 | 2337 | $sth = $Connection->db->prepare($query); |
2338 | 2338 | $sth->execute(); |
2339 | - } catch(PDOException $e) { |
|
2339 | + } catch (PDOException $e) { |
|
2340 | 2340 | return "error : ".$e->getMessage(); |
2341 | 2341 | } |
2342 | 2342 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2351,7 +2351,7 @@ discard block |
||
2351 | 2351 | $Connection = new Connection(); |
2352 | 2352 | $sth = $Connection->db->prepare($query); |
2353 | 2353 | $sth->execute(); |
2354 | - } catch(PDOException $e) { |
|
2354 | + } catch (PDOException $e) { |
|
2355 | 2355 | return "error : ".$e->getMessage(); |
2356 | 2356 | } |
2357 | 2357 | } |
@@ -2366,7 +2366,7 @@ discard block |
||
2366 | 2366 | $Connection = new Connection(); |
2367 | 2367 | $sth = $Connection->db->prepare($query); |
2368 | 2368 | $sth->execute(); |
2369 | - } catch(PDOException $e) { |
|
2369 | + } catch (PDOException $e) { |
|
2370 | 2370 | return "error : ".$e->getMessage(); |
2371 | 2371 | } |
2372 | 2372 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2381,7 +2381,7 @@ discard block |
||
2381 | 2381 | $Connection = new Connection(); |
2382 | 2382 | $sth = $Connection->db->prepare($query); |
2383 | 2383 | $sth->execute(); |
2384 | - } catch(PDOException $e) { |
|
2384 | + } catch (PDOException $e) { |
|
2385 | 2385 | return "error : ".$e->getMessage(); |
2386 | 2386 | } |
2387 | 2387 | } |
@@ -2396,7 +2396,7 @@ discard block |
||
2396 | 2396 | $Connection = new Connection(); |
2397 | 2397 | $sth = $Connection->db->prepare($query); |
2398 | 2398 | $sth->execute(); |
2399 | - } catch(PDOException $e) { |
|
2399 | + } catch (PDOException $e) { |
|
2400 | 2400 | return "error : ".$e->getMessage(); |
2401 | 2401 | } |
2402 | 2402 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2411,7 +2411,7 @@ discard block |
||
2411 | 2411 | $Connection = new Connection(); |
2412 | 2412 | $sth = $Connection->db->prepare($query); |
2413 | 2413 | $sth->execute(); |
2414 | - } catch(PDOException $e) { |
|
2414 | + } catch (PDOException $e) { |
|
2415 | 2415 | return "error : ".$e->getMessage(); |
2416 | 2416 | } |
2417 | 2417 | } |
@@ -2426,7 +2426,7 @@ discard block |
||
2426 | 2426 | $Connection = new Connection(); |
2427 | 2427 | $sth = $Connection->db->prepare($query); |
2428 | 2428 | $sth->execute(); |
2429 | - } catch(PDOException $e) { |
|
2429 | + } catch (PDOException $e) { |
|
2430 | 2430 | return "error : ".$e->getMessage(); |
2431 | 2431 | } |
2432 | 2432 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2441,7 +2441,7 @@ discard block |
||
2441 | 2441 | $Connection = new Connection(); |
2442 | 2442 | $sth = $Connection->db->prepare($query); |
2443 | 2443 | $sth->execute(); |
2444 | - } catch(PDOException $e) { |
|
2444 | + } catch (PDOException $e) { |
|
2445 | 2445 | return "error : ".$e->getMessage(); |
2446 | 2446 | } |
2447 | 2447 | } |
@@ -2456,7 +2456,7 @@ discard block |
||
2456 | 2456 | $Connection = new Connection(); |
2457 | 2457 | $sth = $Connection->db->prepare($query); |
2458 | 2458 | $sth->execute(); |
2459 | - } catch(PDOException $e) { |
|
2459 | + } catch (PDOException $e) { |
|
2460 | 2460 | return "error : ".$e->getMessage(); |
2461 | 2461 | } |
2462 | 2462 | } |
@@ -2471,7 +2471,7 @@ discard block |
||
2471 | 2471 | $Connection = new Connection(); |
2472 | 2472 | $sth = $Connection->db->prepare($query); |
2473 | 2473 | $sth->execute(); |
2474 | - } catch(PDOException $e) { |
|
2474 | + } catch (PDOException $e) { |
|
2475 | 2475 | return "error : ".$e->getMessage(); |
2476 | 2476 | } |
2477 | 2477 | } |
@@ -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() { |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | class update_schema { |
9 | 9 | |
10 | 10 | public static function update_schedule() { |
11 | - $Connection = new Connection(); |
|
12 | - $Schedule = new Schedule(); |
|
13 | - $query = "SELECT * FROM schedule"; |
|
14 | - try { |
|
15 | - $sth = $Connection->db->prepare($query); |
|
11 | + $Connection = new Connection(); |
|
12 | + $Schedule = new Schedule(); |
|
13 | + $query = "SELECT * FROM schedule"; |
|
14 | + try { |
|
15 | + $sth = $Connection->db->prepare($query); |
|
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch(PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | - } |
|
20 | - while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | - } |
|
19 | + } |
|
20 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | + $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | /* |
@@ -43,198 +43,198 @@ discard block |
||
43 | 43 | } |
44 | 44 | */ |
45 | 45 | private static function update_from_1() { |
46 | - $Connection = new Connection(); |
|
47 | - // Add new column to routes table |
|
48 | - //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
46 | + $Connection = new Connection(); |
|
47 | + // Add new column to routes table |
|
48 | + //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
49 | 49 | $query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL"; |
50 | - try { |
|
51 | - $sth = $Connection->db->prepare($query); |
|
52 | - $sth->execute(); |
|
53 | - } catch(PDOException $e) { |
|
54 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | - } |
|
56 | - // Copy schedules data to routes table |
|
57 | - self::update_schedule(); |
|
58 | - // Delete schedule table |
|
50 | + try { |
|
51 | + $sth = $Connection->db->prepare($query); |
|
52 | + $sth->execute(); |
|
53 | + } catch(PDOException $e) { |
|
54 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | + } |
|
56 | + // Copy schedules data to routes table |
|
57 | + self::update_schedule(); |
|
58 | + // Delete schedule table |
|
59 | 59 | $query = "DROP TABLE `schedule`"; |
60 | - try { |
|
61 | - $sth = $Connection->db->prepare($query); |
|
62 | - $sth->execute(); |
|
63 | - } catch(PDOException $e) { |
|
64 | - return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | - } |
|
66 | - // Add source column |
|
67 | - $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | - try { |
|
69 | - $sth = $Connection->db->prepare($query); |
|
70 | - $sth->execute(); |
|
71 | - } catch(PDOException $e) { |
|
72 | - return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | - } |
|
60 | + try { |
|
61 | + $sth = $Connection->db->prepare($query); |
|
62 | + $sth->execute(); |
|
63 | + } catch(PDOException $e) { |
|
64 | + return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | + } |
|
66 | + // Add source column |
|
67 | + $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | + try { |
|
69 | + $sth = $Connection->db->prepare($query); |
|
70 | + $sth->execute(); |
|
71 | + } catch(PDOException $e) { |
|
72 | + return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | + } |
|
74 | 74 | // Delete unused column |
75 | 75 | $query = "ALTER TABLE `aircraft_modes` DROP `SerialNo`, DROP `OperatorFlagCode`, DROP `Manufacturer`, DROP `Type`, DROP `FirstRegDate`, DROP `CurrentRegDate`, DROP `Country`, DROP `PreviousID`, DROP `DeRegDate`, DROP `Status`, DROP `PopularName`, DROP `GenericName`, DROP `AircraftClass`, DROP `Engines`, DROP `OwnershipStatus`, DROP `RegisteredOwners`, DROP `MTOW`, DROP `TotalHours`, DROP `YearBuilt`, DROP `CofACategory`, DROP `CofAExpiry`, DROP `UserNotes`, DROP `Interested`, DROP `UserTag`, DROP `InfoUrl`, DROP `PictureUrl1`, DROP `PictureUrl2`, DROP `PictureUrl3`, DROP `UserBool1`, DROP `UserBool2`, DROP `UserBool3`, DROP `UserBool4`, DROP `UserBool5`, DROP `UserString1`, DROP `UserString2`, DROP `UserString3`, DROP `UserString4`, DROP `UserString5`, DROP `UserInt1`, DROP `UserInt2`, DROP `UserInt3`, DROP `UserInt4`, DROP `UserInt5`"; |
76 | - try { |
|
77 | - $sth = $Connection->db->prepare($query); |
|
78 | - $sth->execute(); |
|
79 | - } catch(PDOException $e) { |
|
80 | - return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | - } |
|
76 | + try { |
|
77 | + $sth = $Connection->db->prepare($query); |
|
78 | + $sth->execute(); |
|
79 | + } catch(PDOException $e) { |
|
80 | + return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | + } |
|
82 | 82 | // Add ModeS column |
83 | 83 | $query = "ALTER TABLE `spotter_output` ADD `ModeS` VARCHAR(255) NULL"; |
84 | - try { |
|
85 | - $sth = $Connection->db->prepare($query); |
|
86 | - $sth->execute(); |
|
87 | - } catch(PDOException $e) { |
|
88 | - return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | - } |
|
84 | + try { |
|
85 | + $sth = $Connection->db->prepare($query); |
|
86 | + $sth->execute(); |
|
87 | + } catch(PDOException $e) { |
|
88 | + return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | + } |
|
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | - try { |
|
92 | - $sth = $Connection->db->prepare($query); |
|
93 | - $sth->execute(); |
|
94 | - } catch(PDOException $e) { |
|
95 | - return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | - } |
|
97 | - // Add auto_increment for aircraft_modes |
|
98 | - $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | - try { |
|
100 | - $sth = $Connection->db->prepare($query); |
|
101 | - $sth->execute(); |
|
102 | - } catch(PDOException $e) { |
|
103 | - return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | - } |
|
105 | - $error = ''; |
|
91 | + try { |
|
92 | + $sth = $Connection->db->prepare($query); |
|
93 | + $sth->execute(); |
|
94 | + } catch(PDOException $e) { |
|
95 | + return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | + } |
|
97 | + // Add auto_increment for aircraft_modes |
|
98 | + $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | + try { |
|
100 | + $sth = $Connection->db->prepare($query); |
|
101 | + $sth->execute(); |
|
102 | + } catch(PDOException $e) { |
|
103 | + return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | + } |
|
105 | + $error = ''; |
|
106 | 106 | $error .= create_db::import_file('../db/acars_live.sql'); |
107 | 107 | $error .= create_db::import_file('../db/config.sql'); |
108 | 108 | // Update schema_version to 2 |
109 | 109 | $query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'"; |
110 | - try { |
|
111 | - $sth = $Connection->db->prepare($query); |
|
112 | - $sth->execute(); |
|
113 | - } catch(PDOException $e) { |
|
114 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | - } |
|
110 | + try { |
|
111 | + $sth = $Connection->db->prepare($query); |
|
112 | + $sth->execute(); |
|
113 | + } catch(PDOException $e) { |
|
114 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | + } |
|
116 | 116 | return $error; |
117 | - } |
|
117 | + } |
|
118 | 118 | |
119 | 119 | private static function update_from_2() { |
120 | - $Connection = new Connection(); |
|
121 | - // Add new column decode to acars_live table |
|
120 | + $Connection = new Connection(); |
|
121 | + // Add new column decode to acars_live table |
|
122 | 122 | $query = "ALTER TABLE `acars_live` ADD `decode` TEXT"; |
123 | - try { |
|
124 | - $sth = $Connection->db->prepare($query); |
|
125 | - $sth->execute(); |
|
126 | - } catch(PDOException $e) { |
|
127 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | - } |
|
129 | - $error = ''; |
|
130 | - // Create table acars_archive |
|
123 | + try { |
|
124 | + $sth = $Connection->db->prepare($query); |
|
125 | + $sth->execute(); |
|
126 | + } catch(PDOException $e) { |
|
127 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | + } |
|
129 | + $error = ''; |
|
130 | + // Create table acars_archive |
|
131 | 131 | $error .= create_db::import_file('../db/acars_archive.sql'); |
132 | 132 | // Update schema_version to 3 |
133 | 133 | $query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'"; |
134 | - try { |
|
135 | - $sth = $Connection->db->prepare($query); |
|
136 | - $sth->execute(); |
|
137 | - } catch(PDOException $e) { |
|
138 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | - } |
|
134 | + try { |
|
135 | + $sth = $Connection->db->prepare($query); |
|
136 | + $sth->execute(); |
|
137 | + } catch(PDOException $e) { |
|
138 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | + } |
|
140 | 140 | return $error; |
141 | 141 | } |
142 | 142 | |
143 | 143 | private static function update_from_3() { |
144 | - $Connection = new Connection(); |
|
145 | - // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
144 | + $Connection = new Connection(); |
|
145 | + // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
146 | 146 | $query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP"; |
147 | - try { |
|
148 | - $sth = $Connection->db->prepare($query); |
|
149 | - $sth->execute(); |
|
150 | - } catch(PDOException $e) { |
|
151 | - return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | - } |
|
153 | - // Add image_source_website column to spotter_image |
|
147 | + try { |
|
148 | + $sth = $Connection->db->prepare($query); |
|
149 | + $sth->execute(); |
|
150 | + } catch(PDOException $e) { |
|
151 | + return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | + } |
|
153 | + // Add image_source_website column to spotter_image |
|
154 | 154 | $query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL"; |
155 | - try { |
|
156 | - $sth = $Connection->db->prepare($query); |
|
157 | - $sth->execute(); |
|
158 | - } catch(PDOException $e) { |
|
159 | - return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | - } |
|
161 | - $error = ''; |
|
155 | + try { |
|
156 | + $sth = $Connection->db->prepare($query); |
|
157 | + $sth->execute(); |
|
158 | + } catch(PDOException $e) { |
|
159 | + return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | + } |
|
161 | + $error = ''; |
|
162 | 162 | // Update schema_version to 4 |
163 | 163 | $query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'"; |
164 | - try { |
|
165 | - $sth = $Connection->db->prepare($query); |
|
166 | - $sth->execute(); |
|
167 | - } catch(PDOException $e) { |
|
168 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | - } |
|
164 | + try { |
|
165 | + $sth = $Connection->db->prepare($query); |
|
166 | + $sth->execute(); |
|
167 | + } catch(PDOException $e) { |
|
168 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | + } |
|
170 | 170 | return $error; |
171 | 171 | } |
172 | 172 | |
173 | 173 | private static function update_from_4() { |
174 | - $Connection = new Connection(); |
|
174 | + $Connection = new Connection(); |
|
175 | 175 | |
176 | - $error = ''; |
|
177 | - // Create table acars_label |
|
176 | + $error = ''; |
|
177 | + // Create table acars_label |
|
178 | 178 | $error .= create_db::import_file('../db/acars_label.sql'); |
179 | 179 | if ($error == '') { |
180 | - // Update schema_version to 5 |
|
181 | - $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | - try { |
|
183 | - $sth = $Connection->db->prepare($query); |
|
180 | + // Update schema_version to 5 |
|
181 | + $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | + try { |
|
183 | + $sth = $Connection->db->prepare($query); |
|
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch(PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | - } |
|
188 | - } |
|
187 | + } |
|
188 | + } |
|
189 | 189 | return $error; |
190 | 190 | } |
191 | 191 | |
192 | 192 | private static function update_from_5() { |
193 | - $Connection = new Connection(); |
|
194 | - // Add columns to translation |
|
193 | + $Connection = new Connection(); |
|
194 | + // Add columns to translation |
|
195 | 195 | $query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;"; |
196 | - try { |
|
197 | - $sth = $Connection->db->prepare($query); |
|
198 | - $sth->execute(); |
|
199 | - } catch(PDOException $e) { |
|
200 | - return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | - } |
|
202 | - // Add aircraft_shadow column to aircraft |
|
203 | - $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | - try { |
|
205 | - $sth = $Connection->db->prepare($query); |
|
206 | - $sth->execute(); |
|
207 | - } catch(PDOException $e) { |
|
208 | - return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | - } |
|
210 | - // Add aircraft_shadow column to spotter_live |
|
211 | - $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | - try { |
|
213 | - $sth = $Connection->db->prepare($query); |
|
214 | - $sth->execute(); |
|
215 | - } catch(PDOException $e) { |
|
216 | - return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | - } |
|
218 | - $error = ''; |
|
219 | - // Update table aircraft |
|
196 | + try { |
|
197 | + $sth = $Connection->db->prepare($query); |
|
198 | + $sth->execute(); |
|
199 | + } catch(PDOException $e) { |
|
200 | + return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | + } |
|
202 | + // Add aircraft_shadow column to aircraft |
|
203 | + $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | + try { |
|
205 | + $sth = $Connection->db->prepare($query); |
|
206 | + $sth->execute(); |
|
207 | + } catch(PDOException $e) { |
|
208 | + return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | + } |
|
210 | + // Add aircraft_shadow column to spotter_live |
|
211 | + $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | + try { |
|
213 | + $sth = $Connection->db->prepare($query); |
|
214 | + $sth->execute(); |
|
215 | + } catch(PDOException $e) { |
|
216 | + return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | + } |
|
218 | + $error = ''; |
|
219 | + // Update table aircraft |
|
220 | 220 | $error .= create_db::import_file('../db/aircraft.sql'); |
221 | 221 | $error .= create_db::import_file('../db/spotter_archive.sql'); |
222 | 222 | |
223 | 223 | // Update schema_version to 6 |
224 | 224 | $query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'"; |
225 | - try { |
|
226 | - $sth = $Connection->db->prepare($query); |
|
227 | - $sth->execute(); |
|
228 | - } catch(PDOException $e) { |
|
229 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | - } |
|
225 | + try { |
|
226 | + $sth = $Connection->db->prepare($query); |
|
227 | + $sth->execute(); |
|
228 | + } catch(PDOException $e) { |
|
229 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | + } |
|
231 | 231 | return $error; |
232 | 232 | } |
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | - $Connection = new Connection(); |
|
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | - $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
235 | + $Connection = new Connection(); |
|
236 | + if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | + $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
240 | 240 | ALTER TABLE spotter_live ADD INDEX(flightaware_id); |
@@ -247,147 +247,147 @@ discard block |
||
247 | 247 | ALTER TABLE aircraft ADD INDEX(icao); |
248 | 248 | ALTER TABLE airport ADD INDEX(icao); |
249 | 249 | ALTER TABLE translation ADD INDEX(Operator);"; |
250 | - try { |
|
251 | - $sth = $Connection->db->prepare($query); |
|
250 | + try { |
|
251 | + $sth = $Connection->db->prepare($query); |
|
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch(PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | - } |
|
256 | - } |
|
257 | - $error = ''; |
|
258 | - // Update table countries |
|
259 | - if ($Connection->tableExists('airspace')) { |
|
260 | - $error .= update_db::update_countries(); |
|
261 | - if ($error != '') return $error; |
|
255 | + } |
|
256 | + } |
|
257 | + $error = ''; |
|
258 | + // Update table countries |
|
259 | + if ($Connection->tableExists('airspace')) { |
|
260 | + $error .= update_db::update_countries(); |
|
261 | + if ($error != '') return $error; |
|
262 | 262 | } |
263 | 263 | // Update schema_version to 7 |
264 | 264 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
265 | - try { |
|
266 | - $sth = $Connection->db->prepare($query); |
|
267 | - $sth->execute(); |
|
268 | - } catch(PDOException $e) { |
|
269 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | - } |
|
265 | + try { |
|
266 | + $sth = $Connection->db->prepare($query); |
|
267 | + $sth->execute(); |
|
268 | + } catch(PDOException $e) { |
|
269 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | + } |
|
271 | 271 | return $error; |
272 | - } |
|
272 | + } |
|
273 | 273 | |
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | - $Connection = new Connection(); |
|
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
276 | + $Connection = new Connection(); |
|
277 | + $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | - try { |
|
280 | - $sth = $Connection->db->prepare($query); |
|
281 | - $sth->execute(); |
|
282 | - } catch(PDOException $e) { |
|
283 | - return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | - } |
|
285 | - if ($globalDBdriver == 'mysql') { |
|
286 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | - try { |
|
288 | - $sth = $Connection->db->prepare($query); |
|
279 | + try { |
|
280 | + $sth = $Connection->db->prepare($query); |
|
281 | + $sth->execute(); |
|
282 | + } catch(PDOException $e) { |
|
283 | + return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | + } |
|
285 | + if ($globalDBdriver == 'mysql') { |
|
286 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | + try { |
|
288 | + $sth = $Connection->db->prepare($query); |
|
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch(PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | - } |
|
293 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | - if ($row['engine'] == 'ARCHIVE') { |
|
292 | + } |
|
293 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | + if ($row['engine'] == 'ARCHIVE') { |
|
295 | 295 | $query = "CREATE TABLE copy LIKE spotter_archive; |
296 | 296 | ALTER TABLE copy ENGINE=ARCHIVE; |
297 | 297 | ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
298 | 298 | INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`; |
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | - } else { |
|
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | - } |
|
304 | - } else { |
|
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | - } |
|
307 | - try { |
|
308 | - $sth = $Connection->db->prepare($query); |
|
309 | - $sth->execute(); |
|
310 | - } catch(PDOException $e) { |
|
311 | - return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | - } |
|
301 | + } else { |
|
302 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | + } |
|
304 | + } else { |
|
305 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | + } |
|
307 | + try { |
|
308 | + $sth = $Connection->db->prepare($query); |
|
309 | + $sth->execute(); |
|
310 | + } catch(PDOException $e) { |
|
311 | + return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | + } |
|
313 | 313 | |
314 | - $error = ''; |
|
315 | - // Update table aircraft |
|
314 | + $error = ''; |
|
315 | + // Update table aircraft |
|
316 | 316 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | 317 | if ($error != '') return $error; |
318 | 318 | // Update schema_version to 6 |
319 | 319 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | - try { |
|
321 | - $sth = $Connection->db->prepare($query); |
|
322 | - $sth->execute(); |
|
323 | - } catch(PDOException $e) { |
|
324 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | - } |
|
320 | + try { |
|
321 | + $sth = $Connection->db->prepare($query); |
|
322 | + $sth->execute(); |
|
323 | + } catch(PDOException $e) { |
|
324 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | + } |
|
326 | 326 | return $error; |
327 | 327 | } |
328 | 328 | |
329 | 329 | private static function update_from_8() { |
330 | - $Connection = new Connection(); |
|
331 | - $error = ''; |
|
332 | - // Update table aircraft |
|
330 | + $Connection = new Connection(); |
|
331 | + $error = ''; |
|
332 | + // Update table aircraft |
|
333 | 333 | $error .= create_db::import_file('../db/notam.sql'); |
334 | 334 | if ($error != '') return $error; |
335 | 335 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 336 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 337 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
338 | 338 | INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());"; |
339 | - try { |
|
340 | - $sth = $Connection->db->prepare($query); |
|
341 | - $sth->execute(); |
|
342 | - } catch(PDOException $e) { |
|
343 | - return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | - } |
|
339 | + try { |
|
340 | + $sth = $Connection->db->prepare($query); |
|
341 | + $sth->execute(); |
|
342 | + } catch(PDOException $e) { |
|
343 | + return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | + } |
|
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | - try { |
|
347 | - $sth = $Connection->db->prepare($query); |
|
348 | - $sth->execute(); |
|
349 | - } catch(PDOException $e) { |
|
350 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | - } |
|
346 | + try { |
|
347 | + $sth = $Connection->db->prepare($query); |
|
348 | + $sth->execute(); |
|
349 | + } catch(PDOException $e) { |
|
350 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | + } |
|
352 | 352 | return $error; |
353 | 353 | } |
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | - $Connection = new Connection(); |
|
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
356 | + $Connection = new Connection(); |
|
357 | + $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | - try { |
|
360 | - $sth = $Connection->db->prepare($query); |
|
361 | - $sth->execute(); |
|
362 | - } catch(PDOException $e) { |
|
363 | - return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | - } |
|
359 | + try { |
|
360 | + $sth = $Connection->db->prepare($query); |
|
361 | + $sth->execute(); |
|
362 | + } catch(PDOException $e) { |
|
363 | + return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | + } |
|
365 | 365 | $error = ''; |
366 | - // Update table atc |
|
366 | + // Update table atc |
|
367 | 367 | $error .= create_db::import_file('../db/atc.sql'); |
368 | 368 | if ($error != '') return $error; |
369 | 369 | |
370 | 370 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | - try { |
|
372 | - $sth = $Connection->db->prepare($query); |
|
373 | - $sth->execute(); |
|
374 | - } catch(PDOException $e) { |
|
375 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | - } |
|
371 | + try { |
|
372 | + $sth = $Connection->db->prepare($query); |
|
373 | + $sth->execute(); |
|
374 | + } catch(PDOException $e) { |
|
375 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | + } |
|
377 | 377 | return $error; |
378 | 378 | } |
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | - $Connection = new Connection(); |
|
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | - try { |
|
384 | - $sth = $Connection->db->prepare($query); |
|
385 | - $sth->execute(); |
|
386 | - } catch(PDOException $e) { |
|
387 | - return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | - } |
|
381 | + $Connection = new Connection(); |
|
382 | + $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | + try { |
|
384 | + $sth = $Connection->db->prepare($query); |
|
385 | + $sth->execute(); |
|
386 | + } catch(PDOException $e) { |
|
387 | + return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | + } |
|
389 | 389 | $error = ''; |
390 | - // Add tables |
|
390 | + // Add tables |
|
391 | 391 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | 392 | if ($error != '') return $error; |
393 | 393 | $error .= create_db::import_file('../db/metar.sql'); |
@@ -398,76 +398,76 @@ discard block |
||
398 | 398 | if ($error != '') return $error; |
399 | 399 | |
400 | 400 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | - try { |
|
402 | - $sth = $Connection->db->prepare($query); |
|
403 | - $sth->execute(); |
|
404 | - } catch(PDOException $e) { |
|
405 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | - } |
|
401 | + try { |
|
402 | + $sth = $Connection->db->prepare($query); |
|
403 | + $sth->execute(); |
|
404 | + } catch(PDOException $e) { |
|
405 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | + } |
|
407 | 407 | return $error; |
408 | 408 | } |
409 | 409 | |
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | - $Connection = new Connection(); |
|
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | - try { |
|
415 | - $sth = $Connection->db->prepare($query); |
|
416 | - $sth->execute(); |
|
417 | - } catch(PDOException $e) { |
|
418 | - return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | - } |
|
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | - try { |
|
422 | - $sth = $Connection->db->prepare($query); |
|
423 | - $sth->execute(); |
|
424 | - } catch(PDOException $e) { |
|
425 | - return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | - } |
|
427 | - if ($globalDBdriver == 'mysql') { |
|
428 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | - try { |
|
430 | - $sth = $Connection->db->prepare($query); |
|
412 | + $Connection = new Connection(); |
|
413 | + $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | + try { |
|
415 | + $sth = $Connection->db->prepare($query); |
|
431 | 416 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
417 | + } catch(PDOException $e) { |
|
418 | + return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | + } |
|
420 | + $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | + try { |
|
422 | + $sth = $Connection->db->prepare($query); |
|
423 | + $sth->execute(); |
|
424 | + } catch(PDOException $e) { |
|
425 | + return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | + } |
|
427 | + if ($globalDBdriver == 'mysql') { |
|
428 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | + try { |
|
430 | + $sth = $Connection->db->prepare($query); |
|
431 | + $sth->execute(); |
|
432 | + } catch(PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | - } |
|
435 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | - if ($row['engine'] == 'ARCHIVE') { |
|
434 | + } |
|
435 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | + if ($row['engine'] == 'ARCHIVE') { |
|
437 | 437 | $query = "CREATE TABLE copy LIKE spotter_archive; |
438 | 438 | ALTER TABLE copy ENGINE=ARCHIVE; |
439 | 439 | ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE; |
440 | 440 | INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`; |
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | - } else { |
|
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | - } |
|
446 | - } else { |
|
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | - } |
|
449 | - try { |
|
450 | - $sth = $Connection->db->prepare($query); |
|
451 | - $sth->execute(); |
|
452 | - } catch(PDOException $e) { |
|
453 | - return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | - } |
|
443 | + } else { |
|
444 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | + } |
|
446 | + } else { |
|
447 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | + } |
|
449 | + try { |
|
450 | + $sth = $Connection->db->prepare($query); |
|
451 | + $sth->execute(); |
|
452 | + } catch(PDOException $e) { |
|
453 | + return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | + } |
|
455 | 455 | |
456 | 456 | $error = ''; |
457 | 457 | |
458 | 458 | $query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'"; |
459 | - try { |
|
460 | - $sth = $Connection->db->prepare($query); |
|
461 | - $sth->execute(); |
|
462 | - } catch(PDOException $e) { |
|
463 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | - } |
|
459 | + try { |
|
460 | + $sth = $Connection->db->prepare($query); |
|
461 | + $sth->execute(); |
|
462 | + } catch(PDOException $e) { |
|
463 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | + } |
|
465 | 465 | return $error; |
466 | 466 | } |
467 | 467 | private static function update_from_12() { |
468 | - $Connection = new Connection(); |
|
468 | + $Connection = new Connection(); |
|
469 | 469 | $error = ''; |
470 | - // Add tables |
|
470 | + // Add tables |
|
471 | 471 | $error .= create_db::import_file('../db/stats.sql'); |
472 | 472 | if ($error != '') return $error; |
473 | 473 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
@@ -484,166 +484,166 @@ discard block |
||
484 | 484 | if ($error != '') return $error; |
485 | 485 | |
486 | 486 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | - try { |
|
488 | - $sth = $Connection->db->prepare($query); |
|
489 | - $sth->execute(); |
|
490 | - } catch(PDOException $e) { |
|
491 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | - } |
|
487 | + try { |
|
488 | + $sth = $Connection->db->prepare($query); |
|
489 | + $sth->execute(); |
|
490 | + } catch(PDOException $e) { |
|
491 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | + } |
|
493 | 493 | return $error; |
494 | 494 | } |
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | - $Connection = new Connection(); |
|
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
497 | + $Connection = new Connection(); |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | + $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch(PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | - } |
|
505 | + } |
|
506 | 506 | } |
507 | - $error = ''; |
|
507 | + $error = ''; |
|
508 | 508 | $query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'"; |
509 | - try { |
|
510 | - $sth = $Connection->db->prepare($query); |
|
511 | - $sth->execute(); |
|
512 | - } catch(PDOException $e) { |
|
513 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | - } |
|
509 | + try { |
|
510 | + $sth = $Connection->db->prepare($query); |
|
511 | + $sth->execute(); |
|
512 | + } catch(PDOException $e) { |
|
513 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | + } |
|
515 | 515 | return $error; |
516 | 516 | } |
517 | 517 | |
518 | 518 | private static function update_from_14() { |
519 | - $Connection = new Connection(); |
|
519 | + $Connection = new Connection(); |
|
520 | 520 | $error = ''; |
521 | - // Add tables |
|
522 | - if (!$Connection->tableExists('stats_flight')) { |
|
521 | + // Add tables |
|
522 | + if (!$Connection->tableExists('stats_flight')) { |
|
523 | 523 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | 524 | if ($error != '') return $error; |
525 | 525 | } |
526 | 526 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | - try { |
|
528 | - $sth = $Connection->db->prepare($query); |
|
529 | - $sth->execute(); |
|
530 | - } catch(PDOException $e) { |
|
531 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | - } |
|
527 | + try { |
|
528 | + $sth = $Connection->db->prepare($query); |
|
529 | + $sth->execute(); |
|
530 | + } catch(PDOException $e) { |
|
531 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | + } |
|
533 | 533 | return $error; |
534 | 534 | } |
535 | 535 | |
536 | 536 | |
537 | 537 | private static function update_from_15() { |
538 | - $Connection = new Connection(); |
|
538 | + $Connection = new Connection(); |
|
539 | 539 | $error = ''; |
540 | - // Add tables |
|
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | - try { |
|
543 | - $sth = $Connection->db->prepare($query); |
|
544 | - $sth->execute(); |
|
545 | - } catch(PDOException $e) { |
|
546 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | - } |
|
540 | + // Add tables |
|
541 | + $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | + try { |
|
543 | + $sth = $Connection->db->prepare($query); |
|
544 | + $sth->execute(); |
|
545 | + } catch(PDOException $e) { |
|
546 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | + } |
|
548 | 548 | if ($error != '') return $error; |
549 | 549 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | - try { |
|
551 | - $sth = $Connection->db->prepare($query); |
|
552 | - $sth->execute(); |
|
553 | - } catch(PDOException $e) { |
|
554 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | - } |
|
550 | + try { |
|
551 | + $sth = $Connection->db->prepare($query); |
|
552 | + $sth->execute(); |
|
553 | + } catch(PDOException $e) { |
|
554 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | + } |
|
556 | 556 | return $error; |
557 | 557 | } |
558 | 558 | |
559 | 559 | private static function update_from_16() { |
560 | - $Connection = new Connection(); |
|
560 | + $Connection = new Connection(); |
|
561 | 561 | $error = ''; |
562 | - // Add tables |
|
563 | - if (!$Connection->tableExists('stats_registration')) { |
|
562 | + // Add tables |
|
563 | + if (!$Connection->tableExists('stats_registration')) { |
|
564 | 564 | $error .= create_db::import_file('../db/stats_registration.sql'); |
565 | 565 | } |
566 | - if (!$Connection->tableExists('stats_callsign')) { |
|
566 | + if (!$Connection->tableExists('stats_callsign')) { |
|
567 | 567 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 568 | } |
569 | 569 | if ($error != '') return $error; |
570 | 570 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | - try { |
|
572 | - $sth = $Connection->db->prepare($query); |
|
573 | - $sth->execute(); |
|
574 | - } catch(PDOException $e) { |
|
575 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | - } |
|
571 | + try { |
|
572 | + $sth = $Connection->db->prepare($query); |
|
573 | + $sth->execute(); |
|
574 | + } catch(PDOException $e) { |
|
575 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | + } |
|
577 | 577 | return $error; |
578 | 578 | } |
579 | 579 | |
580 | 580 | private static function update_from_17() { |
581 | - $Connection = new Connection(); |
|
581 | + $Connection = new Connection(); |
|
582 | 582 | $error = ''; |
583 | - // Add tables |
|
584 | - if (!$Connection->tableExists('stats_country')) { |
|
583 | + // Add tables |
|
584 | + if (!$Connection->tableExists('stats_country')) { |
|
585 | 585 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 586 | } |
587 | 587 | if ($error != '') return $error; |
588 | 588 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | - try { |
|
590 | - $sth = $Connection->db->prepare($query); |
|
591 | - $sth->execute(); |
|
592 | - } catch(PDOException $e) { |
|
593 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | - } |
|
589 | + try { |
|
590 | + $sth = $Connection->db->prepare($query); |
|
591 | + $sth->execute(); |
|
592 | + } catch(PDOException $e) { |
|
593 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | + } |
|
595 | 595 | return $error; |
596 | 596 | } |
597 | 597 | private static function update_from_18() { |
598 | - $Connection = new Connection(); |
|
598 | + $Connection = new Connection(); |
|
599 | 599 | $error = ''; |
600 | - // Modify stats_airport table |
|
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | - $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | - try { |
|
604 | - $sth = $Connection->db->prepare($query); |
|
605 | - $sth->execute(); |
|
606 | - } catch(PDOException $e) { |
|
607 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | - } |
|
609 | - } |
|
600 | + // Modify stats_airport table |
|
601 | + if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | + $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | + try { |
|
604 | + $sth = $Connection->db->prepare($query); |
|
605 | + $sth->execute(); |
|
606 | + } catch(PDOException $e) { |
|
607 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | + } |
|
609 | + } |
|
610 | 610 | if ($error != '') return $error; |
611 | 611 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | - try { |
|
613 | - $sth = $Connection->db->prepare($query); |
|
614 | - $sth->execute(); |
|
615 | - } catch(PDOException $e) { |
|
616 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | - } |
|
612 | + try { |
|
613 | + $sth = $Connection->db->prepare($query); |
|
614 | + $sth->execute(); |
|
615 | + } catch(PDOException $e) { |
|
616 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | + } |
|
618 | 618 | return $error; |
619 | 619 | } |
620 | 620 | |
621 | 621 | private static function update_from_19() { |
622 | - $Connection = new Connection(); |
|
622 | + $Connection = new Connection(); |
|
623 | 623 | $error = ''; |
624 | - // Update airport table |
|
624 | + // Update airport table |
|
625 | 625 | $error .= create_db::import_file('../db/airport.sql'); |
626 | 626 | if ($error != '') return 'Import airport.sql : '.$error; |
627 | 627 | // Remove primary key on Spotter_Archive |
628 | 628 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | - try { |
|
630 | - $sth = $Connection->db->prepare($query); |
|
631 | - $sth->execute(); |
|
632 | - } catch(PDOException $e) { |
|
633 | - return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | - } |
|
629 | + try { |
|
630 | + $sth = $Connection->db->prepare($query); |
|
631 | + $sth->execute(); |
|
632 | + } catch(PDOException $e) { |
|
633 | + return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | + } |
|
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | - try { |
|
637 | - $sth = $Connection->db->prepare($query); |
|
638 | - $sth->execute(); |
|
639 | - } catch(PDOException $e) { |
|
640 | - return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | - } |
|
636 | + try { |
|
637 | + $sth = $Connection->db->prepare($query); |
|
638 | + $sth->execute(); |
|
639 | + } catch(PDOException $e) { |
|
640 | + return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | + } |
|
642 | 642 | if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
643 | 643 | // Add column over_country |
644 | - $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
644 | + $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
645 | 645 | try { |
646 | - $sth = $Connection->db->prepare($query); |
|
646 | + $sth = $Connection->db->prepare($query); |
|
647 | 647 | $sth->execute(); |
648 | 648 | } catch(PDOException $e) { |
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | } |
652 | 652 | if (!$Connection->checkColumnName('spotter_live','over_country')) { |
653 | 653 | // Add column over_country |
654 | - $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
654 | + $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
655 | 655 | try { |
656 | - $sth = $Connection->db->prepare($query); |
|
656 | + $sth = $Connection->db->prepare($query); |
|
657 | 657 | $sth->execute(); |
658 | 658 | } catch(PDOException $e) { |
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -661,74 +661,74 @@ discard block |
||
661 | 661 | } |
662 | 662 | if (!$Connection->checkColumnName('spotter_output','source_name')) { |
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | - $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
664 | + $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | 668 | } catch(PDOException $e) { |
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | - } |
|
671 | - } |
|
670 | + } |
|
671 | + } |
|
672 | 672 | if (!$Connection->checkColumnName('spotter_live','source_name')) { |
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | - $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
674 | + $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | 678 | } catch(PDOException $e) { |
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | - } |
|
681 | - } |
|
680 | + } |
|
681 | + } |
|
682 | 682 | if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | - $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
684 | + $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | 688 | } catch(PDOException $e) { |
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | - } |
|
691 | - } |
|
690 | + } |
|
691 | + } |
|
692 | 692 | if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | - $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
694 | + $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | 698 | } catch(PDOException $e) { |
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | - } |
|
701 | - } |
|
700 | + } |
|
701 | + } |
|
702 | 702 | if ($error != '') return $error; |
703 | 703 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | - try { |
|
705 | - $sth = $Connection->db->prepare($query); |
|
706 | - $sth->execute(); |
|
707 | - } catch(PDOException $e) { |
|
708 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | - } |
|
704 | + try { |
|
705 | + $sth = $Connection->db->prepare($query); |
|
706 | + $sth->execute(); |
|
707 | + } catch(PDOException $e) { |
|
708 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | + } |
|
710 | 710 | return $error; |
711 | 711 | } |
712 | 712 | |
713 | 713 | private static function update_from_20() { |
714 | 714 | global $globalIVAO, $globalVATSIM, $globalphpVMS; |
715 | - $Connection = new Connection(); |
|
715 | + $Connection = new Connection(); |
|
716 | 716 | $error = ''; |
717 | - // Update airline table |
|
718 | - if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
717 | + // Update airline table |
|
718 | + if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | 722 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 723 | // Add column over_country |
724 | - $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | - try { |
|
724 | + $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | + try { |
|
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | 728 | } catch(PDOException $e) { |
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | - } |
|
731 | - } |
|
730 | + } |
|
731 | + } |
|
732 | 732 | if ($error != '') return $error; |
733 | 733 | /* |
734 | 734 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
@@ -738,12 +738,12 @@ discard block |
||
738 | 738 | } |
739 | 739 | */ |
740 | 740 | $query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'"; |
741 | - try { |
|
742 | - $sth = $Connection->db->prepare($query); |
|
743 | - $sth->execute(); |
|
744 | - } catch(PDOException $e) { |
|
745 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | - } |
|
741 | + try { |
|
742 | + $sth = $Connection->db->prepare($query); |
|
743 | + $sth->execute(); |
|
744 | + } catch(PDOException $e) { |
|
745 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | + } |
|
747 | 747 | return $error; |
748 | 748 | } |
749 | 749 | |
@@ -762,35 +762,35 @@ discard block |
||
762 | 762 | if ($error != '') return $error; |
763 | 763 | } |
764 | 764 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | - try { |
|
766 | - $sth = $Connection->db->prepare($query); |
|
767 | - $sth->execute(); |
|
768 | - } catch(PDOException $e) { |
|
769 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | - } |
|
765 | + try { |
|
766 | + $sth = $Connection->db->prepare($query); |
|
767 | + $sth->execute(); |
|
768 | + } catch(PDOException $e) { |
|
769 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | + } |
|
771 | 771 | return $error; |
772 | 772 | } |
773 | 773 | |
774 | 774 | private static function update_from_22() { |
775 | 775 | global $globalDBdriver; |
776 | - $Connection = new Connection(); |
|
776 | + $Connection = new Connection(); |
|
777 | 777 | $error = ''; |
778 | 778 | // Add table stats polar |
779 | - if (!$Connection->tableExists('stats_source')) { |
|
779 | + if (!$Connection->tableExists('stats_source')) { |
|
780 | 780 | if ($globalDBdriver == 'mysql') { |
781 | - $error .= create_db::import_file('../db/stats_source.sql'); |
|
781 | + $error .= create_db::import_file('../db/stats_source.sql'); |
|
782 | 782 | } else { |
783 | 783 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 784 | } |
785 | 785 | if ($error != '') return $error; |
786 | 786 | } |
787 | 787 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | - try { |
|
789 | - $sth = $Connection->db->prepare($query); |
|
790 | - $sth->execute(); |
|
791 | - } catch(PDOException $e) { |
|
792 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | - } |
|
788 | + try { |
|
789 | + $sth = $Connection->db->prepare($query); |
|
790 | + $sth->execute(); |
|
791 | + } catch(PDOException $e) { |
|
792 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | + } |
|
794 | 794 | return $error; |
795 | 795 | } |
796 | 796 | |
@@ -821,14 +821,14 @@ discard block |
||
821 | 821 | } |
822 | 822 | if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
824 | - $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
824 | + $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
825 | 825 | try { |
826 | 826 | $sth = $Connection->db->prepare($query); |
827 | 827 | $sth->execute(); |
828 | 828 | } catch(PDOException $e) { |
829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
830 | - } |
|
831 | - } |
|
830 | + } |
|
831 | + } |
|
832 | 832 | |
833 | 833 | $query = "UPDATE config SET value = '24' WHERE name = 'schema_version'"; |
834 | 834 | try { |
@@ -1176,7 +1176,7 @@ discard block |
||
1176 | 1176 | } catch(PDOException $e) { |
1177 | 1177 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; |
1178 | 1178 | } |
1179 | - } |
|
1179 | + } |
|
1180 | 1180 | if (!$Connection->checkColumnName('aircraft','mfr')) { |
1181 | 1181 | // Add mfr to aircraft |
1182 | 1182 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | } catch(PDOException $e) { |
1251 | 1251 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; |
1252 | 1252 | } |
1253 | - } |
|
1253 | + } |
|
1254 | 1254 | if (!$Connection->indexExists('accidents','registration_idx')) { |
1255 | 1255 | // Add index key |
1256 | 1256 | $query = "create index registration_idx on accidents (registration)"; |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | } catch(PDOException $e) { |
1261 | 1261 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; |
1262 | 1262 | } |
1263 | - } |
|
1263 | + } |
|
1264 | 1264 | if (!$Connection->indexExists('accidents','rdts')) { |
1265 | 1265 | // Add index key |
1266 | 1266 | $query = "create index rdts on accidents (registration,date,type,source)"; |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | } catch(PDOException $e) { |
1271 | 1271 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; |
1272 | 1272 | } |
1273 | - } |
|
1273 | + } |
|
1274 | 1274 | |
1275 | 1275 | $query = "UPDATE config SET value = '31' WHERE name = 'schema_version'"; |
1276 | 1276 | try { |
@@ -1384,161 +1384,161 @@ discard block |
||
1384 | 1384 | } |
1385 | 1385 | |
1386 | 1386 | |
1387 | - public static function check_version($update = false) { |
|
1388 | - global $globalDBname; |
|
1389 | - $version = 0; |
|
1390 | - $Connection = new Connection(); |
|
1391 | - if ($Connection->tableExists('aircraft')) { |
|
1392 | - if (!$Connection->tableExists('config')) { |
|
1393 | - $version = '1'; |
|
1394 | - if ($update) return self::update_from_1(); |
|
1395 | - else return $version; |
|
1387 | + public static function check_version($update = false) { |
|
1388 | + global $globalDBname; |
|
1389 | + $version = 0; |
|
1390 | + $Connection = new Connection(); |
|
1391 | + if ($Connection->tableExists('aircraft')) { |
|
1392 | + if (!$Connection->tableExists('config')) { |
|
1393 | + $version = '1'; |
|
1394 | + if ($update) return self::update_from_1(); |
|
1395 | + else return $version; |
|
1396 | 1396 | } else { |
1397 | - $Connection = new Connection(); |
|
1398 | - $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1399 | - try { |
|
1400 | - $sth = $Connection->db->prepare($query); |
|
1401 | - $sth->execute(); |
|
1402 | - } catch(PDOException $e) { |
|
1397 | + $Connection = new Connection(); |
|
1398 | + $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1399 | + try { |
|
1400 | + $sth = $Connection->db->prepare($query); |
|
1401 | + $sth->execute(); |
|
1402 | + } catch(PDOException $e) { |
|
1403 | 1403 | return "error : ".$e->getMessage()."\n"; |
1404 | - } |
|
1405 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1406 | - if ($update) { |
|
1407 | - if ($result['value'] == '2') { |
|
1408 | - $error = self::update_from_2(); |
|
1409 | - if ($error != '') return $error; |
|
1410 | - else return self::check_version(true); |
|
1411 | - } elseif ($result['value'] == '3') { |
|
1412 | - $error = self::update_from_3(); |
|
1413 | - if ($error != '') return $error; |
|
1414 | - else return self::check_version(true); |
|
1415 | - } elseif ($result['value'] == '4') { |
|
1416 | - $error = self::update_from_4(); |
|
1417 | - if ($error != '') return $error; |
|
1418 | - else return self::check_version(true); |
|
1419 | - } elseif ($result['value'] == '5') { |
|
1420 | - $error = self::update_from_5(); |
|
1421 | - if ($error != '') return $error; |
|
1422 | - else return self::check_version(true); |
|
1423 | - } elseif ($result['value'] == '6') { |
|
1424 | - $error = self::update_from_6(); |
|
1425 | - if ($error != '') return $error; |
|
1426 | - else return self::check_version(true); |
|
1427 | - } elseif ($result['value'] == '7') { |
|
1428 | - $error = self::update_from_7(); |
|
1429 | - if ($error != '') return $error; |
|
1430 | - else return self::check_version(true); |
|
1431 | - } elseif ($result['value'] == '8') { |
|
1432 | - $error = self::update_from_8(); |
|
1433 | - if ($error != '') return $error; |
|
1434 | - else return self::check_version(true); |
|
1435 | - } elseif ($result['value'] == '9') { |
|
1436 | - $error = self::update_from_9(); |
|
1437 | - if ($error != '') return $error; |
|
1438 | - else return self::check_version(true); |
|
1439 | - } elseif ($result['value'] == '10') { |
|
1440 | - $error = self::update_from_10(); |
|
1441 | - if ($error != '') return $error; |
|
1442 | - else return self::check_version(true); |
|
1443 | - } elseif ($result['value'] == '11') { |
|
1444 | - $error = self::update_from_11(); |
|
1445 | - if ($error != '') return $error; |
|
1446 | - else return self::check_version(true); |
|
1447 | - } elseif ($result['value'] == '12') { |
|
1448 | - $error = self::update_from_12(); |
|
1449 | - if ($error != '') return $error; |
|
1450 | - else return self::check_version(true); |
|
1451 | - } elseif ($result['value'] == '13') { |
|
1452 | - $error = self::update_from_13(); |
|
1453 | - if ($error != '') return $error; |
|
1454 | - else return self::check_version(true); |
|
1455 | - } elseif ($result['value'] == '14') { |
|
1456 | - $error = self::update_from_14(); |
|
1457 | - if ($error != '') return $error; |
|
1458 | - else return self::check_version(true); |
|
1459 | - } elseif ($result['value'] == '15') { |
|
1460 | - $error = self::update_from_15(); |
|
1461 | - if ($error != '') return $error; |
|
1462 | - else return self::check_version(true); |
|
1463 | - } elseif ($result['value'] == '16') { |
|
1464 | - $error = self::update_from_16(); |
|
1465 | - if ($error != '') return $error; |
|
1466 | - else return self::check_version(true); |
|
1467 | - } elseif ($result['value'] == '17') { |
|
1468 | - $error = self::update_from_17(); |
|
1469 | - if ($error != '') return $error; |
|
1470 | - else return self::check_version(true); |
|
1471 | - } elseif ($result['value'] == '18') { |
|
1472 | - $error = self::update_from_18(); |
|
1473 | - if ($error != '') return $error; |
|
1474 | - else return self::check_version(true); |
|
1475 | - } elseif ($result['value'] == '19') { |
|
1476 | - $error = self::update_from_19(); |
|
1477 | - if ($error != '') return $error; |
|
1478 | - else return self::check_version(true); |
|
1479 | - } elseif ($result['value'] == '20') { |
|
1480 | - $error = self::update_from_20(); |
|
1481 | - if ($error != '') return $error; |
|
1482 | - else return self::check_version(true); |
|
1483 | - } elseif ($result['value'] == '21') { |
|
1484 | - $error = self::update_from_21(); |
|
1485 | - if ($error != '') return $error; |
|
1486 | - else return self::check_version(true); |
|
1487 | - } elseif ($result['value'] == '22') { |
|
1488 | - $error = self::update_from_22(); |
|
1489 | - if ($error != '') return $error; |
|
1490 | - else return self::check_version(true); |
|
1491 | - } elseif ($result['value'] == '23') { |
|
1492 | - $error = self::update_from_23(); |
|
1493 | - if ($error != '') return $error; |
|
1494 | - else return self::check_version(true); |
|
1495 | - } elseif ($result['value'] == '24') { |
|
1496 | - $error = self::update_from_24(); |
|
1497 | - if ($error != '') return $error; |
|
1498 | - else return self::check_version(true); |
|
1499 | - } elseif ($result['value'] == '25') { |
|
1500 | - $error = self::update_from_25(); |
|
1501 | - if ($error != '') return $error; |
|
1502 | - else return self::check_version(true); |
|
1503 | - } elseif ($result['value'] == '26') { |
|
1504 | - $error = self::update_from_26(); |
|
1505 | - if ($error != '') return $error; |
|
1506 | - else return self::check_version(true); |
|
1507 | - } elseif ($result['value'] == '27') { |
|
1508 | - $error = self::update_from_27(); |
|
1509 | - if ($error != '') return $error; |
|
1510 | - else return self::check_version(true); |
|
1511 | - } elseif ($result['value'] == '28') { |
|
1512 | - $error = self::update_from_28(); |
|
1513 | - if ($error != '') return $error; |
|
1514 | - else return self::check_version(true); |
|
1515 | - } elseif ($result['value'] == '29') { |
|
1516 | - $error = self::update_from_29(); |
|
1517 | - if ($error != '') return $error; |
|
1518 | - else return self::check_version(true); |
|
1519 | - } elseif ($result['value'] == '30') { |
|
1520 | - $error = self::update_from_30(); |
|
1521 | - if ($error != '') return $error; |
|
1522 | - else return self::check_version(true); |
|
1523 | - } elseif ($result['value'] == '31') { |
|
1524 | - $error = self::update_from_31(); |
|
1525 | - if ($error != '') return $error; |
|
1526 | - else return self::check_version(true); |
|
1527 | - } elseif ($result['value'] == '32') { |
|
1528 | - $error = self::update_from_32(); |
|
1529 | - if ($error != '') return $error; |
|
1530 | - else return self::check_version(true); |
|
1531 | - } elseif ($result['value'] == '33') { |
|
1532 | - $error = self::update_from_33(); |
|
1533 | - if ($error != '') return $error; |
|
1534 | - else return self::check_version(true); |
|
1535 | - } else return ''; |
|
1536 | - } |
|
1537 | - else return $result['value']; |
|
1404 | + } |
|
1405 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1406 | + if ($update) { |
|
1407 | + if ($result['value'] == '2') { |
|
1408 | + $error = self::update_from_2(); |
|
1409 | + if ($error != '') return $error; |
|
1410 | + else return self::check_version(true); |
|
1411 | + } elseif ($result['value'] == '3') { |
|
1412 | + $error = self::update_from_3(); |
|
1413 | + if ($error != '') return $error; |
|
1414 | + else return self::check_version(true); |
|
1415 | + } elseif ($result['value'] == '4') { |
|
1416 | + $error = self::update_from_4(); |
|
1417 | + if ($error != '') return $error; |
|
1418 | + else return self::check_version(true); |
|
1419 | + } elseif ($result['value'] == '5') { |
|
1420 | + $error = self::update_from_5(); |
|
1421 | + if ($error != '') return $error; |
|
1422 | + else return self::check_version(true); |
|
1423 | + } elseif ($result['value'] == '6') { |
|
1424 | + $error = self::update_from_6(); |
|
1425 | + if ($error != '') return $error; |
|
1426 | + else return self::check_version(true); |
|
1427 | + } elseif ($result['value'] == '7') { |
|
1428 | + $error = self::update_from_7(); |
|
1429 | + if ($error != '') return $error; |
|
1430 | + else return self::check_version(true); |
|
1431 | + } elseif ($result['value'] == '8') { |
|
1432 | + $error = self::update_from_8(); |
|
1433 | + if ($error != '') return $error; |
|
1434 | + else return self::check_version(true); |
|
1435 | + } elseif ($result['value'] == '9') { |
|
1436 | + $error = self::update_from_9(); |
|
1437 | + if ($error != '') return $error; |
|
1438 | + else return self::check_version(true); |
|
1439 | + } elseif ($result['value'] == '10') { |
|
1440 | + $error = self::update_from_10(); |
|
1441 | + if ($error != '') return $error; |
|
1442 | + else return self::check_version(true); |
|
1443 | + } elseif ($result['value'] == '11') { |
|
1444 | + $error = self::update_from_11(); |
|
1445 | + if ($error != '') return $error; |
|
1446 | + else return self::check_version(true); |
|
1447 | + } elseif ($result['value'] == '12') { |
|
1448 | + $error = self::update_from_12(); |
|
1449 | + if ($error != '') return $error; |
|
1450 | + else return self::check_version(true); |
|
1451 | + } elseif ($result['value'] == '13') { |
|
1452 | + $error = self::update_from_13(); |
|
1453 | + if ($error != '') return $error; |
|
1454 | + else return self::check_version(true); |
|
1455 | + } elseif ($result['value'] == '14') { |
|
1456 | + $error = self::update_from_14(); |
|
1457 | + if ($error != '') return $error; |
|
1458 | + else return self::check_version(true); |
|
1459 | + } elseif ($result['value'] == '15') { |
|
1460 | + $error = self::update_from_15(); |
|
1461 | + if ($error != '') return $error; |
|
1462 | + else return self::check_version(true); |
|
1463 | + } elseif ($result['value'] == '16') { |
|
1464 | + $error = self::update_from_16(); |
|
1465 | + if ($error != '') return $error; |
|
1466 | + else return self::check_version(true); |
|
1467 | + } elseif ($result['value'] == '17') { |
|
1468 | + $error = self::update_from_17(); |
|
1469 | + if ($error != '') return $error; |
|
1470 | + else return self::check_version(true); |
|
1471 | + } elseif ($result['value'] == '18') { |
|
1472 | + $error = self::update_from_18(); |
|
1473 | + if ($error != '') return $error; |
|
1474 | + else return self::check_version(true); |
|
1475 | + } elseif ($result['value'] == '19') { |
|
1476 | + $error = self::update_from_19(); |
|
1477 | + if ($error != '') return $error; |
|
1478 | + else return self::check_version(true); |
|
1479 | + } elseif ($result['value'] == '20') { |
|
1480 | + $error = self::update_from_20(); |
|
1481 | + if ($error != '') return $error; |
|
1482 | + else return self::check_version(true); |
|
1483 | + } elseif ($result['value'] == '21') { |
|
1484 | + $error = self::update_from_21(); |
|
1485 | + if ($error != '') return $error; |
|
1486 | + else return self::check_version(true); |
|
1487 | + } elseif ($result['value'] == '22') { |
|
1488 | + $error = self::update_from_22(); |
|
1489 | + if ($error != '') return $error; |
|
1490 | + else return self::check_version(true); |
|
1491 | + } elseif ($result['value'] == '23') { |
|
1492 | + $error = self::update_from_23(); |
|
1493 | + if ($error != '') return $error; |
|
1494 | + else return self::check_version(true); |
|
1495 | + } elseif ($result['value'] == '24') { |
|
1496 | + $error = self::update_from_24(); |
|
1497 | + if ($error != '') return $error; |
|
1498 | + else return self::check_version(true); |
|
1499 | + } elseif ($result['value'] == '25') { |
|
1500 | + $error = self::update_from_25(); |
|
1501 | + if ($error != '') return $error; |
|
1502 | + else return self::check_version(true); |
|
1503 | + } elseif ($result['value'] == '26') { |
|
1504 | + $error = self::update_from_26(); |
|
1505 | + if ($error != '') return $error; |
|
1506 | + else return self::check_version(true); |
|
1507 | + } elseif ($result['value'] == '27') { |
|
1508 | + $error = self::update_from_27(); |
|
1509 | + if ($error != '') return $error; |
|
1510 | + else return self::check_version(true); |
|
1511 | + } elseif ($result['value'] == '28') { |
|
1512 | + $error = self::update_from_28(); |
|
1513 | + if ($error != '') return $error; |
|
1514 | + else return self::check_version(true); |
|
1515 | + } elseif ($result['value'] == '29') { |
|
1516 | + $error = self::update_from_29(); |
|
1517 | + if ($error != '') return $error; |
|
1518 | + else return self::check_version(true); |
|
1519 | + } elseif ($result['value'] == '30') { |
|
1520 | + $error = self::update_from_30(); |
|
1521 | + if ($error != '') return $error; |
|
1522 | + else return self::check_version(true); |
|
1523 | + } elseif ($result['value'] == '31') { |
|
1524 | + $error = self::update_from_31(); |
|
1525 | + if ($error != '') return $error; |
|
1526 | + else return self::check_version(true); |
|
1527 | + } elseif ($result['value'] == '32') { |
|
1528 | + $error = self::update_from_32(); |
|
1529 | + if ($error != '') return $error; |
|
1530 | + else return self::check_version(true); |
|
1531 | + } elseif ($result['value'] == '33') { |
|
1532 | + $error = self::update_from_33(); |
|
1533 | + if ($error != '') return $error; |
|
1534 | + else return self::check_version(true); |
|
1535 | + } else return ''; |
|
1536 | + } |
|
1537 | + else return $result['value']; |
|
1538 | 1538 | } |
1539 | 1539 | |
1540 | - } else return $version; |
|
1541 | - } |
|
1540 | + } else return $version; |
|
1541 | + } |
|
1542 | 1542 | |
1543 | 1543 | } |
1544 | 1544 | //echo update_schema::check_version(); |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | try { |
15 | 15 | $sth = $Connection->db->prepare($query); |
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch (PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | 19 | } |
20 | 20 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | try { |
51 | 51 | $sth = $Connection->db->prepare($query); |
52 | 52 | $sth->execute(); |
53 | - } catch(PDOException $e) { |
|
53 | + } catch (PDOException $e) { |
|
54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
55 | 55 | } |
56 | 56 | // Copy schedules data to routes table |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $sth = $Connection->db->prepare($query); |
62 | 62 | $sth->execute(); |
63 | - } catch(PDOException $e) { |
|
63 | + } catch (PDOException $e) { |
|
64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; |
65 | 65 | } |
66 | 66 | // Add source column |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | try { |
69 | 69 | $sth = $Connection->db->prepare($query); |
70 | 70 | $sth->execute(); |
71 | - } catch(PDOException $e) { |
|
71 | + } catch (PDOException $e) { |
|
72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
73 | 73 | } |
74 | 74 | // Delete unused column |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | try { |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
81 | 81 | } |
82 | 82 | // Add ModeS column |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | try { |
85 | 85 | $sth = $Connection->db->prepare($query); |
86 | 86 | $sth->execute(); |
87 | - } catch(PDOException $e) { |
|
87 | + } catch (PDOException $e) { |
|
88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
89 | 89 | } |
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | 91 | try { |
92 | 92 | $sth = $Connection->db->prepare($query); |
93 | 93 | $sth->execute(); |
94 | - } catch(PDOException $e) { |
|
94 | + } catch (PDOException $e) { |
|
95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
96 | 96 | } |
97 | 97 | // Add auto_increment for aircraft_modes |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | try { |
100 | 100 | $sth = $Connection->db->prepare($query); |
101 | 101 | $sth->execute(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
104 | 104 | } |
105 | 105 | $error = ''; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | try { |
111 | 111 | $sth = $Connection->db->prepare($query); |
112 | 112 | $sth->execute(); |
113 | - } catch(PDOException $e) { |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
115 | 115 | } |
116 | 116 | return $error; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | try { |
124 | 124 | $sth = $Connection->db->prepare($query); |
125 | 125 | $sth->execute(); |
126 | - } catch(PDOException $e) { |
|
126 | + } catch (PDOException $e) { |
|
127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
128 | 128 | } |
129 | 129 | $error = ''; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | try { |
135 | 135 | $sth = $Connection->db->prepare($query); |
136 | 136 | $sth->execute(); |
137 | - } catch(PDOException $e) { |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
139 | 139 | } |
140 | 140 | return $error; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | try { |
148 | 148 | $sth = $Connection->db->prepare($query); |
149 | 149 | $sth->execute(); |
150 | - } catch(PDOException $e) { |
|
150 | + } catch (PDOException $e) { |
|
151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
152 | 152 | } |
153 | 153 | // Add image_source_website column to spotter_image |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | try { |
156 | 156 | $sth = $Connection->db->prepare($query); |
157 | 157 | $sth->execute(); |
158 | - } catch(PDOException $e) { |
|
158 | + } catch (PDOException $e) { |
|
159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
160 | 160 | } |
161 | 161 | $error = ''; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $Connection->db->prepare($query); |
166 | 166 | $sth->execute(); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
169 | 169 | } |
170 | 170 | return $error; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | try { |
183 | 183 | $sth = $Connection->db->prepare($query); |
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch (PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | 187 | } |
188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $Connection->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
201 | 201 | } |
202 | 202 | // Add aircraft_shadow column to aircraft |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | try { |
205 | 205 | $sth = $Connection->db->prepare($query); |
206 | 206 | $sth->execute(); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
209 | 209 | } |
210 | 210 | // Add aircraft_shadow column to spotter_live |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $Connection->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
217 | 217 | } |
218 | 218 | $error = ''; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | try { |
226 | 226 | $sth = $Connection->db->prepare($query); |
227 | 227 | $sth->execute(); |
228 | - } catch(PDOException $e) { |
|
228 | + } catch (PDOException $e) { |
|
229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
230 | 230 | } |
231 | 231 | return $error; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | 235 | $Connection = new Connection(); |
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
236 | + if (!$Connection->indexExists('spotter_output', 'flightaware_id')) { |
|
237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | 255 | } |
256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
270 | 270 | } |
271 | 271 | return $error; |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | 276 | $Connection = new Connection(); |
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | 279 | try { |
280 | 280 | $sth = $Connection->db->prepare($query); |
281 | 281 | $sth->execute(); |
282 | - } catch(PDOException $e) { |
|
282 | + } catch (PDOException $e) { |
|
283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
284 | 284 | } |
285 | 285 | if ($globalDBdriver == 'mysql') { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | try { |
288 | 288 | $sth = $Connection->db->prepare($query); |
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch (PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | 292 | } |
293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | 301 | } else { |
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | 303 | } |
304 | 304 | } else { |
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | 306 | } |
307 | 307 | try { |
308 | 308 | $sth = $Connection->db->prepare($query); |
309 | 309 | $sth->execute(); |
310 | - } catch(PDOException $e) { |
|
310 | + } catch (PDOException $e) { |
|
311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
312 | 312 | } |
313 | 313 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
325 | 325 | } |
326 | 326 | return $error; |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | try { |
340 | 340 | $sth = $Connection->db->prepare($query); |
341 | 341 | $sth->execute(); |
342 | - } catch(PDOException $e) { |
|
342 | + } catch (PDOException $e) { |
|
343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; |
344 | 344 | } |
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | 346 | try { |
347 | 347 | $sth = $Connection->db->prepare($query); |
348 | 348 | $sth->execute(); |
349 | - } catch(PDOException $e) { |
|
349 | + } catch (PDOException $e) { |
|
350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
351 | 351 | } |
352 | 352 | return $error; |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | 356 | $Connection = new Connection(); |
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | 359 | try { |
360 | 360 | $sth = $Connection->db->prepare($query); |
361 | 361 | $sth->execute(); |
362 | - } catch(PDOException $e) { |
|
362 | + } catch (PDOException $e) { |
|
363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
364 | 364 | } |
365 | 365 | $error = ''; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $sth = $Connection->db->prepare($query); |
373 | 373 | $sth->execute(); |
374 | - } catch(PDOException $e) { |
|
374 | + } catch (PDOException $e) { |
|
375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
376 | 376 | } |
377 | 377 | return $error; |
@@ -379,11 +379,11 @@ discard block |
||
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | 381 | $Connection = new Connection(); |
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
382 | + $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | 383 | try { |
384 | 384 | $sth = $Connection->db->prepare($query); |
385 | 385 | $sth->execute(); |
386 | - } catch(PDOException $e) { |
|
386 | + } catch (PDOException $e) { |
|
387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
388 | 388 | } |
389 | 389 | $error = ''; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | try { |
402 | 402 | $sth = $Connection->db->prepare($query); |
403 | 403 | $sth->execute(); |
404 | - } catch(PDOException $e) { |
|
404 | + } catch (PDOException $e) { |
|
405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
406 | 406 | } |
407 | 407 | return $error; |
@@ -410,18 +410,18 @@ discard block |
||
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | 412 | $Connection = new Connection(); |
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
413 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | 414 | try { |
415 | 415 | $sth = $Connection->db->prepare($query); |
416 | 416 | $sth->execute(); |
417 | - } catch(PDOException $e) { |
|
417 | + } catch (PDOException $e) { |
|
418 | 418 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
419 | 419 | } |
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
420 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | 421 | try { |
422 | 422 | $sth = $Connection->db->prepare($query); |
423 | 423 | $sth->execute(); |
424 | - } catch(PDOException $e) { |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
426 | 426 | } |
427 | 427 | if ($globalDBdriver == 'mysql') { |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | try { |
430 | 430 | $sth = $Connection->db->prepare($query); |
431 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
432 | + } catch (PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | 434 | } |
435 | 435 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -441,15 +441,15 @@ discard block |
||
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | 443 | } else { |
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
444 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | 445 | } |
446 | 446 | } else { |
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
447 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | 448 | } |
449 | 449 | try { |
450 | 450 | $sth = $Connection->db->prepare($query); |
451 | 451 | $sth->execute(); |
452 | - } catch(PDOException $e) { |
|
452 | + } catch (PDOException $e) { |
|
453 | 453 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
454 | 454 | } |
455 | 455 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | try { |
460 | 460 | $sth = $Connection->db->prepare($query); |
461 | 461 | $sth->execute(); |
462 | - } catch(PDOException $e) { |
|
462 | + } catch (PDOException $e) { |
|
463 | 463 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
464 | 464 | } |
465 | 465 | return $error; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $Connection->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
492 | 492 | } |
493 | 493 | return $error; |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | 497 | $Connection = new Connection(); |
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) { |
|
499 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch (PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | 505 | } |
506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | try { |
510 | 510 | $sth = $Connection->db->prepare($query); |
511 | 511 | $sth->execute(); |
512 | - } catch(PDOException $e) { |
|
512 | + } catch (PDOException $e) { |
|
513 | 513 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
514 | 514 | } |
515 | 515 | return $error; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $Connection->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
532 | 532 | } |
533 | 533 | return $error; |
@@ -538,11 +538,11 @@ discard block |
||
538 | 538 | $Connection = new Connection(); |
539 | 539 | $error = ''; |
540 | 540 | // Add tables |
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
541 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | 542 | try { |
543 | 543 | $sth = $Connection->db->prepare($query); |
544 | 544 | $sth->execute(); |
545 | - } catch(PDOException $e) { |
|
545 | + } catch (PDOException $e) { |
|
546 | 546 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 547 | } |
548 | 548 | if ($error != '') return $error; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | try { |
551 | 551 | $sth = $Connection->db->prepare($query); |
552 | 552 | $sth->execute(); |
553 | - } catch(PDOException $e) { |
|
553 | + } catch (PDOException $e) { |
|
554 | 554 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
555 | 555 | } |
556 | 556 | return $error; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | try { |
572 | 572 | $sth = $Connection->db->prepare($query); |
573 | 573 | $sth->execute(); |
574 | - } catch(PDOException $e) { |
|
574 | + } catch (PDOException $e) { |
|
575 | 575 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
576 | 576 | } |
577 | 577 | return $error; |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | try { |
590 | 590 | $sth = $Connection->db->prepare($query); |
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
594 | 594 | } |
595 | 595 | return $error; |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | $Connection = new Connection(); |
599 | 599 | $error = ''; |
600 | 600 | // Modify stats_airport table |
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
601 | + if (!$Connection->checkColumnName('stats_airport', 'airport_name')) { |
|
602 | 602 | $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
603 | 603 | try { |
604 | 604 | $sth = $Connection->db->prepare($query); |
605 | 605 | $sth->execute(); |
606 | - } catch(PDOException $e) { |
|
606 | + } catch (PDOException $e) { |
|
607 | 607 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 608 | } |
609 | 609 | } |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | try { |
613 | 613 | $sth = $Connection->db->prepare($query); |
614 | 614 | $sth->execute(); |
615 | - } catch(PDOException $e) { |
|
615 | + } catch (PDOException $e) { |
|
616 | 616 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
617 | 617 | } |
618 | 618 | return $error; |
@@ -629,73 +629,73 @@ discard block |
||
629 | 629 | try { |
630 | 630 | $sth = $Connection->db->prepare($query); |
631 | 631 | $sth->execute(); |
632 | - } catch(PDOException $e) { |
|
632 | + } catch (PDOException $e) { |
|
633 | 633 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
634 | 634 | } |
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | 636 | try { |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
641 | 641 | } |
642 | - if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
|
642 | + if (!$Connection->checkColumnName('spotter_archive', 'over_country')) { |
|
643 | 643 | // Add column over_country |
644 | 644 | $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
645 | 645 | try { |
646 | 646 | $sth = $Connection->db->prepare($query); |
647 | 647 | $sth->execute(); |
648 | - } catch(PDOException $e) { |
|
648 | + } catch (PDOException $e) { |
|
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
650 | 650 | } |
651 | 651 | } |
652 | - if (!$Connection->checkColumnName('spotter_live','over_country')) { |
|
652 | + if (!$Connection->checkColumnName('spotter_live', 'over_country')) { |
|
653 | 653 | // Add column over_country |
654 | 654 | $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
655 | 655 | try { |
656 | 656 | $sth = $Connection->db->prepare($query); |
657 | 657 | $sth->execute(); |
658 | - } catch(PDOException $e) { |
|
658 | + } catch (PDOException $e) { |
|
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
660 | 660 | } |
661 | 661 | } |
662 | - if (!$Connection->checkColumnName('spotter_output','source_name')) { |
|
662 | + if (!$Connection->checkColumnName('spotter_output', 'source_name')) { |
|
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | 664 | $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | - } catch(PDOException $e) { |
|
668 | + } catch (PDOException $e) { |
|
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | 670 | } |
671 | 671 | } |
672 | - if (!$Connection->checkColumnName('spotter_live','source_name')) { |
|
672 | + if (!$Connection->checkColumnName('spotter_live', 'source_name')) { |
|
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | 674 | $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | - } catch(PDOException $e) { |
|
678 | + } catch (PDOException $e) { |
|
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | 680 | } |
681 | 681 | } |
682 | - if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
|
682 | + if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) { |
|
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | 684 | $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | - } catch(PDOException $e) { |
|
688 | + } catch (PDOException $e) { |
|
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | 690 | } |
691 | 691 | } |
692 | - if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
|
692 | + if (!$Connection->checkColumnName('spotter_archive', 'source_name')) { |
|
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | 694 | $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | - } catch(PDOException $e) { |
|
698 | + } catch (PDOException $e) { |
|
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 700 | } |
701 | 701 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | try { |
705 | 705 | $sth = $Connection->db->prepare($query); |
706 | 706 | $sth->execute(); |
707 | - } catch(PDOException $e) { |
|
707 | + } catch (PDOException $e) { |
|
708 | 708 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
709 | 709 | } |
710 | 710 | return $error; |
@@ -719,13 +719,13 @@ discard block |
||
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | - if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
|
722 | + if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) { |
|
723 | 723 | // Add column over_country |
724 | 724 | $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
725 | 725 | try { |
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | - } catch(PDOException $e) { |
|
728 | + } catch (PDOException $e) { |
|
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 730 | } |
731 | 731 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | try { |
742 | 742 | $sth = $Connection->db->prepare($query); |
743 | 743 | $sth->execute(); |
744 | - } catch(PDOException $e) { |
|
744 | + } catch (PDOException $e) { |
|
745 | 745 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
746 | 746 | } |
747 | 747 | return $error; |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | private static function update_from_21() { |
751 | 751 | $Connection = new Connection(); |
752 | 752 | $error = ''; |
753 | - if (!$Connection->checkColumnName('stats_airport','stats_type')) { |
|
753 | + if (!$Connection->checkColumnName('stats_airport', 'stats_type')) { |
|
754 | 754 | // Rename type to stats_type |
755 | 755 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
756 | 756 | try { |
757 | 757 | $sth = $Connection->db->prepare($query); |
758 | 758 | $sth->execute(); |
759 | - } catch(PDOException $e) { |
|
759 | + } catch (PDOException $e) { |
|
760 | 760 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 761 | } |
762 | 762 | if ($error != '') return $error; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | try { |
766 | 766 | $sth = $Connection->db->prepare($query); |
767 | 767 | $sth->execute(); |
768 | - } catch(PDOException $e) { |
|
768 | + } catch (PDOException $e) { |
|
769 | 769 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
770 | 770 | } |
771 | 771 | return $error; |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | try { |
789 | 789 | $sth = $Connection->db->prepare($query); |
790 | 790 | $sth->execute(); |
791 | - } catch(PDOException $e) { |
|
791 | + } catch (PDOException $e) { |
|
792 | 792 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
793 | 793 | } |
794 | 794 | return $error; |
@@ -815,17 +815,17 @@ discard block |
||
815 | 815 | try { |
816 | 816 | $sth = $Connection->db->prepare($query); |
817 | 817 | $sth->execute(); |
818 | - } catch(PDOException $e) { |
|
818 | + } catch (PDOException $e) { |
|
819 | 819 | return "error (create index on spotter_archive) : ".$e->getMessage()."\n"; |
820 | 820 | } |
821 | 821 | } |
822 | - if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
|
822 | + if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) { |
|
823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
824 | 824 | $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
825 | 825 | try { |
826 | 826 | $sth = $Connection->db->prepare($query); |
827 | 827 | $sth->execute(); |
828 | - } catch(PDOException $e) { |
|
828 | + } catch (PDOException $e) { |
|
829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
830 | 830 | } |
831 | 831 | } |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | try { |
835 | 835 | $sth = $Connection->db->prepare($query); |
836 | 836 | $sth->execute(); |
837 | - } catch(PDOException $e) { |
|
837 | + } catch (PDOException $e) { |
|
838 | 838 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
839 | 839 | } |
840 | 840 | return $error; |
@@ -850,23 +850,23 @@ discard block |
||
850 | 850 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 851 | } |
852 | 852 | if ($error != '') return 'Import airlines.sql : '.$error; |
853 | - if (!$Connection->checkColumnName('airlines','forsource')) { |
|
853 | + if (!$Connection->checkColumnName('airlines', 'forsource')) { |
|
854 | 854 | // Add forsource to airlines |
855 | 855 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
856 | 856 | try { |
857 | 857 | $sth = $Connection->db->prepare($query); |
858 | 858 | $sth->execute(); |
859 | - } catch(PDOException $e) { |
|
859 | + } catch (PDOException $e) { |
|
860 | 860 | return "error (add forsource column) : ".$e->getMessage()."\n"; |
861 | 861 | } |
862 | 862 | } |
863 | - if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) { |
|
863 | + if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) { |
|
864 | 864 | // Add forsource to airlines |
865 | 865 | $query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
866 | 866 | try { |
867 | 867 | $sth = $Connection->db->prepare($query); |
868 | 868 | $sth->execute(); |
869 | - } catch(PDOException $e) { |
|
869 | + } catch (PDOException $e) { |
|
870 | 870 | return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n"; |
871 | 871 | } |
872 | 872 | // Add unique key |
@@ -878,17 +878,17 @@ discard block |
||
878 | 878 | try { |
879 | 879 | $sth = $Connection->db->prepare($query); |
880 | 880 | $sth->execute(); |
881 | - } catch(PDOException $e) { |
|
881 | + } catch (PDOException $e) { |
|
882 | 882 | return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n"; |
883 | 883 | } |
884 | 884 | } |
885 | - if (!$Connection->checkColumnName('stats_airport','stats_airline')) { |
|
885 | + if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) { |
|
886 | 886 | // Add forsource to airlines |
887 | 887 | $query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
888 | 888 | try { |
889 | 889 | $sth = $Connection->db->prepare($query); |
890 | 890 | $sth->execute(); |
891 | - } catch(PDOException $e) { |
|
891 | + } catch (PDOException $e) { |
|
892 | 892 | return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n"; |
893 | 893 | } |
894 | 894 | // Add unique key |
@@ -900,17 +900,17 @@ discard block |
||
900 | 900 | try { |
901 | 901 | $sth = $Connection->db->prepare($query); |
902 | 902 | $sth->execute(); |
903 | - } catch(PDOException $e) { |
|
903 | + } catch (PDOException $e) { |
|
904 | 904 | return "error (add unique key in stats_airport) : ".$e->getMessage()."\n"; |
905 | 905 | } |
906 | 906 | } |
907 | - if (!$Connection->checkColumnName('stats_country','stats_airline')) { |
|
907 | + if (!$Connection->checkColumnName('stats_country', 'stats_airline')) { |
|
908 | 908 | // Add forsource to airlines |
909 | 909 | $query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
910 | 910 | try { |
911 | 911 | $sth = $Connection->db->prepare($query); |
912 | 912 | $sth->execute(); |
913 | - } catch(PDOException $e) { |
|
913 | + } catch (PDOException $e) { |
|
914 | 914 | return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n"; |
915 | 915 | } |
916 | 916 | // Add unique key |
@@ -922,36 +922,36 @@ discard block |
||
922 | 922 | try { |
923 | 923 | $sth = $Connection->db->prepare($query); |
924 | 924 | $sth->execute(); |
925 | - } catch(PDOException $e) { |
|
925 | + } catch (PDOException $e) { |
|
926 | 926 | return "error (add unique key in stats_airline) : ".$e->getMessage()."\n"; |
927 | 927 | } |
928 | 928 | } |
929 | - if (!$Connection->checkColumnName('stats_flight','stats_airline')) { |
|
929 | + if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) { |
|
930 | 930 | // Add forsource to airlines |
931 | 931 | $query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
932 | 932 | try { |
933 | 933 | $sth = $Connection->db->prepare($query); |
934 | 934 | $sth->execute(); |
935 | - } catch(PDOException $e) { |
|
935 | + } catch (PDOException $e) { |
|
936 | 936 | return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n"; |
937 | 937 | } |
938 | 938 | } |
939 | - if (!$Connection->checkColumnName('stats','stats_airline')) { |
|
939 | + if (!$Connection->checkColumnName('stats', 'stats_airline')) { |
|
940 | 940 | // Add forsource to airlines |
941 | 941 | $query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
942 | 942 | try { |
943 | 943 | $sth = $Connection->db->prepare($query); |
944 | 944 | $sth->execute(); |
945 | - } catch(PDOException $e) { |
|
945 | + } catch (PDOException $e) { |
|
946 | 946 | return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n"; |
947 | 947 | } |
948 | - if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) { |
|
948 | + if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) { |
|
949 | 949 | // Add unique key |
950 | 950 | $query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);"; |
951 | 951 | try { |
952 | 952 | $sth = $Connection->db->prepare($query); |
953 | 953 | $sth->execute(); |
954 | - } catch(PDOException $e) { |
|
954 | + } catch (PDOException $e) { |
|
955 | 955 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
956 | 956 | } |
957 | 957 | } else { |
@@ -964,18 +964,18 @@ discard block |
||
964 | 964 | try { |
965 | 965 | $sth = $Connection->db->prepare($query); |
966 | 966 | $sth->execute(); |
967 | - } catch(PDOException $e) { |
|
967 | + } catch (PDOException $e) { |
|
968 | 968 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
969 | 969 | } |
970 | 970 | } |
971 | 971 | } |
972 | - if (!$Connection->checkColumnName('stats_registration','stats_airline')) { |
|
972 | + if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) { |
|
973 | 973 | // Add forsource to airlines |
974 | 974 | $query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
975 | 975 | try { |
976 | 976 | $sth = $Connection->db->prepare($query); |
977 | 977 | $sth->execute(); |
978 | - } catch(PDOException $e) { |
|
978 | + } catch (PDOException $e) { |
|
979 | 979 | return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n"; |
980 | 980 | } |
981 | 981 | // Add unique key |
@@ -987,17 +987,17 @@ discard block |
||
987 | 987 | try { |
988 | 988 | $sth = $Connection->db->prepare($query); |
989 | 989 | $sth->execute(); |
990 | - } catch(PDOException $e) { |
|
990 | + } catch (PDOException $e) { |
|
991 | 991 | return "error (add unique key in stats_registration) : ".$e->getMessage()."\n"; |
992 | 992 | } |
993 | 993 | } |
994 | - if (!$Connection->checkColumnName('stats_callsign','filter_name')) { |
|
994 | + if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) { |
|
995 | 995 | // Add forsource to airlines |
996 | 996 | $query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
997 | 997 | try { |
998 | 998 | $sth = $Connection->db->prepare($query); |
999 | 999 | $sth->execute(); |
1000 | - } catch(PDOException $e) { |
|
1000 | + } catch (PDOException $e) { |
|
1001 | 1001 | return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n"; |
1002 | 1002 | } |
1003 | 1003 | // Add unique key |
@@ -1009,17 +1009,17 @@ discard block |
||
1009 | 1009 | try { |
1010 | 1010 | $sth = $Connection->db->prepare($query); |
1011 | 1011 | $sth->execute(); |
1012 | - } catch(PDOException $e) { |
|
1012 | + } catch (PDOException $e) { |
|
1013 | 1013 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1014 | 1014 | } |
1015 | 1015 | } |
1016 | - if (!$Connection->checkColumnName('stats_airline','filter_name')) { |
|
1016 | + if (!$Connection->checkColumnName('stats_airline', 'filter_name')) { |
|
1017 | 1017 | // Add forsource to airlines |
1018 | 1018 | $query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1019 | 1019 | try { |
1020 | 1020 | $sth = $Connection->db->prepare($query); |
1021 | 1021 | $sth->execute(); |
1022 | - } catch(PDOException $e) { |
|
1022 | + } catch (PDOException $e) { |
|
1023 | 1023 | return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n"; |
1024 | 1024 | } |
1025 | 1025 | // Add unique key |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | try { |
1032 | 1032 | $sth = $Connection->db->prepare($query); |
1033 | 1033 | $sth->execute(); |
1034 | - } catch(PDOException $e) { |
|
1034 | + } catch (PDOException $e) { |
|
1035 | 1035 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1036 | 1036 | } |
1037 | 1037 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | try { |
1041 | 1041 | $sth = $Connection->db->prepare($query); |
1042 | 1042 | $sth->execute(); |
1043 | - } catch(PDOException $e) { |
|
1043 | + } catch (PDOException $e) { |
|
1044 | 1044 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1045 | 1045 | } |
1046 | 1046 | return $error; |
@@ -1050,13 +1050,13 @@ discard block |
||
1050 | 1050 | global $globalDBdriver; |
1051 | 1051 | $Connection = new Connection(); |
1052 | 1052 | $error = ''; |
1053 | - if (!$Connection->checkColumnName('stats_owner','stats_airline')) { |
|
1053 | + if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) { |
|
1054 | 1054 | // Add forsource to airlines |
1055 | 1055 | $query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1056 | 1056 | try { |
1057 | 1057 | $sth = $Connection->db->prepare($query); |
1058 | 1058 | $sth->execute(); |
1059 | - } catch(PDOException $e) { |
|
1059 | + } catch (PDOException $e) { |
|
1060 | 1060 | return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n"; |
1061 | 1061 | } |
1062 | 1062 | // Add unique key |
@@ -1068,17 +1068,17 @@ discard block |
||
1068 | 1068 | try { |
1069 | 1069 | $sth = $Connection->db->prepare($query); |
1070 | 1070 | $sth->execute(); |
1071 | - } catch(PDOException $e) { |
|
1071 | + } catch (PDOException $e) { |
|
1072 | 1072 | return "error (add unique key in stats_owner) : ".$e->getMessage()."\n"; |
1073 | 1073 | } |
1074 | 1074 | } |
1075 | - if (!$Connection->checkColumnName('stats_pilot','stats_airline')) { |
|
1075 | + if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) { |
|
1076 | 1076 | // Add forsource to airlines |
1077 | 1077 | $query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1078 | 1078 | try { |
1079 | 1079 | $sth = $Connection->db->prepare($query); |
1080 | 1080 | $sth->execute(); |
1081 | - } catch(PDOException $e) { |
|
1081 | + } catch (PDOException $e) { |
|
1082 | 1082 | return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n"; |
1083 | 1083 | } |
1084 | 1084 | // Add unique key |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | try { |
1091 | 1091 | $sth = $Connection->db->prepare($query); |
1092 | 1092 | $sth->execute(); |
1093 | - } catch(PDOException $e) { |
|
1093 | + } catch (PDOException $e) { |
|
1094 | 1094 | return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1095 | 1095 | } |
1096 | 1096 | } |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | try { |
1099 | 1099 | $sth = $Connection->db->prepare($query); |
1100 | 1100 | $sth->execute(); |
1101 | - } catch(PDOException $e) { |
|
1101 | + } catch (PDOException $e) { |
|
1102 | 1102 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1103 | 1103 | } |
1104 | 1104 | return $error; |
@@ -1108,12 +1108,12 @@ discard block |
||
1108 | 1108 | global $globalDBdriver; |
1109 | 1109 | $Connection = new Connection(); |
1110 | 1110 | $error = ''; |
1111 | - if (!$Connection->checkColumnName('atc','format_source')) { |
|
1111 | + if (!$Connection->checkColumnName('atc', 'format_source')) { |
|
1112 | 1112 | $query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL"; |
1113 | 1113 | try { |
1114 | 1114 | $sth = $Connection->db->prepare($query); |
1115 | 1115 | $sth->execute(); |
1116 | - } catch(PDOException $e) { |
|
1116 | + } catch (PDOException $e) { |
|
1117 | 1117 | return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n"; |
1118 | 1118 | } |
1119 | 1119 | } |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | try { |
1122 | 1122 | $sth = $Connection->db->prepare($query); |
1123 | 1123 | $sth->execute(); |
1124 | - } catch(PDOException $e) { |
|
1124 | + } catch (PDOException $e) { |
|
1125 | 1125 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1126 | 1126 | } |
1127 | 1127 | return $error; |
@@ -1131,13 +1131,13 @@ discard block |
||
1131 | 1131 | global $globalDBdriver; |
1132 | 1132 | $Connection = new Connection(); |
1133 | 1133 | $error = ''; |
1134 | - if (!$Connection->checkColumnName('stats_pilot','format_source')) { |
|
1134 | + if (!$Connection->checkColumnName('stats_pilot', 'format_source')) { |
|
1135 | 1135 | // Add forsource to airlines |
1136 | 1136 | $query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''"; |
1137 | 1137 | try { |
1138 | 1138 | $sth = $Connection->db->prepare($query); |
1139 | 1139 | $sth->execute(); |
1140 | - } catch(PDOException $e) { |
|
1140 | + } catch (PDOException $e) { |
|
1141 | 1141 | return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n"; |
1142 | 1142 | } |
1143 | 1143 | // Add unique key |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | try { |
1150 | 1150 | $sth = $Connection->db->prepare($query); |
1151 | 1151 | $sth->execute(); |
1152 | - } catch(PDOException $e) { |
|
1152 | + } catch (PDOException $e) { |
|
1153 | 1153 | return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1154 | 1154 | } |
1155 | 1155 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | try { |
1158 | 1158 | $sth = $Connection->db->prepare($query); |
1159 | 1159 | $sth->execute(); |
1160 | - } catch(PDOException $e) { |
|
1160 | + } catch (PDOException $e) { |
|
1161 | 1161 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1162 | 1162 | } |
1163 | 1163 | return $error; |
@@ -1167,23 +1167,23 @@ discard block |
||
1167 | 1167 | global $globalDBdriver; |
1168 | 1168 | $Connection = new Connection(); |
1169 | 1169 | $error = ''; |
1170 | - if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) { |
|
1170 | + if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) { |
|
1171 | 1171 | // Add unique key |
1172 | 1172 | $query = "alter table spotter_live add index(latitude,longitude)"; |
1173 | 1173 | try { |
1174 | 1174 | $sth = $Connection->db->prepare($query); |
1175 | 1175 | $sth->execute(); |
1176 | - } catch(PDOException $e) { |
|
1176 | + } catch (PDOException $e) { |
|
1177 | 1177 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; |
1178 | 1178 | } |
1179 | 1179 | } |
1180 | - if (!$Connection->checkColumnName('aircraft','mfr')) { |
|
1180 | + if (!$Connection->checkColumnName('aircraft', 'mfr')) { |
|
1181 | 1181 | // Add mfr to aircraft |
1182 | 1182 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; |
1183 | 1183 | try { |
1184 | 1184 | $sth = $Connection->db->prepare($query); |
1185 | 1185 | $sth->execute(); |
1186 | - } catch(PDOException $e) { |
|
1186 | + } catch (PDOException $e) { |
|
1187 | 1187 | return "error (add mfr column in aircraft) : ".$e->getMessage()."\n"; |
1188 | 1188 | } |
1189 | 1189 | } |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | try { |
1200 | 1200 | $sth = $Connection->db->prepare($query); |
1201 | 1201 | $sth->execute(); |
1202 | - } catch(PDOException $e) { |
|
1202 | + } catch (PDOException $e) { |
|
1203 | 1203 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1204 | 1204 | } |
1205 | 1205 | return $error; |
@@ -1209,13 +1209,13 @@ discard block |
||
1209 | 1209 | global $globalDBdriver; |
1210 | 1210 | $Connection = new Connection(); |
1211 | 1211 | $error = ''; |
1212 | - if ($Connection->checkColumnName('aircraft','mfr')) { |
|
1212 | + if ($Connection->checkColumnName('aircraft', 'mfr')) { |
|
1213 | 1213 | // drop mfr to aircraft |
1214 | 1214 | $query = "ALTER TABLE aircraft DROP COLUMN mfr"; |
1215 | 1215 | try { |
1216 | 1216 | $sth = $Connection->db->prepare($query); |
1217 | 1217 | $sth->execute(); |
1218 | - } catch(PDOException $e) { |
|
1218 | + } catch (PDOException $e) { |
|
1219 | 1219 | return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n"; |
1220 | 1220 | } |
1221 | 1221 | } |
@@ -1231,7 +1231,7 @@ discard block |
||
1231 | 1231 | try { |
1232 | 1232 | $sth = $Connection->db->prepare($query); |
1233 | 1233 | $sth->execute(); |
1234 | - } catch(PDOException $e) { |
|
1234 | + } catch (PDOException $e) { |
|
1235 | 1235 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1236 | 1236 | } |
1237 | 1237 | return $error; |
@@ -1241,33 +1241,33 @@ discard block |
||
1241 | 1241 | global $globalDBdriver; |
1242 | 1242 | $Connection = new Connection(); |
1243 | 1243 | $error = ''; |
1244 | - if (!$Connection->indexExists('notam','ref_idx')) { |
|
1244 | + if (!$Connection->indexExists('notam', 'ref_idx')) { |
|
1245 | 1245 | // Add index key |
1246 | 1246 | $query = "create index ref_idx on notam (ref)"; |
1247 | 1247 | try { |
1248 | 1248 | $sth = $Connection->db->prepare($query); |
1249 | 1249 | $sth->execute(); |
1250 | - } catch(PDOException $e) { |
|
1250 | + } catch (PDOException $e) { |
|
1251 | 1251 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; |
1252 | 1252 | } |
1253 | 1253 | } |
1254 | - if (!$Connection->indexExists('accidents','registration_idx')) { |
|
1254 | + if (!$Connection->indexExists('accidents', 'registration_idx')) { |
|
1255 | 1255 | // Add index key |
1256 | 1256 | $query = "create index registration_idx on accidents (registration)"; |
1257 | 1257 | try { |
1258 | 1258 | $sth = $Connection->db->prepare($query); |
1259 | 1259 | $sth->execute(); |
1260 | - } catch(PDOException $e) { |
|
1260 | + } catch (PDOException $e) { |
|
1261 | 1261 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; |
1262 | 1262 | } |
1263 | 1263 | } |
1264 | - if (!$Connection->indexExists('accidents','rdts')) { |
|
1264 | + if (!$Connection->indexExists('accidents', 'rdts')) { |
|
1265 | 1265 | // Add index key |
1266 | 1266 | $query = "create index rdts on accidents (registration,date,type,source)"; |
1267 | 1267 | try { |
1268 | 1268 | $sth = $Connection->db->prepare($query); |
1269 | 1269 | $sth->execute(); |
1270 | - } catch(PDOException $e) { |
|
1270 | + } catch (PDOException $e) { |
|
1271 | 1271 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; |
1272 | 1272 | } |
1273 | 1273 | } |
@@ -1276,7 +1276,7 @@ discard block |
||
1276 | 1276 | try { |
1277 | 1277 | $sth = $Connection->db->prepare($query); |
1278 | 1278 | $sth->execute(); |
1279 | - } catch(PDOException $e) { |
|
1279 | + } catch (PDOException $e) { |
|
1280 | 1280 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1281 | 1281 | } |
1282 | 1282 | return $error; |
@@ -1286,23 +1286,23 @@ discard block |
||
1286 | 1286 | global $globalDBdriver; |
1287 | 1287 | $Connection = new Connection(); |
1288 | 1288 | $error = ''; |
1289 | - if (!$Connection->checkColumnName('accidents','airline_name')) { |
|
1289 | + if (!$Connection->checkColumnName('accidents', 'airline_name')) { |
|
1290 | 1290 | // Add airline_name to accidents |
1291 | 1291 | $query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL"; |
1292 | 1292 | try { |
1293 | 1293 | $sth = $Connection->db->prepare($query); |
1294 | 1294 | $sth->execute(); |
1295 | - } catch(PDOException $e) { |
|
1295 | + } catch (PDOException $e) { |
|
1296 | 1296 | return "error (add airline_name column in accidents) : ".$e->getMessage()."\n"; |
1297 | 1297 | } |
1298 | 1298 | } |
1299 | - if (!$Connection->checkColumnName('accidents','airline_icao')) { |
|
1299 | + if (!$Connection->checkColumnName('accidents', 'airline_icao')) { |
|
1300 | 1300 | // Add airline_icao to accidents |
1301 | 1301 | $query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL"; |
1302 | 1302 | try { |
1303 | 1303 | $sth = $Connection->db->prepare($query); |
1304 | 1304 | $sth->execute(); |
1305 | - } catch(PDOException $e) { |
|
1305 | + } catch (PDOException $e) { |
|
1306 | 1306 | return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n"; |
1307 | 1307 | } |
1308 | 1308 | } |
@@ -1310,7 +1310,7 @@ discard block |
||
1310 | 1310 | try { |
1311 | 1311 | $sth = $Connection->db->prepare($query); |
1312 | 1312 | $sth->execute(); |
1313 | - } catch(PDOException $e) { |
|
1313 | + } catch (PDOException $e) { |
|
1314 | 1314 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1315 | 1315 | } |
1316 | 1316 | return $error; |
@@ -1320,13 +1320,13 @@ discard block |
||
1320 | 1320 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1321 | 1321 | $Connection = new Connection(); |
1322 | 1322 | $error = ''; |
1323 | - if (!$Connection->checkColumnName('airlines','alliance')) { |
|
1323 | + if (!$Connection->checkColumnName('airlines', 'alliance')) { |
|
1324 | 1324 | // Add alliance to airlines |
1325 | 1325 | $query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL"; |
1326 | 1326 | try { |
1327 | 1327 | $sth = $Connection->db->prepare($query); |
1328 | 1328 | $sth->execute(); |
1329 | - } catch(PDOException $e) { |
|
1329 | + } catch (PDOException $e) { |
|
1330 | 1330 | return "error (add alliance column in airlines) : ".$e->getMessage()."\n"; |
1331 | 1331 | } |
1332 | 1332 | } |
@@ -1353,7 +1353,7 @@ discard block |
||
1353 | 1353 | try { |
1354 | 1354 | $sth = $Connection->db->prepare($query); |
1355 | 1355 | $sth->execute(); |
1356 | - } catch(PDOException $e) { |
|
1356 | + } catch (PDOException $e) { |
|
1357 | 1357 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1358 | 1358 | } |
1359 | 1359 | return $error; |
@@ -1363,13 +1363,13 @@ discard block |
||
1363 | 1363 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1364 | 1364 | $Connection = new Connection(); |
1365 | 1365 | $error = ''; |
1366 | - if (!$Connection->checkColumnName('airlines','ban_eu')) { |
|
1366 | + if (!$Connection->checkColumnName('airlines', 'ban_eu')) { |
|
1367 | 1367 | // Add ban_eu to airlines |
1368 | 1368 | $query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'"; |
1369 | 1369 | try { |
1370 | 1370 | $sth = $Connection->db->prepare($query); |
1371 | 1371 | $sth->execute(); |
1372 | - } catch(PDOException $e) { |
|
1372 | + } catch (PDOException $e) { |
|
1373 | 1373 | return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n"; |
1374 | 1374 | } |
1375 | 1375 | } |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | try { |
1378 | 1378 | $sth = $Connection->db->prepare($query); |
1379 | 1379 | $sth->execute(); |
1380 | - } catch(PDOException $e) { |
|
1380 | + } catch (PDOException $e) { |
|
1381 | 1381 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1382 | 1382 | } |
1383 | 1383 | return $error; |
@@ -1399,7 +1399,7 @@ discard block |
||
1399 | 1399 | try { |
1400 | 1400 | $sth = $Connection->db->prepare($query); |
1401 | 1401 | $sth->execute(); |
1402 | - } catch(PDOException $e) { |
|
1402 | + } catch (PDOException $e) { |
|
1403 | 1403 | return "error : ".$e->getMessage()."\n"; |
1404 | 1404 | } |
1405 | 1405 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -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 | } |