@@ -70,38 +70,38 @@ discard block |
||
70 | 70 | try { |
71 | 71 | //$Connection = new Connection(); |
72 | 72 | $sth = $Connection->db->prepare($query); |
73 | - $sth->execute(array(':source' => $database_file)); |
|
74 | - } catch(PDOException $e) { |
|
75 | - return "error : ".$e->getMessage(); |
|
76 | - } |
|
73 | + $sth->execute(array(':source' => $database_file)); |
|
74 | + } catch(PDOException $e) { |
|
75 | + return "error : ".$e->getMessage(); |
|
76 | + } |
|
77 | 77 | |
78 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
79 | - update_db::connect_sqlite($database_file); |
|
78 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
79 | + update_db::connect_sqlite($database_file); |
|
80 | 80 | //$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'; |
81 | 81 | $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"; |
82 | 82 | try { |
83 | - $sth = update_db::$db_sqlite->prepare($query); |
|
84 | - $sth->execute(); |
|
85 | - } catch(PDOException $e) { |
|
86 | - return "error : ".$e->getMessage(); |
|
87 | - } |
|
83 | + $sth = update_db::$db_sqlite->prepare($query); |
|
84 | + $sth->execute(); |
|
85 | + } catch(PDOException $e) { |
|
86 | + return "error : ".$e->getMessage(); |
|
87 | + } |
|
88 | 88 | //$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)'; |
89 | 89 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
90 | 90 | $Connection = new Connection(); |
91 | 91 | $sth_dest = $Connection->db->prepare($query_dest); |
92 | 92 | try { |
93 | 93 | if ($globalTransaction) $Connection->db->beginTransaction(); |
94 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
94 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
95 | 95 | //$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); |
96 | 96 | $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); |
97 | 97 | $sth_dest->execute($query_dest_values); |
98 | - } |
|
98 | + } |
|
99 | 99 | if ($globalTransaction) $Connection->db->commit(); |
100 | 100 | } catch(PDOException $e) { |
101 | 101 | if ($globalTransaction) $Connection->db->rollBack(); |
102 | 102 | return "error : ".$e->getMessage(); |
103 | 103 | } |
104 | - return ''; |
|
104 | + return ''; |
|
105 | 105 | } |
106 | 106 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
107 | 107 | global $globalTransaction; |
@@ -110,27 +110,27 @@ discard block |
||
110 | 110 | try { |
111 | 111 | $Connection = new Connection(); |
112 | 112 | $sth = $Connection->db->prepare($query); |
113 | - $sth->execute(array(':source' => $database_file)); |
|
114 | - } catch(PDOException $e) { |
|
115 | - return "error : ".$e->getMessage(); |
|
116 | - } |
|
113 | + $sth->execute(array(':source' => $database_file)); |
|
114 | + } catch(PDOException $e) { |
|
115 | + return "error : ".$e->getMessage(); |
|
116 | + } |
|
117 | 117 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
118 | 118 | try { |
119 | 119 | $Connection = new Connection(); |
120 | 120 | $sth = $Connection->db->prepare($query); |
121 | - $sth->execute(array(':source' => $database_file)); |
|
122 | - } catch(PDOException $e) { |
|
123 | - return "error : ".$e->getMessage(); |
|
124 | - } |
|
121 | + $sth->execute(array(':source' => $database_file)); |
|
122 | + } catch(PDOException $e) { |
|
123 | + return "error : ".$e->getMessage(); |
|
124 | + } |
|
125 | 125 | |
126 | - update_db::connect_sqlite($database_file); |
|
126 | + update_db::connect_sqlite($database_file); |
|
127 | 127 | $query = 'select * from Aircraft'; |
128 | 128 | try { |
129 | - $sth = update_db::$db_sqlite->prepare($query); |
|
130 | - $sth->execute(); |
|
131 | - } catch(PDOException $e) { |
|
132 | - return "error : ".$e->getMessage(); |
|
133 | - } |
|
129 | + $sth = update_db::$db_sqlite->prepare($query); |
|
130 | + $sth->execute(); |
|
131 | + } catch(PDOException $e) { |
|
132 | + return "error : ".$e->getMessage(); |
|
133 | + } |
|
134 | 134 | //$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)'; |
135 | 135 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
136 | 136 | |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
142 | 142 | try { |
143 | 143 | if ($globalTransaction) $Connection->db->beginTransaction(); |
144 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
144 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
145 | 145 | //$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']); |
146 | 146 | if ($values['UserString4'] == 'M') $type = 'military'; |
147 | 147 | else $type = null; |
148 | 148 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
149 | 149 | $sth_dest->execute($query_dest_values); |
150 | 150 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
151 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
152 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
151 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
152 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
153 | 153 | } |
154 | - } |
|
154 | + } |
|
155 | 155 | if ($globalTransaction) $Connection->db->commit(); |
156 | 156 | } catch(PDOException $e) { |
157 | 157 | return "error : ".$e->getMessage(); |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | try { |
162 | 162 | $Connection = new Connection(); |
163 | 163 | $sth = $Connection->db->prepare($query); |
164 | - $sth->execute(array(':source' => $database_file)); |
|
165 | - } catch(PDOException $e) { |
|
166 | - return "error : ".$e->getMessage(); |
|
167 | - } |
|
164 | + $sth->execute(array(':source' => $database_file)); |
|
165 | + } catch(PDOException $e) { |
|
166 | + return "error : ".$e->getMessage(); |
|
167 | + } |
|
168 | 168 | return ''; |
169 | 169 | } |
170 | 170 | |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | try { |
177 | 177 | $Connection = new Connection(); |
178 | 178 | $sth = $Connection->db->prepare($query); |
179 | - $sth->execute(array(':source' => $database_file)); |
|
180 | - } catch(PDOException $e) { |
|
181 | - return "error : ".$e->getMessage(); |
|
182 | - } |
|
179 | + $sth->execute(array(':source' => $database_file)); |
|
180 | + } catch(PDOException $e) { |
|
181 | + return "error : ".$e->getMessage(); |
|
182 | + } |
|
183 | 183 | |
184 | 184 | if ($fh = fopen($database_file,"r")) { |
185 | 185 | //$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)'; |
@@ -189,25 +189,25 @@ discard block |
||
189 | 189 | $sth_dest = $Connection->db->prepare($query_dest); |
190 | 190 | try { |
191 | 191 | if ($globalTransaction) $Connection->db->beginTransaction(); |
192 | - while (!feof($fh)) { |
|
193 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
192 | + while (!feof($fh)) { |
|
193 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
194 | 194 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
195 | - $values['ModeS'] = substr($line,0,6); |
|
196 | - $values['Registration'] = trim(substr($line,69,6)); |
|
197 | - $aircraft_name = trim(substr($line,48,6)); |
|
198 | - // Check if we can find ICAO, else set it to GLID |
|
199 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
200 | - $search_more = ''; |
|
201 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
202 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
203 | - $sth_search = $Connection->db->prepare($query_search); |
|
195 | + $values['ModeS'] = substr($line,0,6); |
|
196 | + $values['Registration'] = trim(substr($line,69,6)); |
|
197 | + $aircraft_name = trim(substr($line,48,6)); |
|
198 | + // Check if we can find ICAO, else set it to GLID |
|
199 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
200 | + $search_more = ''; |
|
201 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
202 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
203 | + $sth_search = $Connection->db->prepare($query_search); |
|
204 | 204 | try { |
205 | - $sth_search->execute(); |
|
206 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
207 | - //if (count($result) > 0) { |
|
208 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
209 | - $values['ICAOTypeCode'] = $result['icao']; |
|
210 | - } |
|
205 | + $sth_search->execute(); |
|
206 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
207 | + //if (count($result) > 0) { |
|
208 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
209 | + $values['ICAOTypeCode'] = $result['icao']; |
|
210 | + } |
|
211 | 211 | } catch(PDOException $e) { |
212 | 212 | return "error : ".$e->getMessage(); |
213 | 213 | } |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | try { |
231 | 231 | $Connection = new Connection(); |
232 | 232 | $sth = $Connection->db->prepare($query); |
233 | - $sth->execute(array(':source' => $database_file)); |
|
234 | - } catch(PDOException $e) { |
|
235 | - return "error : ".$e->getMessage(); |
|
236 | - } |
|
233 | + $sth->execute(array(':source' => $database_file)); |
|
234 | + } catch(PDOException $e) { |
|
235 | + return "error : ".$e->getMessage(); |
|
236 | + } |
|
237 | 237 | return ''; |
238 | 238 | } |
239 | 239 | |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | try { |
245 | 245 | $Connection = new Connection(); |
246 | 246 | $sth = $Connection->db->prepare($query); |
247 | - $sth->execute(array(':source' => $database_file)); |
|
248 | - } catch(PDOException $e) { |
|
249 | - return "error : ".$e->getMessage(); |
|
250 | - } |
|
247 | + $sth->execute(array(':source' => $database_file)); |
|
248 | + } catch(PDOException $e) { |
|
249 | + return "error : ".$e->getMessage(); |
|
250 | + } |
|
251 | 251 | |
252 | 252 | if ($fh = fopen($database_file,"r")) { |
253 | 253 | //$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)'; |
@@ -258,24 +258,24 @@ discard block |
||
258 | 258 | try { |
259 | 259 | if ($globalTransaction) $Connection->db->beginTransaction(); |
260 | 260 | $tmp = fgetcsv($fh,9999,',',"'"); |
261 | - while (!feof($fh)) { |
|
262 | - $line = fgetcsv($fh,9999,',',"'"); |
|
261 | + while (!feof($fh)) { |
|
262 | + $line = fgetcsv($fh,9999,',',"'"); |
|
263 | 263 | |
264 | 264 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
265 | 265 | //print_r($line); |
266 | - $values['ModeS'] = $line[1]; |
|
267 | - $values['Registration'] = $line[3]; |
|
268 | - $aircraft_name = $line[2]; |
|
269 | - // Check if we can find ICAO, else set it to GLID |
|
270 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
271 | - $search_more = ''; |
|
272 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
273 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
274 | - $sth_search = $Connection->db->prepare($query_search); |
|
266 | + $values['ModeS'] = $line[1]; |
|
267 | + $values['Registration'] = $line[3]; |
|
268 | + $aircraft_name = $line[2]; |
|
269 | + // Check if we can find ICAO, else set it to GLID |
|
270 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
271 | + $search_more = ''; |
|
272 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
273 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
274 | + $sth_search = $Connection->db->prepare($query_search); |
|
275 | 275 | try { |
276 | - $sth_search->execute(); |
|
277 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
278 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
276 | + $sth_search->execute(); |
|
277 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
278 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
279 | 279 | } catch(PDOException $e) { |
280 | 280 | return "error : ".$e->getMessage(); |
281 | 281 | } |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | try { |
299 | 299 | $Connection = new Connection(); |
300 | 300 | $sth = $Connection->db->prepare($query); |
301 | - $sth->execute(array(':source' => $database_file)); |
|
302 | - } catch(PDOException $e) { |
|
303 | - return "error : ".$e->getMessage(); |
|
304 | - } |
|
301 | + $sth->execute(array(':source' => $database_file)); |
|
302 | + } catch(PDOException $e) { |
|
303 | + return "error : ".$e->getMessage(); |
|
304 | + } |
|
305 | 305 | return ''; |
306 | 306 | } |
307 | 307 | |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | try { |
313 | 313 | $Connection = new Connection(); |
314 | 314 | $sth = $Connection->db->prepare($query); |
315 | - $sth->execute(array(':source' => $database_file)); |
|
316 | - } catch(PDOException $e) { |
|
317 | - return "error : ".$e->getMessage(); |
|
318 | - } |
|
315 | + $sth->execute(array(':source' => $database_file)); |
|
316 | + } catch(PDOException $e) { |
|
317 | + return "error : ".$e->getMessage(); |
|
318 | + } |
|
319 | 319 | |
320 | 320 | if ($fh = fopen($database_file,"r")) { |
321 | 321 | //$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)'; |
@@ -326,94 +326,94 @@ discard block |
||
326 | 326 | try { |
327 | 327 | if ($globalTransaction) $Connection->db->beginTransaction(); |
328 | 328 | $tmp = fgetcsv($fh,9999,',','"'); |
329 | - while (!feof($fh)) { |
|
330 | - $line = fgetcsv($fh,9999,',','"'); |
|
331 | - //print_r($line); |
|
332 | - if ($country == 'F') { |
|
333 | - $values['registration'] = $line[0]; |
|
334 | - $values['base'] = $line[4]; |
|
335 | - $values['owner'] = $line[5]; |
|
336 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
337 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
338 | - $values['cancel'] = $line[7]; |
|
329 | + while (!feof($fh)) { |
|
330 | + $line = fgetcsv($fh,9999,',','"'); |
|
331 | + //print_r($line); |
|
332 | + if ($country == 'F') { |
|
333 | + $values['registration'] = $line[0]; |
|
334 | + $values['base'] = $line[4]; |
|
335 | + $values['owner'] = $line[5]; |
|
336 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
337 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
338 | + $values['cancel'] = $line[7]; |
|
339 | 339 | } elseif ($country == 'EI') { |
340 | - // TODO : add modeS & reg to aircraft_modes |
|
341 | - $values['registration'] = $line[0]; |
|
342 | - $values['base'] = $line[3]; |
|
343 | - $values['owner'] = $line[2]; |
|
344 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
345 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
346 | - $values['cancel'] = ''; |
|
340 | + // TODO : add modeS & reg to aircraft_modes |
|
341 | + $values['registration'] = $line[0]; |
|
342 | + $values['base'] = $line[3]; |
|
343 | + $values['owner'] = $line[2]; |
|
344 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
345 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
346 | + $values['cancel'] = ''; |
|
347 | 347 | } elseif ($country == 'HB') { |
348 | - // TODO : add modeS & reg to aircraft_modes |
|
349 | - $values['registration'] = $line[0]; |
|
350 | - $values['base'] = null; |
|
351 | - $values['owner'] = $line[5]; |
|
352 | - $values['date_first_reg'] = null; |
|
353 | - $values['cancel'] = ''; |
|
348 | + // TODO : add modeS & reg to aircraft_modes |
|
349 | + $values['registration'] = $line[0]; |
|
350 | + $values['base'] = null; |
|
351 | + $values['owner'] = $line[5]; |
|
352 | + $values['date_first_reg'] = null; |
|
353 | + $values['cancel'] = ''; |
|
354 | 354 | } elseif ($country == 'OK') { |
355 | - // TODO : add modeS & reg to aircraft_modes |
|
356 | - $values['registration'] = $line[3]; |
|
357 | - $values['base'] = null; |
|
358 | - $values['owner'] = $line[5]; |
|
359 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
360 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
361 | - $values['cancel'] = ''; |
|
355 | + // TODO : add modeS & reg to aircraft_modes |
|
356 | + $values['registration'] = $line[3]; |
|
357 | + $values['base'] = null; |
|
358 | + $values['owner'] = $line[5]; |
|
359 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
360 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
361 | + $values['cancel'] = ''; |
|
362 | 362 | } elseif ($country == 'VH') { |
363 | - // TODO : add modeS & reg to aircraft_modes |
|
364 | - $values['registration'] = $line[0]; |
|
365 | - $values['base'] = null; |
|
366 | - $values['owner'] = $line[12]; |
|
367 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
368 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
369 | - |
|
370 | - $values['cancel'] = $line[39]; |
|
363 | + // TODO : add modeS & reg to aircraft_modes |
|
364 | + $values['registration'] = $line[0]; |
|
365 | + $values['base'] = null; |
|
366 | + $values['owner'] = $line[12]; |
|
367 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
368 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
369 | + |
|
370 | + $values['cancel'] = $line[39]; |
|
371 | 371 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
372 | - $values['registration'] = $line[0]; |
|
373 | - $values['base'] = null; |
|
374 | - $values['owner'] = $line[4]; |
|
375 | - $values['date_first_reg'] = null; |
|
376 | - $values['cancel'] = ''; |
|
372 | + $values['registration'] = $line[0]; |
|
373 | + $values['base'] = null; |
|
374 | + $values['owner'] = $line[4]; |
|
375 | + $values['date_first_reg'] = null; |
|
376 | + $values['cancel'] = ''; |
|
377 | 377 | } elseif ($country == 'CC') { |
378 | - $values['registration'] = $line[0]; |
|
379 | - $values['base'] = null; |
|
380 | - $values['owner'] = $line[6]; |
|
381 | - $values['date_first_reg'] = null; |
|
382 | - $values['cancel'] = ''; |
|
378 | + $values['registration'] = $line[0]; |
|
379 | + $values['base'] = null; |
|
380 | + $values['owner'] = $line[6]; |
|
381 | + $values['date_first_reg'] = null; |
|
382 | + $values['cancel'] = ''; |
|
383 | 383 | } elseif ($country == 'HJ') { |
384 | - $values['registration'] = $line[0]; |
|
385 | - $values['base'] = null; |
|
386 | - $values['owner'] = $line[8]; |
|
387 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
388 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
389 | - $values['cancel'] = ''; |
|
384 | + $values['registration'] = $line[0]; |
|
385 | + $values['base'] = null; |
|
386 | + $values['owner'] = $line[8]; |
|
387 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
388 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
389 | + $values['cancel'] = ''; |
|
390 | 390 | } elseif ($country == 'PP') { |
391 | - $values['registration'] = $line[0]; |
|
392 | - $values['base'] = null; |
|
393 | - $values['owner'] = $line[4]; |
|
394 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
395 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
396 | - $values['cancel'] = $line[7]; |
|
391 | + $values['registration'] = $line[0]; |
|
392 | + $values['base'] = null; |
|
393 | + $values['owner'] = $line[4]; |
|
394 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
395 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
396 | + $values['cancel'] = $line[7]; |
|
397 | 397 | } elseif ($country == 'E7') { |
398 | - $values['registration'] = $line[0]; |
|
399 | - $values['base'] = null; |
|
400 | - $values['owner'] = $line[4]; |
|
401 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
402 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
403 | - $values['cancel'] = ''; |
|
398 | + $values['registration'] = $line[0]; |
|
399 | + $values['base'] = null; |
|
400 | + $values['owner'] = $line[4]; |
|
401 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
402 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
403 | + $values['cancel'] = ''; |
|
404 | 404 | } elseif ($country == '8Q') { |
405 | - $values['registration'] = $line[0]; |
|
406 | - $values['base'] = null; |
|
407 | - $values['owner'] = $line[3]; |
|
408 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
409 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
410 | - $values['cancel'] = ''; |
|
405 | + $values['registration'] = $line[0]; |
|
406 | + $values['base'] = null; |
|
407 | + $values['owner'] = $line[3]; |
|
408 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
409 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
410 | + $values['cancel'] = ''; |
|
411 | 411 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
412 | - $values['registration'] = $line[0]; |
|
413 | - $values['base'] = null; |
|
414 | - $values['owner'] = $line[3]; |
|
415 | - $values['date_first_reg'] = null; |
|
416 | - $values['cancel'] = ''; |
|
412 | + $values['registration'] = $line[0]; |
|
413 | + $values['base'] = null; |
|
414 | + $values['owner'] = $line[3]; |
|
415 | + $values['date_first_reg'] = null; |
|
416 | + $values['cancel'] = ''; |
|
417 | 417 | } |
418 | 418 | if ($values['cancel'] == '' && $values['registration'] != null) { |
419 | 419 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -535,20 +535,20 @@ discard block |
||
535 | 535 | try { |
536 | 536 | $Connection = new Connection(); |
537 | 537 | $sth = $Connection->db->prepare($query); |
538 | - $sth->execute(); |
|
539 | - } catch(PDOException $e) { |
|
540 | - return "error : ".$e->getMessage(); |
|
541 | - } |
|
538 | + $sth->execute(); |
|
539 | + } catch(PDOException $e) { |
|
540 | + return "error : ".$e->getMessage(); |
|
541 | + } |
|
542 | 542 | |
543 | 543 | |
544 | 544 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
545 | 545 | try { |
546 | 546 | $Connection = new Connection(); |
547 | 547 | $sth = $Connection->db->prepare($query); |
548 | - $sth->execute(); |
|
549 | - } catch(PDOException $e) { |
|
550 | - return "error : ".$e->getMessage(); |
|
551 | - } |
|
548 | + $sth->execute(); |
|
549 | + } catch(PDOException $e) { |
|
550 | + return "error : ".$e->getMessage(); |
|
551 | + } |
|
552 | 552 | |
553 | 553 | $query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`) |
554 | 554 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
@@ -614,10 +614,10 @@ discard block |
||
614 | 614 | try { |
615 | 615 | $Connection = new Connection(); |
616 | 616 | $sth = $Connection->db->prepare($query); |
617 | - $sth->execute(); |
|
618 | - } catch(PDOException $e) { |
|
619 | - return "error : ".$e->getMessage(); |
|
620 | - } |
|
617 | + $sth->execute(); |
|
618 | + } catch(PDOException $e) { |
|
619 | + return "error : ".$e->getMessage(); |
|
620 | + } |
|
621 | 621 | |
622 | 622 | |
623 | 623 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
@@ -627,10 +627,10 @@ discard block |
||
627 | 627 | try { |
628 | 628 | $Connection = new Connection(); |
629 | 629 | $sth = $Connection->db->prepare($query); |
630 | - $sth->execute($query_values); |
|
631 | - } catch(PDOException $e) { |
|
632 | - return "error : ".$e->getMessage(); |
|
633 | - } |
|
630 | + $sth->execute($query_values); |
|
631 | + } catch(PDOException $e) { |
|
632 | + return "error : ".$e->getMessage(); |
|
633 | + } |
|
634 | 634 | $i++; |
635 | 635 | /* |
636 | 636 | $query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)'; |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | |
745 | 745 | |
746 | 746 | |
747 | - return "success"; |
|
747 | + return "success"; |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | public static function translation() { |
@@ -760,10 +760,10 @@ discard block |
||
760 | 760 | try { |
761 | 761 | $Connection = new Connection(); |
762 | 762 | $sth = $Connection->db->prepare($query); |
763 | - $sth->execute(array(':source' => 'translation.csv')); |
|
764 | - } catch(PDOException $e) { |
|
765 | - return "error : ".$e->getMessage(); |
|
766 | - } |
|
763 | + $sth->execute(array(':source' => 'translation.csv')); |
|
764 | + } catch(PDOException $e) { |
|
765 | + return "error : ".$e->getMessage(); |
|
766 | + } |
|
767 | 767 | |
768 | 768 | |
769 | 769 | //update_db::unzip($out_file); |
@@ -782,21 +782,21 @@ discard block |
||
782 | 782 | $data = $row; |
783 | 783 | $operator = $data[2]; |
784 | 784 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
785 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
786 | - //echo substr($operator, 0, 2)."\n";; |
|
787 | - if (count($airline_array) > 0) { |
|
785 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
786 | + //echo substr($operator, 0, 2)."\n";; |
|
787 | + if (count($airline_array) > 0) { |
|
788 | 788 | //print_r($airline_array); |
789 | 789 | $operator = $airline_array[0]['icao'].substr($operator,2); |
790 | - } |
|
791 | - } |
|
790 | + } |
|
791 | + } |
|
792 | 792 | |
793 | 793 | $operator_correct = $data[3]; |
794 | 794 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
795 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
796 | - if (count($airline_array) > 0) { |
|
797 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
798 | - } |
|
799 | - } |
|
795 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
796 | + if (count($airline_array) > 0) { |
|
797 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
798 | + } |
|
799 | + } |
|
800 | 800 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
801 | 801 | try { |
802 | 802 | $sth = $Connection->db->prepare($query); |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | //$Connection->db->commit(); |
811 | 811 | } |
812 | 812 | return ''; |
813 | - } |
|
813 | + } |
|
814 | 814 | |
815 | 815 | public static function translation_fam() { |
816 | 816 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -820,10 +820,10 @@ discard block |
||
820 | 820 | try { |
821 | 821 | $Connection = new Connection(); |
822 | 822 | $sth = $Connection->db->prepare($query); |
823 | - $sth->execute(array(':source' => 'website_fam')); |
|
824 | - } catch(PDOException $e) { |
|
825 | - return "error : ".$e->getMessage(); |
|
826 | - } |
|
823 | + $sth->execute(array(':source' => 'website_fam')); |
|
824 | + } catch(PDOException $e) { |
|
825 | + return "error : ".$e->getMessage(); |
|
826 | + } |
|
827 | 827 | |
828 | 828 | |
829 | 829 | //update_db::unzip($out_file); |
@@ -852,54 +852,54 @@ discard block |
||
852 | 852 | //$Connection->db->commit(); |
853 | 853 | } |
854 | 854 | return ''; |
855 | - } |
|
855 | + } |
|
856 | 856 | |
857 | 857 | /** |
858 | - * Convert a HTML table to an array |
|
859 | - * @param String $data HTML page |
|
860 | - * @return Array array of the tables in HTML page |
|
861 | - */ |
|
862 | - private static function table2array($data) { |
|
863 | - $html = str_get_html($data); |
|
864 | - $tabledata=array(); |
|
865 | - foreach($html->find('tr') as $element) |
|
866 | - { |
|
867 | - $td = array(); |
|
868 | - foreach( $element->find('th') as $row) |
|
869 | - { |
|
870 | - $td [] = trim($row->plaintext); |
|
871 | - } |
|
872 | - $td=array_filter($td); |
|
873 | - $tabledata[] = $td; |
|
874 | - |
|
875 | - $td = array(); |
|
876 | - $tdi = array(); |
|
877 | - foreach( $element->find('td') as $row) |
|
878 | - { |
|
879 | - $td [] = trim($row->plaintext); |
|
880 | - $tdi [] = trim($row->innertext); |
|
881 | - } |
|
882 | - $td=array_filter($td); |
|
883 | - $tdi=array_filter($tdi); |
|
884 | - // $tabledata[]=array_merge($td,$tdi); |
|
885 | - $tabledata[]=$td; |
|
886 | - } |
|
887 | - return(array_filter($tabledata)); |
|
888 | - } |
|
889 | - |
|
890 | - /** |
|
891 | - * Get data from form result |
|
892 | - * @param String $url form URL |
|
893 | - * @return String the result |
|
894 | - */ |
|
895 | - private static function getData($url) { |
|
896 | - $ch = curl_init(); |
|
897 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
898 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
899 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
900 | - 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'); |
|
901 | - return curl_exec($ch); |
|
902 | - } |
|
858 | + * Convert a HTML table to an array |
|
859 | + * @param String $data HTML page |
|
860 | + * @return Array array of the tables in HTML page |
|
861 | + */ |
|
862 | + private static function table2array($data) { |
|
863 | + $html = str_get_html($data); |
|
864 | + $tabledata=array(); |
|
865 | + foreach($html->find('tr') as $element) |
|
866 | + { |
|
867 | + $td = array(); |
|
868 | + foreach( $element->find('th') as $row) |
|
869 | + { |
|
870 | + $td [] = trim($row->plaintext); |
|
871 | + } |
|
872 | + $td=array_filter($td); |
|
873 | + $tabledata[] = $td; |
|
874 | + |
|
875 | + $td = array(); |
|
876 | + $tdi = array(); |
|
877 | + foreach( $element->find('td') as $row) |
|
878 | + { |
|
879 | + $td [] = trim($row->plaintext); |
|
880 | + $tdi [] = trim($row->innertext); |
|
881 | + } |
|
882 | + $td=array_filter($td); |
|
883 | + $tdi=array_filter($tdi); |
|
884 | + // $tabledata[]=array_merge($td,$tdi); |
|
885 | + $tabledata[]=$td; |
|
886 | + } |
|
887 | + return(array_filter($tabledata)); |
|
888 | + } |
|
889 | + |
|
890 | + /** |
|
891 | + * Get data from form result |
|
892 | + * @param String $url form URL |
|
893 | + * @return String the result |
|
894 | + */ |
|
895 | + private static function getData($url) { |
|
896 | + $ch = curl_init(); |
|
897 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
898 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
899 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
900 | + 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'); |
|
901 | + return curl_exec($ch); |
|
902 | + } |
|
903 | 903 | /* |
904 | 904 | public static function waypoints() { |
905 | 905 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -949,10 +949,10 @@ discard block |
||
949 | 949 | try { |
950 | 950 | $Connection = new Connection(); |
951 | 951 | $sth = $Connection->db->prepare($query); |
952 | - $sth->execute(); |
|
953 | - } catch(PDOException $e) { |
|
954 | - return "error : ".$e->getMessage(); |
|
955 | - } |
|
952 | + $sth->execute(); |
|
953 | + } catch(PDOException $e) { |
|
954 | + return "error : ".$e->getMessage(); |
|
955 | + } |
|
956 | 956 | |
957 | 957 | |
958 | 958 | //update_db::unzip($out_file); |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | if ($globalTransaction) $Connection->db->commit(); |
994 | 994 | } |
995 | 995 | return ''; |
996 | - } |
|
996 | + } |
|
997 | 997 | |
998 | 998 | public static function ivao_airlines($filename) { |
999 | 999 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1002,10 +1002,10 @@ discard block |
||
1002 | 1002 | try { |
1003 | 1003 | $Connection = new Connection(); |
1004 | 1004 | $sth = $Connection->db->prepare($query); |
1005 | - $sth->execute(); |
|
1006 | - } catch(PDOException $e) { |
|
1007 | - return "error : ".$e->getMessage(); |
|
1008 | - } |
|
1005 | + $sth->execute(); |
|
1006 | + } catch(PDOException $e) { |
|
1007 | + return "error : ".$e->getMessage(); |
|
1008 | + } |
|
1009 | 1009 | |
1010 | 1010 | $header = NULL; |
1011 | 1011 | $delimiter = ':'; |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | if ($globalTransaction) $Connection->db->commit(); |
1030 | 1030 | } |
1031 | 1031 | return ''; |
1032 | - } |
|
1032 | + } |
|
1033 | 1033 | |
1034 | 1034 | public static function update_airspace() { |
1035 | 1035 | global $tmp_dir, $globalDBdriver; |
@@ -1065,10 +1065,10 @@ discard block |
||
1065 | 1065 | $query = 'DROP TABLE countries'; |
1066 | 1066 | try { |
1067 | 1067 | $sth = $Connection->db->prepare($query); |
1068 | - $sth->execute(); |
|
1069 | - } catch(PDOException $e) { |
|
1070 | - echo "error : ".$e->getMessage(); |
|
1071 | - } |
|
1068 | + $sth->execute(); |
|
1069 | + } catch(PDOException $e) { |
|
1070 | + echo "error : ".$e->getMessage(); |
|
1071 | + } |
|
1072 | 1072 | } |
1073 | 1073 | if ($globalDBdriver == 'mysql') { |
1074 | 1074 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -1413,12 +1413,12 @@ discard block |
||
1413 | 1413 | echo $data; |
1414 | 1414 | */ |
1415 | 1415 | if (file_exists($tmp_dir.'aircrafts.html')) { |
1416 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
1417 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
1418 | - $result = fread($fh,100000000); |
|
1419 | - //echo $result; |
|
1420 | - //var_dump(str_get_html($result)); |
|
1421 | - //print_r(self::table2array($result)); |
|
1416 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
1417 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
1418 | + $result = fread($fh,100000000); |
|
1419 | + //echo $result; |
|
1420 | + //var_dump(str_get_html($result)); |
|
1421 | + //print_r(self::table2array($result)); |
|
1422 | 1422 | } |
1423 | 1423 | |
1424 | 1424 | } |
@@ -1432,10 +1432,10 @@ discard block |
||
1432 | 1432 | try { |
1433 | 1433 | $Connection = new Connection(); |
1434 | 1434 | $sth = $Connection->db->prepare($query); |
1435 | - $sth->execute(); |
|
1436 | - } catch(PDOException $e) { |
|
1437 | - return "error : ".$e->getMessage(); |
|
1438 | - } |
|
1435 | + $sth->execute(); |
|
1436 | + } catch(PDOException $e) { |
|
1437 | + return "error : ".$e->getMessage(); |
|
1438 | + } |
|
1439 | 1439 | |
1440 | 1440 | $error = ''; |
1441 | 1441 | if ($globalDebug) echo "Notam : Download..."; |
@@ -1491,8 +1491,8 @@ discard block |
||
1491 | 1491 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
1492 | 1492 | $data['permanent'] = 0; |
1493 | 1493 | } else { |
1494 | - $data['date_end'] = NULL; |
|
1495 | - $data['permanent'] = 1; |
|
1494 | + $data['date_end'] = NULL; |
|
1495 | + $data['permanent'] = 1; |
|
1496 | 1496 | } |
1497 | 1497 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
1498 | 1498 | $NOTAM = new NOTAM(); |
@@ -1516,13 +1516,13 @@ discard block |
||
1516 | 1516 | try { |
1517 | 1517 | $Connection = new Connection(); |
1518 | 1518 | $sth = $Connection->db->prepare($query); |
1519 | - $sth->execute(); |
|
1520 | - } catch(PDOException $e) { |
|
1521 | - return "error : ".$e->getMessage(); |
|
1522 | - } |
|
1523 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1524 | - if ($row['nb'] > 0) return false; |
|
1525 | - else return true; |
|
1519 | + $sth->execute(); |
|
1520 | + } catch(PDOException $e) { |
|
1521 | + return "error : ".$e->getMessage(); |
|
1522 | + } |
|
1523 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1524 | + if ($row['nb'] > 0) return false; |
|
1525 | + else return true; |
|
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | public static function insert_last_update() { |
@@ -1531,10 +1531,10 @@ discard block |
||
1531 | 1531 | try { |
1532 | 1532 | $Connection = new Connection(); |
1533 | 1533 | $sth = $Connection->db->prepare($query); |
1534 | - $sth->execute(); |
|
1535 | - } catch(PDOException $e) { |
|
1536 | - return "error : ".$e->getMessage(); |
|
1537 | - } |
|
1534 | + $sth->execute(); |
|
1535 | + } catch(PDOException $e) { |
|
1536 | + return "error : ".$e->getMessage(); |
|
1537 | + } |
|
1538 | 1538 | } |
1539 | 1539 | |
1540 | 1540 | public static function check_last_notam_update() { |
@@ -1547,13 +1547,13 @@ discard block |
||
1547 | 1547 | try { |
1548 | 1548 | $Connection = new Connection(); |
1549 | 1549 | $sth = $Connection->db->prepare($query); |
1550 | - $sth->execute(); |
|
1551 | - } catch(PDOException $e) { |
|
1552 | - return "error : ".$e->getMessage(); |
|
1553 | - } |
|
1554 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1555 | - if ($row['nb'] > 0) return false; |
|
1556 | - else return true; |
|
1550 | + $sth->execute(); |
|
1551 | + } catch(PDOException $e) { |
|
1552 | + return "error : ".$e->getMessage(); |
|
1553 | + } |
|
1554 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1555 | + if ($row['nb'] > 0) return false; |
|
1556 | + else return true; |
|
1557 | 1557 | } |
1558 | 1558 | |
1559 | 1559 | public static function insert_last_notam_update() { |
@@ -1562,10 +1562,10 @@ discard block |
||
1562 | 1562 | try { |
1563 | 1563 | $Connection = new Connection(); |
1564 | 1564 | $sth = $Connection->db->prepare($query); |
1565 | - $sth->execute(); |
|
1566 | - } catch(PDOException $e) { |
|
1567 | - return "error : ".$e->getMessage(); |
|
1568 | - } |
|
1565 | + $sth->execute(); |
|
1566 | + } catch(PDOException $e) { |
|
1567 | + return "error : ".$e->getMessage(); |
|
1568 | + } |
|
1569 | 1569 | } |
1570 | 1570 | |
1571 | 1571 | public static function check_last_owner_update() { |
@@ -1578,13 +1578,13 @@ discard block |
||
1578 | 1578 | try { |
1579 | 1579 | $Connection = new Connection(); |
1580 | 1580 | $sth = $Connection->db->prepare($query); |
1581 | - $sth->execute(); |
|
1582 | - } catch(PDOException $e) { |
|
1583 | - return "error : ".$e->getMessage(); |
|
1584 | - } |
|
1585 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1586 | - if ($row['nb'] > 0) return false; |
|
1587 | - else return true; |
|
1581 | + $sth->execute(); |
|
1582 | + } catch(PDOException $e) { |
|
1583 | + return "error : ".$e->getMessage(); |
|
1584 | + } |
|
1585 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
1586 | + if ($row['nb'] > 0) return false; |
|
1587 | + else return true; |
|
1588 | 1588 | } |
1589 | 1589 | |
1590 | 1590 | public static function insert_last_owner_update() { |
@@ -1593,10 +1593,10 @@ discard block |
||
1593 | 1593 | try { |
1594 | 1594 | $Connection = new Connection(); |
1595 | 1595 | $sth = $Connection->db->prepare($query); |
1596 | - $sth->execute(); |
|
1597 | - } catch(PDOException $e) { |
|
1598 | - return "error : ".$e->getMessage(); |
|
1599 | - } |
|
1596 | + $sth->execute(); |
|
1597 | + } catch(PDOException $e) { |
|
1598 | + return "error : ".$e->getMessage(); |
|
1599 | + } |
|
1600 | 1600 | } |
1601 | 1601 | |
1602 | 1602 | public static function update_all() { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | print '</ul>You <strong>must</strong> add these modules.</div>'; |
87 | 87 | require('../footer.php'); |
88 | - exit; |
|
88 | + exit; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | if (!isset($_SESSION['install']) && !isset($_POST['dbtype']) && (count($error) == 0)) { |
@@ -291,14 +291,14 @@ discard block |
||
291 | 291 | <th>Source name</th> |
292 | 292 | </tr> |
293 | 293 | <?php |
294 | - require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
295 | - $Connection = new Connection(); |
|
296 | - if ($Connection->db != NULL) { |
|
294 | + require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
|
295 | + $Connection = new Connection(); |
|
296 | + if ($Connection->db != NULL) { |
|
297 | 297 | if ($Connection->tableExists('source_location')) { |
298 | - require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
299 | - $Source = new Source(); |
|
300 | - $alllocations = $Source->getAllLocationInfo(); |
|
301 | - foreach ($alllocations as $location) { |
|
298 | + require_once(dirname(__FILE__).'/../require/class.Source.php'); |
|
299 | + $Source = new Source(); |
|
300 | + $alllocations = $Source->getAllLocationInfo(); |
|
301 | + foreach ($alllocations as $location) { |
|
302 | 302 | ?> |
303 | 303 | <tr> |
304 | 304 | <input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" /> |
@@ -312,9 +312,9 @@ discard block |
||
312 | 312 | </tr> |
313 | 313 | |
314 | 314 | <?php |
315 | - } |
|
315 | + } |
|
316 | + } |
|
316 | 317 | } |
317 | - } |
|
318 | 318 | ?> |
319 | 319 | |
320 | 320 | <tr> |
@@ -499,12 +499,12 @@ discard block |
||
499 | 499 | ?> |
500 | 500 | <tr> |
501 | 501 | <?php |
502 | - if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
502 | + if (filter_var($source['host'],FILTER_VALIDATE_URL)) { |
|
503 | 503 | ?> |
504 | 504 | <td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td> |
505 | 505 | <td><input type="number" name="port[]" id="port" value="<?php print $source['port']; ?>" /></td> |
506 | 506 | <?php |
507 | - } else { |
|
507 | + } else { |
|
508 | 508 | $hostport = explode(':',$source['host']); |
509 | 509 | if (isset($hostport[1])) { |
510 | 510 | $host = $hostport[0]; |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | <td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td> |
518 | 518 | <td><input type="number" name="port[]" id="port" value="<?php print $port; ?>" /></td> |
519 | 519 | <?php |
520 | - } |
|
520 | + } |
|
521 | 521 | ?> |
522 | 522 | <td> |
523 | 523 | <select name="format[]" id="format"> |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | <br /> |
793 | 793 | <p> |
794 | 794 | <?php |
795 | - if (extension_loaded('gd') && function_exists('gd_info')) { |
|
795 | + if (extension_loaded('gd') && function_exists('gd_info')) { |
|
796 | 796 | ?> |
797 | 797 | <label for="aircrafticoncolor">Color of aircraft icon on map</label> |
798 | 798 | <input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" /> |
@@ -802,11 +802,11 @@ discard block |
||
802 | 802 | <b>The directory cache is not writable, aircraft icon will not be cached</b> |
803 | 803 | <?php |
804 | 804 | } |
805 | - } else { |
|
805 | + } else { |
|
806 | 806 | ?> |
807 | 807 | <b>PHP GD is not installed, you can t change color of aircraft icon on map</b> |
808 | 808 | <?php |
809 | - } |
|
809 | + } |
|
810 | 810 | ?> |
811 | 811 | </p> |
812 | 812 | <br /> |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | </p> |
826 | 826 | <?php |
827 | 827 | require('../footer.php'); |
828 | - exit; |
|
828 | + exit; |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | $settings = array(); |
@@ -915,8 +915,8 @@ discard block |
||
915 | 915 | |
916 | 916 | $sources = array(); |
917 | 917 | foreach ($source_name as $keys => $name) { |
918 | - if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
919 | - else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
918 | + if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]); |
|
919 | + else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]); |
|
920 | 920 | } |
921 | 921 | if (count($sources) > 0) $_SESSION['sources'] = $sources; |
922 | 922 | |
@@ -1168,14 +1168,14 @@ discard block |
||
1168 | 1168 | |
1169 | 1169 | // Set some defaults values... |
1170 | 1170 | if (!isset($globalAircraftImageSources)) { |
1171 | - $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1172 | - $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1171 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
1172 | + $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources)); |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | if (!isset($globalSchedulesSources)) { |
1176 | - $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1177 | - $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1178 | - } |
|
1176 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1177 | + $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources)); |
|
1178 | + } |
|
1179 | 1179 | |
1180 | 1180 | $settings = array_merge($settings,array('globalInstalled' => 'TRUE')); |
1181 | 1181 | |
@@ -1215,17 +1215,17 @@ discard block |
||
1215 | 1215 | print '<ul><div id="step">'; |
1216 | 1216 | $pop = false; |
1217 | 1217 | foreach ($_SESSION['done'] as $done) { |
1218 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1219 | - if ($done == 'Create database') $pop = true; |
|
1220 | - if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1221 | - if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1218 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1219 | + if ($done == 'Create database') $pop = true; |
|
1220 | + if ($_SESSION['install'] == 'database_create') $pop = true; |
|
1221 | + if ($_SESSION['install'] == 'database_import') $popi = true; |
|
1222 | 1222 | } |
1223 | 1223 | if ($pop) { |
1224 | - sleep(5); |
|
1225 | - print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1224 | + sleep(5); |
|
1225 | + print '<li>Create database....<img src="../images/loading.gif" /></li>'; |
|
1226 | 1226 | } else if ($popi) { |
1227 | - sleep(5); |
|
1228 | - print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1227 | + sleep(5); |
|
1228 | + print '<li>Create and import tables....<img src="../images/loading.gif" /></li>'; |
|
1229 | 1229 | } else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>'; |
1230 | 1230 | print '</div></ul>'; |
1231 | 1231 | print '<div id="error"></div>'; |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | unset($_COOKIE['install']); |
1289 | 1289 | print '<div class="info column"><ul>'; |
1290 | 1290 | foreach ($_SESSION['done'] as $done) { |
1291 | - print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1291 | + print '<li>'.$done.'....<strong>SUCCESS</strong></li>'; |
|
1292 | 1292 | } |
1293 | 1293 | print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>'; |
1294 | 1294 | print '</ul></div>'; |