@@ -10,6 +10,9 @@ discard block |
||
| 10 | 10 | class update_db { |
| 11 | 11 | public static $db_sqlite; |
| 12 | 12 | |
| 13 | + /** |
|
| 14 | + * @param string $file |
|
| 15 | + */ |
|
| 13 | 16 | public static function download($url, $file, $referer = '') { |
| 14 | 17 | //$file = str_replace('/',DIRECTORY_SEPARATOR,$file); |
| 15 | 18 | $fp = fopen($file, 'w+'); |
@@ -25,6 +28,9 @@ discard block |
||
| 25 | 28 | fclose($fp); |
| 26 | 29 | } |
| 27 | 30 | |
| 31 | + /** |
|
| 32 | + * @param string $in_file |
|
| 33 | + */ |
|
| 28 | 34 | public static function gunzip($in_file,$out_file_name = '') { |
| 29 | 35 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 30 | 36 | $buffer_size = 4096; // read 4kb at a time |
@@ -46,6 +52,9 @@ discard block |
||
| 46 | 52 | } |
| 47 | 53 | } |
| 48 | 54 | |
| 55 | + /** |
|
| 56 | + * @param string $in_file |
|
| 57 | + */ |
|
| 49 | 58 | public static function unzip($in_file) { |
| 50 | 59 | if ($in_file != '' && file_exists($in_file)) { |
| 51 | 60 | $path = pathinfo(realpath($in_file), PATHINFO_DIRNAME); |
@@ -67,6 +76,9 @@ discard block |
||
| 67 | 76 | } |
| 68 | 77 | } |
| 69 | 78 | |
| 79 | + /** |
|
| 80 | + * @param string $database_file |
|
| 81 | + */ |
|
| 70 | 82 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 71 | 83 | global $globalDebug, $globalTransaction; |
| 72 | 84 | //$query = 'TRUNCATE TABLE routes'; |
@@ -109,6 +121,10 @@ discard block |
||
| 109 | 121 | } |
| 110 | 122 | return ''; |
| 111 | 123 | } |
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @param string $database_file |
|
| 127 | + */ |
|
| 112 | 128 | public static function retrieve_route_oneworld($database_file) { |
| 113 | 129 | global $globalDebug, $globalTransaction; |
| 114 | 130 | //$query = 'TRUNCATE TABLE routes'; |
@@ -150,6 +166,9 @@ discard block |
||
| 150 | 166 | return ''; |
| 151 | 167 | } |
| 152 | 168 | |
| 169 | + /** |
|
| 170 | + * @param string $database_file |
|
| 171 | + */ |
|
| 153 | 172 | public static function retrieve_route_skyteam($database_file) { |
| 154 | 173 | global $globalDebug, $globalTransaction; |
| 155 | 174 | //$query = 'TRUNCATE TABLE routes'; |
@@ -192,6 +211,10 @@ discard block |
||
| 192 | 211 | } |
| 193 | 212 | return ''; |
| 194 | 213 | } |
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * @param string $database_file |
|
| 217 | + */ |
|
| 195 | 218 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
| 196 | 219 | global $globalTransaction; |
| 197 | 220 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
@@ -258,6 +281,9 @@ discard block |
||
| 258 | 281 | return ''; |
| 259 | 282 | } |
| 260 | 283 | |
| 284 | + /** |
|
| 285 | + * @param string $database_file |
|
| 286 | + */ |
|
| 261 | 287 | public static function retrieve_modes_flarmnet($database_file) { |
| 262 | 288 | global $globalTransaction; |
| 263 | 289 | $Common = new Common(); |
@@ -328,6 +354,9 @@ discard block |
||
| 328 | 354 | return ''; |
| 329 | 355 | } |
| 330 | 356 | |
| 357 | + /** |
|
| 358 | + * @param string $database_file |
|
| 359 | + */ |
|
| 331 | 360 | public static function retrieve_modes_ogn($database_file) { |
| 332 | 361 | global $globalTransaction; |
| 333 | 362 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
@@ -396,6 +425,9 @@ discard block |
||
| 396 | 425 | return ''; |
| 397 | 426 | } |
| 398 | 427 | |
| 428 | + /** |
|
| 429 | + * @param string $database_file |
|
| 430 | + */ |
|
| 399 | 431 | public static function retrieve_owner($database_file,$country = 'F') { |
| 400 | 432 | global $globalTransaction, $globalMasterSource; |
| 401 | 433 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
@@ -1276,6 +1308,10 @@ discard block |
||
| 1276 | 1308 | return ''; |
| 1277 | 1309 | } |
| 1278 | 1310 | |
| 1311 | + /** |
|
| 1312 | + * @param string $filename |
|
| 1313 | + * @param string $tletype |
|
| 1314 | + */ |
|
| 1279 | 1315 | public static function tle($filename,$tletype) { |
| 1280 | 1316 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 1281 | 1317 | global $tmp_dir, $globalTransaction; |
@@ -1408,6 +1444,9 @@ discard block |
||
| 1408 | 1444 | |
| 1409 | 1445 | } |
| 1410 | 1446 | */ |
| 1447 | + /** |
|
| 1448 | + * @param string $filename |
|
| 1449 | + */ |
|
| 1411 | 1450 | public static function waypoints($filename) { |
| 1412 | 1451 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 1413 | 1452 | global $tmp_dir, $globalTransaction; |
@@ -1455,6 +1494,9 @@ discard block |
||
| 1455 | 1494 | return ''; |
| 1456 | 1495 | } |
| 1457 | 1496 | |
| 1497 | + /** |
|
| 1498 | + * @param string $filename |
|
| 1499 | + */ |
|
| 1458 | 1500 | public static function ivao_airlines($filename) { |
| 1459 | 1501 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 1460 | 1502 | global $tmp_dir, $globalTransaction; |
@@ -76,38 +76,38 @@ discard block |
||
| 76 | 76 | try { |
| 77 | 77 | //$Connection = new Connection(); |
| 78 | 78 | $sth = $Connection->db->prepare($query); |
| 79 | - $sth->execute(array(':source' => $database_file)); |
|
| 80 | - } catch(PDOException $e) { |
|
| 81 | - return "error : ".$e->getMessage(); |
|
| 82 | - } |
|
| 79 | + $sth->execute(array(':source' => $database_file)); |
|
| 80 | + } catch(PDOException $e) { |
|
| 81 | + return "error : ".$e->getMessage(); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 85 | - update_db::connect_sqlite($database_file); |
|
| 84 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 85 | + update_db::connect_sqlite($database_file); |
|
| 86 | 86 | //$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'; |
| 87 | 87 | $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"; |
| 88 | 88 | try { |
| 89 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 90 | - $sth->execute(); |
|
| 91 | - } catch(PDOException $e) { |
|
| 92 | - return "error : ".$e->getMessage(); |
|
| 93 | - } |
|
| 89 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 90 | + $sth->execute(); |
|
| 91 | + } catch(PDOException $e) { |
|
| 92 | + return "error : ".$e->getMessage(); |
|
| 93 | + } |
|
| 94 | 94 | //$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)'; |
| 95 | 95 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
| 96 | 96 | $Connection = new Connection(); |
| 97 | 97 | $sth_dest = $Connection->db->prepare($query_dest); |
| 98 | 98 | try { |
| 99 | 99 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 100 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 100 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 101 | 101 | //$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); |
| 102 | 102 | $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); |
| 103 | 103 | $sth_dest->execute($query_dest_values); |
| 104 | - } |
|
| 104 | + } |
|
| 105 | 105 | if ($globalTransaction) $Connection->db->commit(); |
| 106 | 106 | } catch(PDOException $e) { |
| 107 | 107 | if ($globalTransaction) $Connection->db->rollBack(); |
| 108 | 108 | return "error : ".$e->getMessage(); |
| 109 | 109 | } |
| 110 | - return ''; |
|
| 110 | + return ''; |
|
| 111 | 111 | } |
| 112 | 112 | public static function retrieve_route_oneworld($database_file) { |
| 113 | 113 | global $globalDebug, $globalTransaction; |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | try { |
| 119 | 119 | //$Connection = new Connection(); |
| 120 | 120 | $sth = $Connection->db->prepare($query); |
| 121 | - $sth->execute(array(':source' => 'oneworld')); |
|
| 122 | - } catch(PDOException $e) { |
|
| 123 | - return "error : ".$e->getMessage(); |
|
| 124 | - } |
|
| 121 | + $sth->execute(array(':source' => 'oneworld')); |
|
| 122 | + } catch(PDOException $e) { |
|
| 123 | + return "error : ".$e->getMessage(); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 126 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 127 | 127 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 128 | 128 | $Spotter = new Spotter(); |
| 129 | 129 | if ($fh = fopen($database_file,"r")) { |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | if ($globalTransaction) $Connection->db->commit(); |
| 149 | 149 | } |
| 150 | - return ''; |
|
| 150 | + return ''; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | public static function retrieve_route_skyteam($database_file) { |
@@ -159,12 +159,12 @@ discard block |
||
| 159 | 159 | try { |
| 160 | 160 | //$Connection = new Connection(); |
| 161 | 161 | $sth = $Connection->db->prepare($query); |
| 162 | - $sth->execute(array(':source' => 'skyteam')); |
|
| 163 | - } catch(PDOException $e) { |
|
| 164 | - return "error : ".$e->getMessage(); |
|
| 165 | - } |
|
| 162 | + $sth->execute(array(':source' => 'skyteam')); |
|
| 163 | + } catch(PDOException $e) { |
|
| 164 | + return "error : ".$e->getMessage(); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 167 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 168 | 168 | |
| 169 | 169 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 170 | 170 | $Spotter = new Spotter(); |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | return "error : ".$e->getMessage(); |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | - return ''; |
|
| 193 | + return ''; |
|
| 194 | 194 | } |
| 195 | 195 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
| 196 | 196 | global $globalTransaction; |
@@ -199,27 +199,27 @@ discard block |
||
| 199 | 199 | try { |
| 200 | 200 | $Connection = new Connection(); |
| 201 | 201 | $sth = $Connection->db->prepare($query); |
| 202 | - $sth->execute(array(':source' => $database_file)); |
|
| 203 | - } catch(PDOException $e) { |
|
| 204 | - return "error : ".$e->getMessage(); |
|
| 205 | - } |
|
| 202 | + $sth->execute(array(':source' => $database_file)); |
|
| 203 | + } catch(PDOException $e) { |
|
| 204 | + return "error : ".$e->getMessage(); |
|
| 205 | + } |
|
| 206 | 206 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
| 207 | 207 | try { |
| 208 | 208 | $Connection = new Connection(); |
| 209 | 209 | $sth = $Connection->db->prepare($query); |
| 210 | - $sth->execute(array(':source' => $database_file)); |
|
| 211 | - } catch(PDOException $e) { |
|
| 212 | - return "error : ".$e->getMessage(); |
|
| 213 | - } |
|
| 210 | + $sth->execute(array(':source' => $database_file)); |
|
| 211 | + } catch(PDOException $e) { |
|
| 212 | + return "error : ".$e->getMessage(); |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - update_db::connect_sqlite($database_file); |
|
| 215 | + update_db::connect_sqlite($database_file); |
|
| 216 | 216 | $query = 'select * from Aircraft'; |
| 217 | 217 | try { |
| 218 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 219 | - $sth->execute(); |
|
| 220 | - } catch(PDOException $e) { |
|
| 221 | - return "error : ".$e->getMessage(); |
|
| 222 | - } |
|
| 218 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 219 | + $sth->execute(); |
|
| 220 | + } catch(PDOException $e) { |
|
| 221 | + return "error : ".$e->getMessage(); |
|
| 222 | + } |
|
| 223 | 223 | //$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)'; |
| 224 | 224 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
| 225 | 225 | |
@@ -230,17 +230,17 @@ discard block |
||
| 230 | 230 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 231 | 231 | try { |
| 232 | 232 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 233 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 233 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 234 | 234 | //$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']); |
| 235 | 235 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 236 | 236 | else $type = null; |
| 237 | 237 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 238 | 238 | $sth_dest->execute($query_dest_values); |
| 239 | 239 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 240 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 241 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
| 240 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 241 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
| 242 | 242 | } |
| 243 | - } |
|
| 243 | + } |
|
| 244 | 244 | if ($globalTransaction) $Connection->db->commit(); |
| 245 | 245 | } catch(PDOException $e) { |
| 246 | 246 | return "error : ".$e->getMessage(); |
@@ -251,10 +251,10 @@ discard block |
||
| 251 | 251 | try { |
| 252 | 252 | $Connection = new Connection(); |
| 253 | 253 | $sth = $Connection->db->prepare($query); |
| 254 | - $sth->execute(array(':source' => $database_file)); |
|
| 255 | - } catch(PDOException $e) { |
|
| 256 | - return "error : ".$e->getMessage(); |
|
| 257 | - } |
|
| 254 | + $sth->execute(array(':source' => $database_file)); |
|
| 255 | + } catch(PDOException $e) { |
|
| 256 | + return "error : ".$e->getMessage(); |
|
| 257 | + } |
|
| 258 | 258 | return ''; |
| 259 | 259 | } |
| 260 | 260 | |
@@ -266,10 +266,10 @@ discard block |
||
| 266 | 266 | try { |
| 267 | 267 | $Connection = new Connection(); |
| 268 | 268 | $sth = $Connection->db->prepare($query); |
| 269 | - $sth->execute(array(':source' => $database_file)); |
|
| 270 | - } catch(PDOException $e) { |
|
| 271 | - return "error : ".$e->getMessage(); |
|
| 272 | - } |
|
| 269 | + $sth->execute(array(':source' => $database_file)); |
|
| 270 | + } catch(PDOException $e) { |
|
| 271 | + return "error : ".$e->getMessage(); |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | 274 | if ($fh = fopen($database_file,"r")) { |
| 275 | 275 | //$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)'; |
@@ -279,26 +279,26 @@ discard block |
||
| 279 | 279 | $sth_dest = $Connection->db->prepare($query_dest); |
| 280 | 280 | try { |
| 281 | 281 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 282 | - while (!feof($fh)) { |
|
| 283 | - $values = array(); |
|
| 284 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 282 | + while (!feof($fh)) { |
|
| 283 | + $values = array(); |
|
| 284 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
| 285 | 285 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 286 | - $values['ModeS'] = substr($line,0,6); |
|
| 287 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 288 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 289 | - // Check if we can find ICAO, else set it to GLID |
|
| 290 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 291 | - $search_more = ''; |
|
| 292 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 293 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 294 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 286 | + $values['ModeS'] = substr($line,0,6); |
|
| 287 | + $values['Registration'] = trim(substr($line,69,6)); |
|
| 288 | + $aircraft_name = trim(substr($line,48,6)); |
|
| 289 | + // Check if we can find ICAO, else set it to GLID |
|
| 290 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 291 | + $search_more = ''; |
|
| 292 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 293 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 294 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 295 | 295 | try { |
| 296 | - $sth_search->execute(); |
|
| 297 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 298 | - //if (count($result) > 0) { |
|
| 299 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
| 300 | - $values['ICAOTypeCode'] = $result['icao']; |
|
| 301 | - } |
|
| 296 | + $sth_search->execute(); |
|
| 297 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 298 | + //if (count($result) > 0) { |
|
| 299 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 300 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 301 | + } |
|
| 302 | 302 | } catch(PDOException $e) { |
| 303 | 303 | return "error : ".$e->getMessage(); |
| 304 | 304 | } |
@@ -321,10 +321,10 @@ discard block |
||
| 321 | 321 | try { |
| 322 | 322 | $Connection = new Connection(); |
| 323 | 323 | $sth = $Connection->db->prepare($query); |
| 324 | - $sth->execute(array(':source' => $database_file)); |
|
| 325 | - } catch(PDOException $e) { |
|
| 326 | - return "error : ".$e->getMessage(); |
|
| 327 | - } |
|
| 324 | + $sth->execute(array(':source' => $database_file)); |
|
| 325 | + } catch(PDOException $e) { |
|
| 326 | + return "error : ".$e->getMessage(); |
|
| 327 | + } |
|
| 328 | 328 | return ''; |
| 329 | 329 | } |
| 330 | 330 | |
@@ -335,10 +335,10 @@ discard block |
||
| 335 | 335 | try { |
| 336 | 336 | $Connection = new Connection(); |
| 337 | 337 | $sth = $Connection->db->prepare($query); |
| 338 | - $sth->execute(array(':source' => $database_file)); |
|
| 339 | - } catch(PDOException $e) { |
|
| 340 | - return "error : ".$e->getMessage(); |
|
| 341 | - } |
|
| 338 | + $sth->execute(array(':source' => $database_file)); |
|
| 339 | + } catch(PDOException $e) { |
|
| 340 | + return "error : ".$e->getMessage(); |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | 343 | if ($fh = fopen($database_file,"r")) { |
| 344 | 344 | //$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)'; |
@@ -349,25 +349,25 @@ discard block |
||
| 349 | 349 | try { |
| 350 | 350 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 351 | 351 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 352 | - while (!feof($fh)) { |
|
| 353 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 352 | + while (!feof($fh)) { |
|
| 353 | + $line = fgetcsv($fh,9999,',',"'"); |
|
| 354 | 354 | |
| 355 | 355 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 356 | 356 | //print_r($line); |
| 357 | - $values['ModeS'] = $line[1]; |
|
| 358 | - $values['Registration'] = $line[3]; |
|
| 359 | - $values['ICAOTypeCode'] = ''; |
|
| 360 | - $aircraft_name = $line[2]; |
|
| 361 | - // Check if we can find ICAO, else set it to GLID |
|
| 362 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 363 | - $search_more = ''; |
|
| 364 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 365 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 366 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 357 | + $values['ModeS'] = $line[1]; |
|
| 358 | + $values['Registration'] = $line[3]; |
|
| 359 | + $values['ICAOTypeCode'] = ''; |
|
| 360 | + $aircraft_name = $line[2]; |
|
| 361 | + // Check if we can find ICAO, else set it to GLID |
|
| 362 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 363 | + $search_more = ''; |
|
| 364 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 365 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 366 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 367 | 367 | try { |
| 368 | - $sth_search->execute(); |
|
| 369 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 370 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 368 | + $sth_search->execute(); |
|
| 369 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 370 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 371 | 371 | } catch(PDOException $e) { |
| 372 | 372 | return "error : ".$e->getMessage(); |
| 373 | 373 | } |
@@ -390,10 +390,10 @@ discard block |
||
| 390 | 390 | try { |
| 391 | 391 | $Connection = new Connection(); |
| 392 | 392 | $sth = $Connection->db->prepare($query); |
| 393 | - $sth->execute(array(':source' => $database_file)); |
|
| 394 | - } catch(PDOException $e) { |
|
| 395 | - return "error : ".$e->getMessage(); |
|
| 396 | - } |
|
| 393 | + $sth->execute(array(':source' => $database_file)); |
|
| 394 | + } catch(PDOException $e) { |
|
| 395 | + return "error : ".$e->getMessage(); |
|
| 396 | + } |
|
| 397 | 397 | return ''; |
| 398 | 398 | } |
| 399 | 399 | |
@@ -404,16 +404,16 @@ discard block |
||
| 404 | 404 | try { |
| 405 | 405 | $Connection = new Connection(); |
| 406 | 406 | $sth = $Connection->db->prepare($query); |
| 407 | - $sth->execute(array(':source' => $database_file)); |
|
| 408 | - } catch(PDOException $e) { |
|
| 409 | - return "error : ".$e->getMessage(); |
|
| 410 | - } |
|
| 407 | + $sth->execute(array(':source' => $database_file)); |
|
| 408 | + } catch(PDOException $e) { |
|
| 409 | + return "error : ".$e->getMessage(); |
|
| 410 | + } |
|
| 411 | 411 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 412 | 412 | $Spotter = new Spotter(); |
| 413 | 413 | if ($fh = fopen($database_file,"r")) { |
| 414 | 414 | //$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)'; |
| 415 | 415 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 416 | - $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
| 416 | + $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
|
| 417 | 417 | |
| 418 | 418 | $Connection = new Connection(); |
| 419 | 419 | $sth_dest = $Connection->db->prepare($query_dest); |
@@ -421,126 +421,126 @@ discard block |
||
| 421 | 421 | try { |
| 422 | 422 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 423 | 423 | $tmp = fgetcsv($fh,9999,',','"'); |
| 424 | - while (!feof($fh)) { |
|
| 425 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 426 | - $values = array(); |
|
| 427 | - //print_r($line); |
|
| 428 | - if ($country == 'F') { |
|
| 429 | - $values['registration'] = $line[0]; |
|
| 430 | - $values['base'] = $line[4]; |
|
| 431 | - $values['owner'] = $line[5]; |
|
| 432 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 434 | - $values['cancel'] = $line[7]; |
|
| 424 | + while (!feof($fh)) { |
|
| 425 | + $line = fgetcsv($fh,9999,',','"'); |
|
| 426 | + $values = array(); |
|
| 427 | + //print_r($line); |
|
| 428 | + if ($country == 'F') { |
|
| 429 | + $values['registration'] = $line[0]; |
|
| 430 | + $values['base'] = $line[4]; |
|
| 431 | + $values['owner'] = $line[5]; |
|
| 432 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 433 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 434 | + $values['cancel'] = $line[7]; |
|
| 435 | 435 | } elseif ($country == 'EI') { |
| 436 | - // TODO : add modeS & reg to aircraft_modes |
|
| 437 | - $values['registration'] = $line[0]; |
|
| 438 | - $values['base'] = $line[3]; |
|
| 439 | - $values['owner'] = $line[2]; |
|
| 440 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 442 | - $values['cancel'] = ''; |
|
| 443 | - $values['modes'] = $line[7]; |
|
| 444 | - $values['icao'] = $line[8]; |
|
| 436 | + // TODO : add modeS & reg to aircraft_modes |
|
| 437 | + $values['registration'] = $line[0]; |
|
| 438 | + $values['base'] = $line[3]; |
|
| 439 | + $values['owner'] = $line[2]; |
|
| 440 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 441 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 442 | + $values['cancel'] = ''; |
|
| 443 | + $values['modes'] = $line[7]; |
|
| 444 | + $values['icao'] = $line[8]; |
|
| 445 | 445 | |
| 446 | 446 | } elseif ($country == 'HB') { |
| 447 | - // TODO : add modeS & reg to aircraft_modes |
|
| 448 | - $values['registration'] = $line[0]; |
|
| 449 | - $values['base'] = null; |
|
| 450 | - $values['owner'] = $line[5]; |
|
| 451 | - $values['date_first_reg'] = null; |
|
| 452 | - $values['cancel'] = ''; |
|
| 453 | - $values['modes'] = $line[4]; |
|
| 454 | - $values['icao'] = $line[7]; |
|
| 447 | + // TODO : add modeS & reg to aircraft_modes |
|
| 448 | + $values['registration'] = $line[0]; |
|
| 449 | + $values['base'] = null; |
|
| 450 | + $values['owner'] = $line[5]; |
|
| 451 | + $values['date_first_reg'] = null; |
|
| 452 | + $values['cancel'] = ''; |
|
| 453 | + $values['modes'] = $line[4]; |
|
| 454 | + $values['icao'] = $line[7]; |
|
| 455 | 455 | } elseif ($country == 'OK') { |
| 456 | - // TODO : add modeS & reg to aircraft_modes |
|
| 457 | - $values['registration'] = $line[3]; |
|
| 458 | - $values['base'] = null; |
|
| 459 | - $values['owner'] = $line[5]; |
|
| 460 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 462 | - $values['cancel'] = ''; |
|
| 456 | + // TODO : add modeS & reg to aircraft_modes |
|
| 457 | + $values['registration'] = $line[3]; |
|
| 458 | + $values['base'] = null; |
|
| 459 | + $values['owner'] = $line[5]; |
|
| 460 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 461 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 462 | + $values['cancel'] = ''; |
|
| 463 | 463 | } elseif ($country == 'VH') { |
| 464 | - // TODO : add modeS & reg to aircraft_modes |
|
| 465 | - $values['registration'] = $line[0]; |
|
| 466 | - $values['base'] = null; |
|
| 467 | - $values['owner'] = $line[12]; |
|
| 468 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 470 | - |
|
| 471 | - $values['cancel'] = $line[39]; |
|
| 464 | + // TODO : add modeS & reg to aircraft_modes |
|
| 465 | + $values['registration'] = $line[0]; |
|
| 466 | + $values['base'] = null; |
|
| 467 | + $values['owner'] = $line[12]; |
|
| 468 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 469 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 470 | + |
|
| 471 | + $values['cancel'] = $line[39]; |
|
| 472 | 472 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
| 473 | - $values['registration'] = $line[0]; |
|
| 474 | - $values['base'] = null; |
|
| 475 | - $values['owner'] = $line[4]; |
|
| 476 | - $values['date_first_reg'] = null; |
|
| 477 | - $values['cancel'] = ''; |
|
| 473 | + $values['registration'] = $line[0]; |
|
| 474 | + $values['base'] = null; |
|
| 475 | + $values['owner'] = $line[4]; |
|
| 476 | + $values['date_first_reg'] = null; |
|
| 477 | + $values['cancel'] = ''; |
|
| 478 | 478 | } elseif ($country == 'CC') { |
| 479 | - $values['registration'] = $line[0]; |
|
| 480 | - $values['base'] = null; |
|
| 481 | - $values['owner'] = $line[6]; |
|
| 482 | - $values['date_first_reg'] = null; |
|
| 483 | - $values['cancel'] = ''; |
|
| 479 | + $values['registration'] = $line[0]; |
|
| 480 | + $values['base'] = null; |
|
| 481 | + $values['owner'] = $line[6]; |
|
| 482 | + $values['date_first_reg'] = null; |
|
| 483 | + $values['cancel'] = ''; |
|
| 484 | 484 | } elseif ($country == 'HJ') { |
| 485 | - $values['registration'] = $line[0]; |
|
| 486 | - $values['base'] = null; |
|
| 487 | - $values['owner'] = $line[8]; |
|
| 488 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 490 | - $values['cancel'] = ''; |
|
| 485 | + $values['registration'] = $line[0]; |
|
| 486 | + $values['base'] = null; |
|
| 487 | + $values['owner'] = $line[8]; |
|
| 488 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 489 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 490 | + $values['cancel'] = ''; |
|
| 491 | 491 | } elseif ($country == 'PP') { |
| 492 | - $values['registration'] = $line[0]; |
|
| 493 | - $values['base'] = null; |
|
| 494 | - $values['owner'] = $line[4]; |
|
| 495 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 497 | - $values['cancel'] = $line[7]; |
|
| 492 | + $values['registration'] = $line[0]; |
|
| 493 | + $values['base'] = null; |
|
| 494 | + $values['owner'] = $line[4]; |
|
| 495 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 496 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 497 | + $values['cancel'] = $line[7]; |
|
| 498 | 498 | } elseif ($country == 'E7') { |
| 499 | - $values['registration'] = $line[0]; |
|
| 500 | - $values['base'] = null; |
|
| 501 | - $values['owner'] = $line[4]; |
|
| 502 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 504 | - $values['cancel'] = ''; |
|
| 499 | + $values['registration'] = $line[0]; |
|
| 500 | + $values['base'] = null; |
|
| 501 | + $values['owner'] = $line[4]; |
|
| 502 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 503 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 504 | + $values['cancel'] = ''; |
|
| 505 | 505 | } elseif ($country == '8Q') { |
| 506 | - $values['registration'] = $line[0]; |
|
| 507 | - $values['base'] = null; |
|
| 508 | - $values['owner'] = $line[3]; |
|
| 509 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 511 | - $values['cancel'] = ''; |
|
| 506 | + $values['registration'] = $line[0]; |
|
| 507 | + $values['base'] = null; |
|
| 508 | + $values['owner'] = $line[3]; |
|
| 509 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 510 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 511 | + $values['cancel'] = ''; |
|
| 512 | 512 | } elseif ($country == 'ZK') { |
| 513 | - $values['registration'] = $line[0]; |
|
| 514 | - $values['base'] = null; |
|
| 515 | - $values['owner'] = $line[3]; |
|
| 516 | - $values['date_first_reg'] = null; |
|
| 517 | - $values['cancel'] = ''; |
|
| 518 | - $values['modes'] = $line[5]; |
|
| 519 | - $values['icao'] = $line[9]; |
|
| 513 | + $values['registration'] = $line[0]; |
|
| 514 | + $values['base'] = null; |
|
| 515 | + $values['owner'] = $line[3]; |
|
| 516 | + $values['date_first_reg'] = null; |
|
| 517 | + $values['cancel'] = ''; |
|
| 518 | + $values['modes'] = $line[5]; |
|
| 519 | + $values['icao'] = $line[9]; |
|
| 520 | 520 | } elseif ($country == 'M') { |
| 521 | - $values['registration'] = $line[0]; |
|
| 522 | - $values['base'] = null; |
|
| 523 | - $values['owner'] = $line[6]; |
|
| 524 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 525 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 526 | - $values['modes'] = $line[4]; |
|
| 527 | - $values['icao'] = $line[10]; |
|
| 521 | + $values['registration'] = $line[0]; |
|
| 522 | + $values['base'] = null; |
|
| 523 | + $values['owner'] = $line[6]; |
|
| 524 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 525 | + $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 526 | + $values['modes'] = $line[4]; |
|
| 527 | + $values['icao'] = $line[10]; |
|
| 528 | 528 | } elseif ($country == 'OY') { |
| 529 | - $values['registration'] = $line[0]; |
|
| 530 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 531 | - $values['modes'] = $line[5]; |
|
| 532 | - $values['icao'] = $line[6]; |
|
| 529 | + $values['registration'] = $line[0]; |
|
| 530 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 531 | + $values['modes'] = $line[5]; |
|
| 532 | + $values['icao'] = $line[6]; |
|
| 533 | 533 | } elseif ($country == 'PH') { |
| 534 | - $values['registration'] = $line[0]; |
|
| 535 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 536 | - $values['modes'] = $line[4]; |
|
| 537 | - $values['icao'] = $line[5]; |
|
| 534 | + $values['registration'] = $line[0]; |
|
| 535 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 536 | + $values['modes'] = $line[4]; |
|
| 537 | + $values['icao'] = $line[5]; |
|
| 538 | 538 | } elseif ($country == 'OM' || $country == 'TF') { |
| 539 | - $values['registration'] = $line[0]; |
|
| 540 | - $values['base'] = null; |
|
| 541 | - $values['owner'] = $line[3]; |
|
| 542 | - $values['date_first_reg'] = null; |
|
| 543 | - $values['cancel'] = ''; |
|
| 539 | + $values['registration'] = $line[0]; |
|
| 540 | + $values['base'] = null; |
|
| 541 | + $values['owner'] = $line[3]; |
|
| 542 | + $values['date_first_reg'] = null; |
|
| 543 | + $values['cancel'] = ''; |
|
| 544 | 544 | } |
| 545 | 545 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
| 546 | 546 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | return "error : ".$e->getMessage(); |
| 674 | 674 | } |
| 675 | 675 | */ |
| 676 | - /* |
|
| 676 | + /* |
|
| 677 | 677 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
| 678 | 678 | try { |
| 679 | 679 | $Connection = new Connection(); |
@@ -918,10 +918,10 @@ discard block |
||
| 918 | 918 | try { |
| 919 | 919 | $Connection = new Connection(); |
| 920 | 920 | $sth = $Connection->db->prepare($query); |
| 921 | - $sth->execute(array(':source' => 'translation.csv')); |
|
| 922 | - } catch(PDOException $e) { |
|
| 923 | - return "error : ".$e->getMessage(); |
|
| 924 | - } |
|
| 921 | + $sth->execute(array(':source' => 'translation.csv')); |
|
| 922 | + } catch(PDOException $e) { |
|
| 923 | + return "error : ".$e->getMessage(); |
|
| 924 | + } |
|
| 925 | 925 | |
| 926 | 926 | |
| 927 | 927 | //update_db::unzip($out_file); |
@@ -940,21 +940,21 @@ discard block |
||
| 940 | 940 | $data = $row; |
| 941 | 941 | $operator = $data[2]; |
| 942 | 942 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
| 943 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 944 | - //echo substr($operator, 0, 2)."\n";; |
|
| 945 | - if (count($airline_array) > 0) { |
|
| 943 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 944 | + //echo substr($operator, 0, 2)."\n";; |
|
| 945 | + if (count($airline_array) > 0) { |
|
| 946 | 946 | //print_r($airline_array); |
| 947 | 947 | $operator = $airline_array[0]['icao'].substr($operator,2); |
| 948 | - } |
|
| 949 | - } |
|
| 948 | + } |
|
| 949 | + } |
|
| 950 | 950 | |
| 951 | 951 | $operator_correct = $data[3]; |
| 952 | 952 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 953 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 954 | - if (count($airline_array) > 0) { |
|
| 955 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 956 | - } |
|
| 957 | - } |
|
| 953 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 954 | + if (count($airline_array) > 0) { |
|
| 955 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 956 | + } |
|
| 957 | + } |
|
| 958 | 958 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 959 | 959 | try { |
| 960 | 960 | $sth = $Connection->db->prepare($query); |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | //$Connection->db->commit(); |
| 969 | 969 | } |
| 970 | 970 | return ''; |
| 971 | - } |
|
| 971 | + } |
|
| 972 | 972 | |
| 973 | 973 | public static function translation_fam() { |
| 974 | 974 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -978,10 +978,10 @@ discard block |
||
| 978 | 978 | try { |
| 979 | 979 | $Connection = new Connection(); |
| 980 | 980 | $sth = $Connection->db->prepare($query); |
| 981 | - $sth->execute(array(':source' => 'website_fam')); |
|
| 982 | - } catch(PDOException $e) { |
|
| 983 | - return "error : ".$e->getMessage(); |
|
| 984 | - } |
|
| 981 | + $sth->execute(array(':source' => 'website_fam')); |
|
| 982 | + } catch(PDOException $e) { |
|
| 983 | + return "error : ".$e->getMessage(); |
|
| 984 | + } |
|
| 985 | 985 | |
| 986 | 986 | |
| 987 | 987 | //update_db::unzip($out_file); |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | //$Connection->db->commit(); |
| 1011 | 1011 | } |
| 1012 | 1012 | return ''; |
| 1013 | - } |
|
| 1013 | + } |
|
| 1014 | 1014 | |
| 1015 | 1015 | /* |
| 1016 | 1016 | * This function use FAA public data. |
@@ -1022,19 +1022,19 @@ discard block |
||
| 1022 | 1022 | try { |
| 1023 | 1023 | $Connection = new Connection(); |
| 1024 | 1024 | $sth = $Connection->db->prepare($query); |
| 1025 | - $sth->execute(array(':source' => 'website_faa')); |
|
| 1026 | - } catch(PDOException $e) { |
|
| 1027 | - return "error : ".$e->getMessage(); |
|
| 1028 | - } |
|
| 1025 | + $sth->execute(array(':source' => 'website_faa')); |
|
| 1026 | + } catch(PDOException $e) { |
|
| 1027 | + return "error : ".$e->getMessage(); |
|
| 1028 | + } |
|
| 1029 | 1029 | |
| 1030 | 1030 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source"; |
| 1031 | 1031 | try { |
| 1032 | 1032 | $Connection = new Connection(); |
| 1033 | 1033 | $sth = $Connection->db->prepare($query); |
| 1034 | - $sth->execute(array(':source' => 'website_faa')); |
|
| 1035 | - } catch(PDOException $e) { |
|
| 1036 | - return "error : ".$e->getMessage(); |
|
| 1037 | - } |
|
| 1034 | + $sth->execute(array(':source' => 'website_faa')); |
|
| 1035 | + } catch(PDOException $e) { |
|
| 1036 | + return "error : ".$e->getMessage(); |
|
| 1037 | + } |
|
| 1038 | 1038 | |
| 1039 | 1039 | $delimiter = ","; |
| 1040 | 1040 | $mfr = array(); |
@@ -1110,17 +1110,17 @@ discard block |
||
| 1110 | 1110 | } |
| 1111 | 1111 | print_r($mfr); |
| 1112 | 1112 | return ''; |
| 1113 | - } |
|
| 1113 | + } |
|
| 1114 | 1114 | public static function modes_fam() { |
| 1115 | 1115 | global $tmp_dir, $globalTransaction; |
| 1116 | 1116 | $query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source"; |
| 1117 | 1117 | try { |
| 1118 | 1118 | $Connection = new Connection(); |
| 1119 | 1119 | $sth = $Connection->db->prepare($query); |
| 1120 | - $sth->execute(array(':source' => 'website_fam')); |
|
| 1121 | - } catch(PDOException $e) { |
|
| 1122 | - return "error : ".$e->getMessage(); |
|
| 1123 | - } |
|
| 1120 | + $sth->execute(array(':source' => 'website_fam')); |
|
| 1121 | + } catch(PDOException $e) { |
|
| 1122 | + return "error : ".$e->getMessage(); |
|
| 1123 | + } |
|
| 1124 | 1124 | |
| 1125 | 1125 | |
| 1126 | 1126 | //update_db::unzip($out_file); |
@@ -1150,7 +1150,7 @@ discard block |
||
| 1150 | 1150 | if ($globalTransaction) $Connection->db->commit(); |
| 1151 | 1151 | } |
| 1152 | 1152 | return ''; |
| 1153 | - } |
|
| 1153 | + } |
|
| 1154 | 1154 | |
| 1155 | 1155 | public static function owner_fam() { |
| 1156 | 1156 | global $tmp_dir, $globalTransaction; |
@@ -1158,10 +1158,10 @@ discard block |
||
| 1158 | 1158 | try { |
| 1159 | 1159 | $Connection = new Connection(); |
| 1160 | 1160 | $sth = $Connection->db->prepare($query); |
| 1161 | - $sth->execute(array(':source' => 'website_fam')); |
|
| 1162 | - } catch(PDOException $e) { |
|
| 1163 | - return "error : ".$e->getMessage(); |
|
| 1164 | - } |
|
| 1161 | + $sth->execute(array(':source' => 'website_fam')); |
|
| 1162 | + } catch(PDOException $e) { |
|
| 1163 | + return "error : ".$e->getMessage(); |
|
| 1164 | + } |
|
| 1165 | 1165 | |
| 1166 | 1166 | $delimiter = "\t"; |
| 1167 | 1167 | $Connection = new Connection(); |
@@ -1187,7 +1187,7 @@ discard block |
||
| 1187 | 1187 | if ($globalTransaction) $Connection->db->commit(); |
| 1188 | 1188 | } |
| 1189 | 1189 | return ''; |
| 1190 | - } |
|
| 1190 | + } |
|
| 1191 | 1191 | |
| 1192 | 1192 | public static function routes_fam() { |
| 1193 | 1193 | global $tmp_dir, $globalTransaction, $globalDebug; |
@@ -1222,7 +1222,7 @@ discard block |
||
| 1222 | 1222 | if ($globalTransaction) $Connection->db->commit(); |
| 1223 | 1223 | } |
| 1224 | 1224 | return ''; |
| 1225 | - } |
|
| 1225 | + } |
|
| 1226 | 1226 | |
| 1227 | 1227 | public static function marine_identity_fam() { |
| 1228 | 1228 | global $tmp_dir, $globalTransaction; |
@@ -1230,10 +1230,10 @@ discard block |
||
| 1230 | 1230 | try { |
| 1231 | 1231 | $Connection = new Connection(); |
| 1232 | 1232 | $sth = $Connection->db->prepare($query); |
| 1233 | - $sth->execute(); |
|
| 1234 | - } catch(PDOException $e) { |
|
| 1235 | - return "error : ".$e->getMessage(); |
|
| 1236 | - } |
|
| 1233 | + $sth->execute(); |
|
| 1234 | + } catch(PDOException $e) { |
|
| 1235 | + return "error : ".$e->getMessage(); |
|
| 1236 | + } |
|
| 1237 | 1237 | |
| 1238 | 1238 | |
| 1239 | 1239 | //update_db::unzip($out_file); |
@@ -1263,7 +1263,7 @@ discard block |
||
| 1263 | 1263 | if ($globalTransaction) $Connection->db->commit(); |
| 1264 | 1264 | } |
| 1265 | 1265 | return ''; |
| 1266 | - } |
|
| 1266 | + } |
|
| 1267 | 1267 | |
| 1268 | 1268 | public static function banned_fam() { |
| 1269 | 1269 | global $tmp_dir, $globalTransaction; |
@@ -1297,7 +1297,7 @@ discard block |
||
| 1297 | 1297 | if ($globalTransaction) $Connection->db->commit(); |
| 1298 | 1298 | } |
| 1299 | 1299 | return ''; |
| 1300 | - } |
|
| 1300 | + } |
|
| 1301 | 1301 | |
| 1302 | 1302 | public static function tle($filename,$tletype) { |
| 1303 | 1303 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1308,10 +1308,10 @@ discard block |
||
| 1308 | 1308 | try { |
| 1309 | 1309 | $Connection = new Connection(); |
| 1310 | 1310 | $sth = $Connection->db->prepare($query); |
| 1311 | - $sth->execute(array(':source' => $filename)); |
|
| 1312 | - } catch(PDOException $e) { |
|
| 1313 | - return "error : ".$e->getMessage(); |
|
| 1314 | - } |
|
| 1311 | + $sth->execute(array(':source' => $filename)); |
|
| 1312 | + } catch(PDOException $e) { |
|
| 1313 | + return "error : ".$e->getMessage(); |
|
| 1314 | + } |
|
| 1315 | 1315 | |
| 1316 | 1316 | $Connection = new Connection(); |
| 1317 | 1317 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -1346,54 +1346,54 @@ discard block |
||
| 1346 | 1346 | //$Connection->db->commit(); |
| 1347 | 1347 | } |
| 1348 | 1348 | return ''; |
| 1349 | - } |
|
| 1349 | + } |
|
| 1350 | 1350 | |
| 1351 | 1351 | /** |
| 1352 | - * Convert a HTML table to an array |
|
| 1353 | - * @param String $data HTML page |
|
| 1354 | - * @return Array array of the tables in HTML page |
|
| 1355 | - */ |
|
| 1356 | - private static function table2array($data) { |
|
| 1357 | - $html = str_get_html($data); |
|
| 1358 | - $tabledata=array(); |
|
| 1359 | - foreach($html->find('tr') as $element) |
|
| 1360 | - { |
|
| 1361 | - $td = array(); |
|
| 1362 | - foreach( $element->find('th') as $row) |
|
| 1363 | - { |
|
| 1364 | - $td [] = trim($row->plaintext); |
|
| 1365 | - } |
|
| 1366 | - $td=array_filter($td); |
|
| 1367 | - $tabledata[] = $td; |
|
| 1368 | - |
|
| 1369 | - $td = array(); |
|
| 1370 | - $tdi = array(); |
|
| 1371 | - foreach( $element->find('td') as $row) |
|
| 1372 | - { |
|
| 1373 | - $td [] = trim($row->plaintext); |
|
| 1374 | - $tdi [] = trim($row->innertext); |
|
| 1375 | - } |
|
| 1376 | - $td=array_filter($td); |
|
| 1377 | - $tdi=array_filter($tdi); |
|
| 1378 | - // $tabledata[]=array_merge($td,$tdi); |
|
| 1379 | - $tabledata[]=$td; |
|
| 1380 | - } |
|
| 1381 | - return(array_filter($tabledata)); |
|
| 1382 | - } |
|
| 1383 | - |
|
| 1384 | - /** |
|
| 1385 | - * Get data from form result |
|
| 1386 | - * @param String $url form URL |
|
| 1387 | - * @return String the result |
|
| 1388 | - */ |
|
| 1389 | - private static function getData($url) { |
|
| 1390 | - $ch = curl_init(); |
|
| 1391 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
| 1392 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 1393 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 1394 | - 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'); |
|
| 1395 | - return curl_exec($ch); |
|
| 1396 | - } |
|
| 1352 | + * Convert a HTML table to an array |
|
| 1353 | + * @param String $data HTML page |
|
| 1354 | + * @return Array array of the tables in HTML page |
|
| 1355 | + */ |
|
| 1356 | + private static function table2array($data) { |
|
| 1357 | + $html = str_get_html($data); |
|
| 1358 | + $tabledata=array(); |
|
| 1359 | + foreach($html->find('tr') as $element) |
|
| 1360 | + { |
|
| 1361 | + $td = array(); |
|
| 1362 | + foreach( $element->find('th') as $row) |
|
| 1363 | + { |
|
| 1364 | + $td [] = trim($row->plaintext); |
|
| 1365 | + } |
|
| 1366 | + $td=array_filter($td); |
|
| 1367 | + $tabledata[] = $td; |
|
| 1368 | + |
|
| 1369 | + $td = array(); |
|
| 1370 | + $tdi = array(); |
|
| 1371 | + foreach( $element->find('td') as $row) |
|
| 1372 | + { |
|
| 1373 | + $td [] = trim($row->plaintext); |
|
| 1374 | + $tdi [] = trim($row->innertext); |
|
| 1375 | + } |
|
| 1376 | + $td=array_filter($td); |
|
| 1377 | + $tdi=array_filter($tdi); |
|
| 1378 | + // $tabledata[]=array_merge($td,$tdi); |
|
| 1379 | + $tabledata[]=$td; |
|
| 1380 | + } |
|
| 1381 | + return(array_filter($tabledata)); |
|
| 1382 | + } |
|
| 1383 | + |
|
| 1384 | + /** |
|
| 1385 | + * Get data from form result |
|
| 1386 | + * @param String $url form URL |
|
| 1387 | + * @return String the result |
|
| 1388 | + */ |
|
| 1389 | + private static function getData($url) { |
|
| 1390 | + $ch = curl_init(); |
|
| 1391 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 1392 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 1393 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 1394 | + 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'); |
|
| 1395 | + return curl_exec($ch); |
|
| 1396 | + } |
|
| 1397 | 1397 | /* |
| 1398 | 1398 | public static function waypoints() { |
| 1399 | 1399 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -1476,7 +1476,7 @@ discard block |
||
| 1476 | 1476 | if ($globalTransaction) $Connection->db->commit(); |
| 1477 | 1477 | } |
| 1478 | 1478 | return ''; |
| 1479 | - } |
|
| 1479 | + } |
|
| 1480 | 1480 | |
| 1481 | 1481 | public static function ivao_airlines($filename) { |
| 1482 | 1482 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1486,10 +1486,10 @@ discard block |
||
| 1486 | 1486 | try { |
| 1487 | 1487 | $Connection = new Connection(); |
| 1488 | 1488 | $sth = $Connection->db->prepare($query); |
| 1489 | - $sth->execute(); |
|
| 1490 | - } catch(PDOException $e) { |
|
| 1491 | - return "error : ".$e->getMessage(); |
|
| 1492 | - } |
|
| 1489 | + $sth->execute(); |
|
| 1490 | + } catch(PDOException $e) { |
|
| 1491 | + return "error : ".$e->getMessage(); |
|
| 1492 | + } |
|
| 1493 | 1493 | |
| 1494 | 1494 | $header = NULL; |
| 1495 | 1495 | $delimiter = ':'; |
@@ -1513,7 +1513,7 @@ discard block |
||
| 1513 | 1513 | if ($globalTransaction) $Connection->db->commit(); |
| 1514 | 1514 | } |
| 1515 | 1515 | return ''; |
| 1516 | - } |
|
| 1516 | + } |
|
| 1517 | 1517 | |
| 1518 | 1518 | public static function update_airspace() { |
| 1519 | 1519 | global $tmp_dir, $globalDBdriver; |
@@ -1523,11 +1523,11 @@ discard block |
||
| 1523 | 1523 | $query = 'DROP TABLE airspace'; |
| 1524 | 1524 | try { |
| 1525 | 1525 | $sth = $Connection->db->prepare($query); |
| 1526 | - $sth->execute(); |
|
| 1527 | - } catch(PDOException $e) { |
|
| 1526 | + $sth->execute(); |
|
| 1527 | + } catch(PDOException $e) { |
|
| 1528 | 1528 | return "error : ".$e->getMessage(); |
| 1529 | - } |
|
| 1530 | - } |
|
| 1529 | + } |
|
| 1530 | + } |
|
| 1531 | 1531 | |
| 1532 | 1532 | |
| 1533 | 1533 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1582,10 +1582,10 @@ discard block |
||
| 1582 | 1582 | $query = 'DROP TABLE countries'; |
| 1583 | 1583 | try { |
| 1584 | 1584 | $sth = $Connection->db->prepare($query); |
| 1585 | - $sth->execute(); |
|
| 1586 | - } catch(PDOException $e) { |
|
| 1587 | - echo "error : ".$e->getMessage(); |
|
| 1588 | - } |
|
| 1585 | + $sth->execute(); |
|
| 1586 | + } catch(PDOException $e) { |
|
| 1587 | + echo "error : ".$e->getMessage(); |
|
| 1588 | + } |
|
| 1589 | 1589 | } |
| 1590 | 1590 | if ($globalDBdriver == 'mysql') { |
| 1591 | 1591 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -2114,11 +2114,11 @@ discard block |
||
| 2114 | 2114 | $query = 'DROP TABLE airspace'; |
| 2115 | 2115 | try { |
| 2116 | 2116 | $sth = $Connection->db->prepare($query); |
| 2117 | - $sth->execute(); |
|
| 2118 | - } catch(PDOException $e) { |
|
| 2117 | + $sth->execute(); |
|
| 2118 | + } catch(PDOException $e) { |
|
| 2119 | 2119 | return "error : ".$e->getMessage(); |
| 2120 | - } |
|
| 2121 | - } |
|
| 2120 | + } |
|
| 2121 | + } |
|
| 2122 | 2122 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 2123 | 2123 | update_db::insert_airspace_version($airspace_md5); |
| 2124 | 2124 | } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
@@ -2300,12 +2300,12 @@ discard block |
||
| 2300 | 2300 | echo $data; |
| 2301 | 2301 | */ |
| 2302 | 2302 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 2303 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 2304 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 2305 | - $result = fread($fh,100000000); |
|
| 2306 | - //echo $result; |
|
| 2307 | - //var_dump(str_get_html($result)); |
|
| 2308 | - //print_r(self::table2array($result)); |
|
| 2303 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 2304 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 2305 | + $result = fread($fh,100000000); |
|
| 2306 | + //echo $result; |
|
| 2307 | + //var_dump(str_get_html($result)); |
|
| 2308 | + //print_r(self::table2array($result)); |
|
| 2309 | 2309 | } |
| 2310 | 2310 | |
| 2311 | 2311 | } |
@@ -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 | $error = ''; |
| 2328 | 2328 | if ($globalDebug) echo "Notam : Download..."; |
@@ -2378,8 +2378,8 @@ discard block |
||
| 2378 | 2378 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
| 2379 | 2379 | $data['permanent'] = 0; |
| 2380 | 2380 | } else { |
| 2381 | - $data['date_end'] = NULL; |
|
| 2382 | - $data['permanent'] = 1; |
|
| 2381 | + $data['date_end'] = NULL; |
|
| 2382 | + $data['permanent'] = 1; |
|
| 2383 | 2383 | } |
| 2384 | 2384 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 2385 | 2385 | $NOTAM = new NOTAM(); |
@@ -2453,13 +2453,13 @@ discard block |
||
| 2453 | 2453 | try { |
| 2454 | 2454 | $Connection = new Connection(); |
| 2455 | 2455 | $sth = $Connection->db->prepare($query); |
| 2456 | - $sth->execute(); |
|
| 2457 | - } catch(PDOException $e) { |
|
| 2458 | - return "error : ".$e->getMessage(); |
|
| 2459 | - } |
|
| 2460 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2461 | - if ($row['nb'] > 0) return false; |
|
| 2462 | - else return true; |
|
| 2456 | + $sth->execute(); |
|
| 2457 | + } catch(PDOException $e) { |
|
| 2458 | + return "error : ".$e->getMessage(); |
|
| 2459 | + } |
|
| 2460 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2461 | + if ($row['nb'] > 0) return false; |
|
| 2462 | + else return true; |
|
| 2463 | 2463 | } |
| 2464 | 2464 | |
| 2465 | 2465 | public static function insert_last_update() { |
@@ -2468,10 +2468,10 @@ discard block |
||
| 2468 | 2468 | try { |
| 2469 | 2469 | $Connection = new Connection(); |
| 2470 | 2470 | $sth = $Connection->db->prepare($query); |
| 2471 | - $sth->execute(); |
|
| 2472 | - } catch(PDOException $e) { |
|
| 2473 | - return "error : ".$e->getMessage(); |
|
| 2474 | - } |
|
| 2471 | + $sth->execute(); |
|
| 2472 | + } catch(PDOException $e) { |
|
| 2473 | + return "error : ".$e->getMessage(); |
|
| 2474 | + } |
|
| 2475 | 2475 | } |
| 2476 | 2476 | |
| 2477 | 2477 | public static function check_airspace_version($version) { |
@@ -2479,13 +2479,13 @@ discard block |
||
| 2479 | 2479 | try { |
| 2480 | 2480 | $Connection = new Connection(); |
| 2481 | 2481 | $sth = $Connection->db->prepare($query); |
| 2482 | - $sth->execute(array(':version' => $version)); |
|
| 2483 | - } catch(PDOException $e) { |
|
| 2484 | - return "error : ".$e->getMessage(); |
|
| 2485 | - } |
|
| 2486 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2487 | - if ($row['nb'] > 0) return true; |
|
| 2488 | - else return false; |
|
| 2482 | + $sth->execute(array(':version' => $version)); |
|
| 2483 | + } catch(PDOException $e) { |
|
| 2484 | + return "error : ".$e->getMessage(); |
|
| 2485 | + } |
|
| 2486 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2487 | + if ($row['nb'] > 0) return true; |
|
| 2488 | + else return false; |
|
| 2489 | 2489 | } |
| 2490 | 2490 | |
| 2491 | 2491 | public static function check_geoid_version($version) { |
@@ -2493,13 +2493,13 @@ discard block |
||
| 2493 | 2493 | try { |
| 2494 | 2494 | $Connection = new Connection(); |
| 2495 | 2495 | $sth = $Connection->db->prepare($query); |
| 2496 | - $sth->execute(array(':version' => $version)); |
|
| 2497 | - } catch(PDOException $e) { |
|
| 2498 | - return "error : ".$e->getMessage(); |
|
| 2499 | - } |
|
| 2500 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2501 | - if ($row['nb'] > 0) return true; |
|
| 2502 | - else return false; |
|
| 2496 | + $sth->execute(array(':version' => $version)); |
|
| 2497 | + } catch(PDOException $e) { |
|
| 2498 | + return "error : ".$e->getMessage(); |
|
| 2499 | + } |
|
| 2500 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2501 | + if ($row['nb'] > 0) return true; |
|
| 2502 | + else return false; |
|
| 2503 | 2503 | } |
| 2504 | 2504 | |
| 2505 | 2505 | public static function check_marine_identity_version($version) { |
@@ -2507,13 +2507,13 @@ discard block |
||
| 2507 | 2507 | try { |
| 2508 | 2508 | $Connection = new Connection(); |
| 2509 | 2509 | $sth = $Connection->db->prepare($query); |
| 2510 | - $sth->execute(array(':version' => $version)); |
|
| 2511 | - } catch(PDOException $e) { |
|
| 2512 | - return "error : ".$e->getMessage(); |
|
| 2513 | - } |
|
| 2514 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2515 | - if ($row['nb'] > 0) return true; |
|
| 2516 | - else return false; |
|
| 2510 | + $sth->execute(array(':version' => $version)); |
|
| 2511 | + } catch(PDOException $e) { |
|
| 2512 | + return "error : ".$e->getMessage(); |
|
| 2513 | + } |
|
| 2514 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2515 | + if ($row['nb'] > 0) return true; |
|
| 2516 | + else return false; |
|
| 2517 | 2517 | } |
| 2518 | 2518 | |
| 2519 | 2519 | |
@@ -2535,10 +2535,10 @@ discard block |
||
| 2535 | 2535 | try { |
| 2536 | 2536 | $Connection = new Connection(); |
| 2537 | 2537 | $sth = $Connection->db->prepare($query); |
| 2538 | - $sth->execute(array(':version' => $version)); |
|
| 2539 | - } catch(PDOException $e) { |
|
| 2540 | - return "error : ".$e->getMessage(); |
|
| 2541 | - } |
|
| 2538 | + $sth->execute(array(':version' => $version)); |
|
| 2539 | + } catch(PDOException $e) { |
|
| 2540 | + return "error : ".$e->getMessage(); |
|
| 2541 | + } |
|
| 2542 | 2542 | } |
| 2543 | 2543 | |
| 2544 | 2544 | public static function insert_marine_identity_version($version) { |
@@ -2547,10 +2547,10 @@ discard block |
||
| 2547 | 2547 | try { |
| 2548 | 2548 | $Connection = new Connection(); |
| 2549 | 2549 | $sth = $Connection->db->prepare($query); |
| 2550 | - $sth->execute(array(':version' => $version)); |
|
| 2551 | - } catch(PDOException $e) { |
|
| 2552 | - return "error : ".$e->getMessage(); |
|
| 2553 | - } |
|
| 2550 | + $sth->execute(array(':version' => $version)); |
|
| 2551 | + } catch(PDOException $e) { |
|
| 2552 | + return "error : ".$e->getMessage(); |
|
| 2553 | + } |
|
| 2554 | 2554 | } |
| 2555 | 2555 | |
| 2556 | 2556 | public static function check_last_notam_update() { |
@@ -2563,13 +2563,13 @@ discard block |
||
| 2563 | 2563 | try { |
| 2564 | 2564 | $Connection = new Connection(); |
| 2565 | 2565 | $sth = $Connection->db->prepare($query); |
| 2566 | - $sth->execute(); |
|
| 2567 | - } catch(PDOException $e) { |
|
| 2568 | - return "error : ".$e->getMessage(); |
|
| 2569 | - } |
|
| 2570 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2571 | - if ($row['nb'] > 0) return false; |
|
| 2572 | - else return true; |
|
| 2566 | + $sth->execute(); |
|
| 2567 | + } catch(PDOException $e) { |
|
| 2568 | + return "error : ".$e->getMessage(); |
|
| 2569 | + } |
|
| 2570 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2571 | + if ($row['nb'] > 0) return false; |
|
| 2572 | + else return true; |
|
| 2573 | 2573 | } |
| 2574 | 2574 | |
| 2575 | 2575 | public static function insert_last_notam_update() { |
@@ -2578,10 +2578,10 @@ discard block |
||
| 2578 | 2578 | try { |
| 2579 | 2579 | $Connection = new Connection(); |
| 2580 | 2580 | $sth = $Connection->db->prepare($query); |
| 2581 | - $sth->execute(); |
|
| 2582 | - } catch(PDOException $e) { |
|
| 2583 | - return "error : ".$e->getMessage(); |
|
| 2584 | - } |
|
| 2581 | + $sth->execute(); |
|
| 2582 | + } catch(PDOException $e) { |
|
| 2583 | + return "error : ".$e->getMessage(); |
|
| 2584 | + } |
|
| 2585 | 2585 | } |
| 2586 | 2586 | |
| 2587 | 2587 | public static function check_last_airspace_update() { |
@@ -2594,13 +2594,13 @@ discard block |
||
| 2594 | 2594 | try { |
| 2595 | 2595 | $Connection = new Connection(); |
| 2596 | 2596 | $sth = $Connection->db->prepare($query); |
| 2597 | - $sth->execute(); |
|
| 2598 | - } catch(PDOException $e) { |
|
| 2599 | - return "error : ".$e->getMessage(); |
|
| 2600 | - } |
|
| 2601 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2602 | - if ($row['nb'] > 0) return false; |
|
| 2603 | - else return true; |
|
| 2597 | + $sth->execute(); |
|
| 2598 | + } catch(PDOException $e) { |
|
| 2599 | + return "error : ".$e->getMessage(); |
|
| 2600 | + } |
|
| 2601 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2602 | + if ($row['nb'] > 0) return false; |
|
| 2603 | + else return true; |
|
| 2604 | 2604 | } |
| 2605 | 2605 | |
| 2606 | 2606 | public static function insert_last_airspace_update() { |
@@ -2609,10 +2609,10 @@ discard block |
||
| 2609 | 2609 | try { |
| 2610 | 2610 | $Connection = new Connection(); |
| 2611 | 2611 | $sth = $Connection->db->prepare($query); |
| 2612 | - $sth->execute(); |
|
| 2613 | - } catch(PDOException $e) { |
|
| 2614 | - return "error : ".$e->getMessage(); |
|
| 2615 | - } |
|
| 2612 | + $sth->execute(); |
|
| 2613 | + } catch(PDOException $e) { |
|
| 2614 | + return "error : ".$e->getMessage(); |
|
| 2615 | + } |
|
| 2616 | 2616 | } |
| 2617 | 2617 | |
| 2618 | 2618 | public static function check_last_geoid_update() { |
@@ -2625,13 +2625,13 @@ discard block |
||
| 2625 | 2625 | try { |
| 2626 | 2626 | $Connection = new Connection(); |
| 2627 | 2627 | $sth = $Connection->db->prepare($query); |
| 2628 | - $sth->execute(); |
|
| 2629 | - } catch(PDOException $e) { |
|
| 2630 | - return "error : ".$e->getMessage(); |
|
| 2631 | - } |
|
| 2632 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2633 | - if ($row['nb'] > 0) return false; |
|
| 2634 | - else return true; |
|
| 2628 | + $sth->execute(); |
|
| 2629 | + } catch(PDOException $e) { |
|
| 2630 | + return "error : ".$e->getMessage(); |
|
| 2631 | + } |
|
| 2632 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2633 | + if ($row['nb'] > 0) return false; |
|
| 2634 | + else return true; |
|
| 2635 | 2635 | } |
| 2636 | 2636 | |
| 2637 | 2637 | public static function insert_last_geoid_update() { |
@@ -2640,10 +2640,10 @@ discard block |
||
| 2640 | 2640 | try { |
| 2641 | 2641 | $Connection = new Connection(); |
| 2642 | 2642 | $sth = $Connection->db->prepare($query); |
| 2643 | - $sth->execute(); |
|
| 2644 | - } catch(PDOException $e) { |
|
| 2645 | - return "error : ".$e->getMessage(); |
|
| 2646 | - } |
|
| 2643 | + $sth->execute(); |
|
| 2644 | + } catch(PDOException $e) { |
|
| 2645 | + return "error : ".$e->getMessage(); |
|
| 2646 | + } |
|
| 2647 | 2647 | } |
| 2648 | 2648 | |
| 2649 | 2649 | public static function check_last_owner_update() { |
@@ -2656,13 +2656,13 @@ discard block |
||
| 2656 | 2656 | try { |
| 2657 | 2657 | $Connection = new Connection(); |
| 2658 | 2658 | $sth = $Connection->db->prepare($query); |
| 2659 | - $sth->execute(); |
|
| 2660 | - } catch(PDOException $e) { |
|
| 2661 | - return "error : ".$e->getMessage(); |
|
| 2662 | - } |
|
| 2663 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2664 | - if ($row['nb'] > 0) return false; |
|
| 2665 | - else return true; |
|
| 2659 | + $sth->execute(); |
|
| 2660 | + } catch(PDOException $e) { |
|
| 2661 | + return "error : ".$e->getMessage(); |
|
| 2662 | + } |
|
| 2663 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2664 | + if ($row['nb'] > 0) return false; |
|
| 2665 | + else return true; |
|
| 2666 | 2666 | } |
| 2667 | 2667 | |
| 2668 | 2668 | public static function insert_last_owner_update() { |
@@ -2671,10 +2671,10 @@ discard block |
||
| 2671 | 2671 | try { |
| 2672 | 2672 | $Connection = new Connection(); |
| 2673 | 2673 | $sth = $Connection->db->prepare($query); |
| 2674 | - $sth->execute(); |
|
| 2675 | - } catch(PDOException $e) { |
|
| 2676 | - return "error : ".$e->getMessage(); |
|
| 2677 | - } |
|
| 2674 | + $sth->execute(); |
|
| 2675 | + } catch(PDOException $e) { |
|
| 2676 | + return "error : ".$e->getMessage(); |
|
| 2677 | + } |
|
| 2678 | 2678 | } |
| 2679 | 2679 | public static function check_last_schedules_update() { |
| 2680 | 2680 | global $globalDBdriver; |
@@ -2686,13 +2686,13 @@ discard block |
||
| 2686 | 2686 | try { |
| 2687 | 2687 | $Connection = new Connection(); |
| 2688 | 2688 | $sth = $Connection->db->prepare($query); |
| 2689 | - $sth->execute(); |
|
| 2690 | - } catch(PDOException $e) { |
|
| 2691 | - return "error : ".$e->getMessage(); |
|
| 2692 | - } |
|
| 2693 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2694 | - if ($row['nb'] > 0) return false; |
|
| 2695 | - else return true; |
|
| 2689 | + $sth->execute(); |
|
| 2690 | + } catch(PDOException $e) { |
|
| 2691 | + return "error : ".$e->getMessage(); |
|
| 2692 | + } |
|
| 2693 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2694 | + if ($row['nb'] > 0) return false; |
|
| 2695 | + else return true; |
|
| 2696 | 2696 | } |
| 2697 | 2697 | |
| 2698 | 2698 | public static function insert_last_schedules_update() { |
@@ -2701,10 +2701,10 @@ discard block |
||
| 2701 | 2701 | try { |
| 2702 | 2702 | $Connection = new Connection(); |
| 2703 | 2703 | $sth = $Connection->db->prepare($query); |
| 2704 | - $sth->execute(); |
|
| 2705 | - } catch(PDOException $e) { |
|
| 2706 | - return "error : ".$e->getMessage(); |
|
| 2707 | - } |
|
| 2704 | + $sth->execute(); |
|
| 2705 | + } catch(PDOException $e) { |
|
| 2706 | + return "error : ".$e->getMessage(); |
|
| 2707 | + } |
|
| 2708 | 2708 | } |
| 2709 | 2709 | public static function check_last_tle_update() { |
| 2710 | 2710 | global $globalDBdriver; |
@@ -2716,13 +2716,13 @@ discard block |
||
| 2716 | 2716 | try { |
| 2717 | 2717 | $Connection = new Connection(); |
| 2718 | 2718 | $sth = $Connection->db->prepare($query); |
| 2719 | - $sth->execute(); |
|
| 2720 | - } catch(PDOException $e) { |
|
| 2721 | - return "error : ".$e->getMessage(); |
|
| 2722 | - } |
|
| 2723 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2724 | - if ($row['nb'] > 0) return false; |
|
| 2725 | - else return true; |
|
| 2719 | + $sth->execute(); |
|
| 2720 | + } catch(PDOException $e) { |
|
| 2721 | + return "error : ".$e->getMessage(); |
|
| 2722 | + } |
|
| 2723 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2724 | + if ($row['nb'] > 0) return false; |
|
| 2725 | + else return true; |
|
| 2726 | 2726 | } |
| 2727 | 2727 | |
| 2728 | 2728 | public static function insert_last_tle_update() { |
@@ -2731,10 +2731,10 @@ discard block |
||
| 2731 | 2731 | try { |
| 2732 | 2732 | $Connection = new Connection(); |
| 2733 | 2733 | $sth = $Connection->db->prepare($query); |
| 2734 | - $sth->execute(); |
|
| 2735 | - } catch(PDOException $e) { |
|
| 2736 | - return "error : ".$e->getMessage(); |
|
| 2737 | - } |
|
| 2734 | + $sth->execute(); |
|
| 2735 | + } catch(PDOException $e) { |
|
| 2736 | + return "error : ".$e->getMessage(); |
|
| 2737 | + } |
|
| 2738 | 2738 | } |
| 2739 | 2739 | public static function check_last_marine_identity_update() { |
| 2740 | 2740 | global $globalDBdriver; |
@@ -2746,13 +2746,13 @@ discard block |
||
| 2746 | 2746 | try { |
| 2747 | 2747 | $Connection = new Connection(); |
| 2748 | 2748 | $sth = $Connection->db->prepare($query); |
| 2749 | - $sth->execute(); |
|
| 2750 | - } catch(PDOException $e) { |
|
| 2751 | - return "error : ".$e->getMessage(); |
|
| 2752 | - } |
|
| 2753 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2754 | - if ($row['nb'] > 0) return false; |
|
| 2755 | - else return true; |
|
| 2749 | + $sth->execute(); |
|
| 2750 | + } catch(PDOException $e) { |
|
| 2751 | + return "error : ".$e->getMessage(); |
|
| 2752 | + } |
|
| 2753 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2754 | + if ($row['nb'] > 0) return false; |
|
| 2755 | + else return true; |
|
| 2756 | 2756 | } |
| 2757 | 2757 | |
| 2758 | 2758 | public static function insert_last_marine_identity_update() { |
@@ -2761,10 +2761,10 @@ discard block |
||
| 2761 | 2761 | try { |
| 2762 | 2762 | $Connection = new Connection(); |
| 2763 | 2763 | $sth = $Connection->db->prepare($query); |
| 2764 | - $sth->execute(); |
|
| 2765 | - } catch(PDOException $e) { |
|
| 2766 | - return "error : ".$e->getMessage(); |
|
| 2767 | - } |
|
| 2764 | + $sth->execute(); |
|
| 2765 | + } catch(PDOException $e) { |
|
| 2766 | + return "error : ".$e->getMessage(); |
|
| 2767 | + } |
|
| 2768 | 2768 | } |
| 2769 | 2769 | public static function delete_duplicatemodes() { |
| 2770 | 2770 | global $globalDBdriver; |
@@ -2776,10 +2776,10 @@ discard block |
||
| 2776 | 2776 | try { |
| 2777 | 2777 | $Connection = new Connection(); |
| 2778 | 2778 | $sth = $Connection->db->prepare($query); |
| 2779 | - $sth->execute(); |
|
| 2780 | - } catch(PDOException $e) { |
|
| 2781 | - return "error : ".$e->getMessage(); |
|
| 2782 | - } |
|
| 2779 | + $sth->execute(); |
|
| 2780 | + } catch(PDOException $e) { |
|
| 2781 | + return "error : ".$e->getMessage(); |
|
| 2782 | + } |
|
| 2783 | 2783 | } |
| 2784 | 2784 | public static function delete_duplicateowner() { |
| 2785 | 2785 | global $globalDBdriver; |
@@ -2791,10 +2791,10 @@ discard block |
||
| 2791 | 2791 | try { |
| 2792 | 2792 | $Connection = new Connection(); |
| 2793 | 2793 | $sth = $Connection->db->prepare($query); |
| 2794 | - $sth->execute(); |
|
| 2795 | - } catch(PDOException $e) { |
|
| 2796 | - return "error : ".$e->getMessage(); |
|
| 2797 | - } |
|
| 2794 | + $sth->execute(); |
|
| 2795 | + } catch(PDOException $e) { |
|
| 2796 | + return "error : ".$e->getMessage(); |
|
| 2797 | + } |
|
| 2798 | 2798 | } |
| 2799 | 2799 | |
| 2800 | 2800 | public static function update_all() { |
@@ -25,20 +25,20 @@ discard block |
||
| 25 | 25 | fclose($fp); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public static function gunzip($in_file,$out_file_name = '') { |
|
| 28 | + public static function gunzip($in_file, $out_file_name = '') { |
|
| 29 | 29 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 30 | 30 | $buffer_size = 4096; // read 4kb at a time |
| 31 | 31 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
| 32 | 32 | if ($in_file != '' && file_exists($in_file)) { |
| 33 | 33 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 34 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 35 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 34 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
| 35 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
| 36 | 36 | else { |
| 37 | 37 | echo 'gzopen not available'; |
| 38 | 38 | die; |
| 39 | 39 | } |
| 40 | 40 | $out_file = fopen($out_file_name, 'wb'); |
| 41 | - while(!gzeof($file)) { |
|
| 41 | + while (!gzeof($file)) { |
|
| 42 | 42 | fwrite($out_file, gzread($file, $buffer_size)); |
| 43 | 43 | } |
| 44 | 44 | fclose($out_file); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | try { |
| 63 | 63 | self::$db_sqlite = new PDO('sqlite:'.$database); |
| 64 | 64 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 65 | - } catch(PDOException $e) { |
|
| 65 | + } catch (PDOException $e) { |
|
| 66 | 66 | return "error : ".$e->getMessage(); |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | //$Connection = new Connection(); |
| 78 | 78 | $sth = $Connection->db->prepare($query); |
| 79 | 79 | $sth->execute(array(':source' => $database_file)); |
| 80 | - } catch(PDOException $e) { |
|
| 80 | + } catch (PDOException $e) { |
|
| 81 | 81 | return "error : ".$e->getMessage(); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | try { |
| 89 | 89 | $sth = update_db::$db_sqlite->prepare($query); |
| 90 | 90 | $sth->execute(); |
| 91 | - } catch(PDOException $e) { |
|
| 91 | + } catch (PDOException $e) { |
|
| 92 | 92 | return "error : ".$e->getMessage(); |
| 93 | 93 | } |
| 94 | 94 | //$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)'; |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 100 | 100 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 101 | 101 | //$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); |
| 102 | - $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 | + $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); |
|
| 103 | 103 | $sth_dest->execute($query_dest_values); |
| 104 | 104 | } |
| 105 | 105 | if ($globalTransaction) $Connection->db->commit(); |
| 106 | - } catch(PDOException $e) { |
|
| 106 | + } catch (PDOException $e) { |
|
| 107 | 107 | if ($globalTransaction) $Connection->db->rollBack(); |
| 108 | 108 | return "error : ".$e->getMessage(); |
| 109 | 109 | } |
@@ -119,26 +119,26 @@ discard block |
||
| 119 | 119 | //$Connection = new Connection(); |
| 120 | 120 | $sth = $Connection->db->prepare($query); |
| 121 | 121 | $sth->execute(array(':source' => 'oneworld')); |
| 122 | - } catch(PDOException $e) { |
|
| 122 | + } catch (PDOException $e) { |
|
| 123 | 123 | return "error : ".$e->getMessage(); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | if ($globalDebug) echo " - Add routes to DB -"; |
| 127 | 127 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 128 | 128 | $Spotter = new Spotter(); |
| 129 | - if ($fh = fopen($database_file,"r")) { |
|
| 129 | + if ($fh = fopen($database_file, "r")) { |
|
| 130 | 130 | $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)'; |
| 131 | 131 | $Connection = new Connection(); |
| 132 | 132 | $sth_dest = $Connection->db->prepare($query_dest); |
| 133 | 133 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 134 | 134 | while (!feof($fh)) { |
| 135 | - $line = fgetcsv($fh,9999,','); |
|
| 135 | + $line = fgetcsv($fh, 9999, ','); |
|
| 136 | 136 | if ($line[0] != '') { |
| 137 | 137 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
| 138 | 138 | try { |
| 139 | - $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 | + $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'); |
|
| 140 | 140 | $sth_dest->execute($query_dest_values); |
| 141 | - } catch(PDOException $e) { |
|
| 141 | + } catch (PDOException $e) { |
|
| 142 | 142 | if ($globalTransaction) $Connection->db->rollBack(); |
| 143 | 143 | return "error : ".$e->getMessage(); |
| 144 | 144 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | //$Connection = new Connection(); |
| 161 | 161 | $sth = $Connection->db->prepare($query); |
| 162 | 162 | $sth->execute(array(':source' => 'skyteam')); |
| 163 | - } catch(PDOException $e) { |
|
| 163 | + } catch (PDOException $e) { |
|
| 164 | 164 | return "error : ".$e->getMessage(); |
| 165 | 165 | } |
| 166 | 166 | |
@@ -168,24 +168,24 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 170 | 170 | $Spotter = new Spotter(); |
| 171 | - if ($fh = fopen($database_file,"r")) { |
|
| 171 | + if ($fh = fopen($database_file, "r")) { |
|
| 172 | 172 | $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)'; |
| 173 | 173 | $Connection = new Connection(); |
| 174 | 174 | $sth_dest = $Connection->db->prepare($query_dest); |
| 175 | 175 | try { |
| 176 | 176 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 177 | 177 | while (!feof($fh)) { |
| 178 | - $line = fgetcsv($fh,9999,','); |
|
| 178 | + $line = fgetcsv($fh, 9999, ','); |
|
| 179 | 179 | if ($line[0] != '') { |
| 180 | - $datebe = explode(' - ',$line[2]); |
|
| 180 | + $datebe = explode(' - ', $line[2]); |
|
| 181 | 181 | if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
| 182 | - $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 | + $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'); |
|
| 183 | 183 | $sth_dest->execute($query_dest_values); |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | if ($globalTransaction) $Connection->db->commit(); |
| 188 | - } catch(PDOException $e) { |
|
| 188 | + } catch (PDOException $e) { |
|
| 189 | 189 | if ($globalTransaction) $Connection->db->rollBack(); |
| 190 | 190 | return "error : ".$e->getMessage(); |
| 191 | 191 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | $Connection = new Connection(); |
| 201 | 201 | $sth = $Connection->db->prepare($query); |
| 202 | 202 | $sth->execute(array(':source' => $database_file)); |
| 203 | - } catch(PDOException $e) { |
|
| 203 | + } catch (PDOException $e) { |
|
| 204 | 204 | return "error : ".$e->getMessage(); |
| 205 | 205 | } |
| 206 | 206 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $Connection = new Connection(); |
| 209 | 209 | $sth = $Connection->db->prepare($query); |
| 210 | 210 | $sth->execute(array(':source' => $database_file)); |
| 211 | - } catch(PDOException $e) { |
|
| 211 | + } catch (PDOException $e) { |
|
| 212 | 212 | return "error : ".$e->getMessage(); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | try { |
| 218 | 218 | $sth = update_db::$db_sqlite->prepare($query); |
| 219 | 219 | $sth->execute(); |
| 220 | - } catch(PDOException $e) { |
|
| 220 | + } catch (PDOException $e) { |
|
| 221 | 221 | return "error : ".$e->getMessage(); |
| 222 | 222 | } |
| 223 | 223 | //$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)'; |
@@ -234,15 +234,15 @@ discard block |
||
| 234 | 234 | //$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']); |
| 235 | 235 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 236 | 236 | else $type = null; |
| 237 | - $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 | + $query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type); |
|
| 238 | 238 | $sth_dest->execute($query_dest_values); |
| 239 | 239 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 240 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 240 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
| 241 | 241 | $sth_dest_owner->execute($query_dest_owner_values); |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | if ($globalTransaction) $Connection->db->commit(); |
| 245 | - } catch(PDOException $e) { |
|
| 245 | + } catch (PDOException $e) { |
|
| 246 | 246 | return "error : ".$e->getMessage(); |
| 247 | 247 | } |
| 248 | 248 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $Connection = new Connection(); |
| 253 | 253 | $sth = $Connection->db->prepare($query); |
| 254 | 254 | $sth->execute(array(':source' => $database_file)); |
| 255 | - } catch(PDOException $e) { |
|
| 255 | + } catch (PDOException $e) { |
|
| 256 | 256 | return "error : ".$e->getMessage(); |
| 257 | 257 | } |
| 258 | 258 | return ''; |
@@ -267,11 +267,11 @@ discard block |
||
| 267 | 267 | $Connection = new Connection(); |
| 268 | 268 | $sth = $Connection->db->prepare($query); |
| 269 | 269 | $sth->execute(array(':source' => $database_file)); |
| 270 | - } catch(PDOException $e) { |
|
| 270 | + } catch (PDOException $e) { |
|
| 271 | 271 | return "error : ".$e->getMessage(); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if ($fh = fopen($database_file,"r")) { |
|
| 274 | + if ($fh = fopen($database_file, "r")) { |
|
| 275 | 275 | //$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)'; |
| 276 | 276 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
| 277 | 277 | |
@@ -281,13 +281,13 @@ discard block |
||
| 281 | 281 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 282 | 282 | while (!feof($fh)) { |
| 283 | 283 | $values = array(); |
| 284 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 284 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
| 285 | 285 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 286 | - $values['ModeS'] = substr($line,0,6); |
|
| 287 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 288 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 286 | + $values['ModeS'] = substr($line, 0, 6); |
|
| 287 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
| 288 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
| 289 | 289 | // Check if we can find ICAO, else set it to GLID |
| 290 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 290 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 291 | 291 | $search_more = ''; |
| 292 | 292 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 293 | 293 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -299,20 +299,20 @@ discard block |
||
| 299 | 299 | if (isset($result['icao']) && $result['icao'] != '') { |
| 300 | 300 | $values['ICAOTypeCode'] = $result['icao']; |
| 301 | 301 | } |
| 302 | - } catch(PDOException $e) { |
|
| 302 | + } catch (PDOException $e) { |
|
| 303 | 303 | return "error : ".$e->getMessage(); |
| 304 | 304 | } |
| 305 | 305 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 306 | 306 | // Add data to db |
| 307 | 307 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
| 308 | 308 | //$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']); |
| 309 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
| 309 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
| 310 | 310 | //print_r($query_dest_values); |
| 311 | 311 | $sth_dest->execute($query_dest_values); |
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | if ($globalTransaction) $Connection->db->commit(); |
| 315 | - } catch(PDOException $e) { |
|
| 315 | + } catch (PDOException $e) { |
|
| 316 | 316 | return "error : ".$e->getMessage(); |
| 317 | 317 | } |
| 318 | 318 | } |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | $Connection = new Connection(); |
| 323 | 323 | $sth = $Connection->db->prepare($query); |
| 324 | 324 | $sth->execute(array(':source' => $database_file)); |
| 325 | - } catch(PDOException $e) { |
|
| 325 | + } catch (PDOException $e) { |
|
| 326 | 326 | return "error : ".$e->getMessage(); |
| 327 | 327 | } |
| 328 | 328 | return ''; |
@@ -336,11 +336,11 @@ discard block |
||
| 336 | 336 | $Connection = new Connection(); |
| 337 | 337 | $sth = $Connection->db->prepare($query); |
| 338 | 338 | $sth->execute(array(':source' => $database_file)); |
| 339 | - } catch(PDOException $e) { |
|
| 339 | + } catch (PDOException $e) { |
|
| 340 | 340 | return "error : ".$e->getMessage(); |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if ($fh = fopen($database_file,"r")) { |
|
| 343 | + if ($fh = fopen($database_file, "r")) { |
|
| 344 | 344 | //$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)'; |
| 345 | 345 | $query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)'; |
| 346 | 346 | |
@@ -348,9 +348,9 @@ discard block |
||
| 348 | 348 | $sth_dest = $Connection->db->prepare($query_dest); |
| 349 | 349 | try { |
| 350 | 350 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 351 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
| 351 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
| 352 | 352 | while (!feof($fh)) { |
| 353 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 353 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
| 354 | 354 | |
| 355 | 355 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 356 | 356 | //print_r($line); |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | $values['ICAOTypeCode'] = ''; |
| 360 | 360 | $aircraft_name = $line[2]; |
| 361 | 361 | // Check if we can find ICAO, else set it to GLID |
| 362 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 362 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 363 | 363 | $search_more = ''; |
| 364 | 364 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 365 | 365 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -368,20 +368,20 @@ discard block |
||
| 368 | 368 | $sth_search->execute(); |
| 369 | 369 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 370 | 370 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
| 371 | - } catch(PDOException $e) { |
|
| 371 | + } catch (PDOException $e) { |
|
| 372 | 372 | return "error : ".$e->getMessage(); |
| 373 | 373 | } |
| 374 | 374 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 375 | 375 | // Add data to db |
| 376 | 376 | if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
| 377 | 377 | //$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']); |
| 378 | - $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm'); |
|
| 378 | + $query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm'); |
|
| 379 | 379 | //print_r($query_dest_values); |
| 380 | 380 | $sth_dest->execute($query_dest_values); |
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | if ($globalTransaction) $Connection->db->commit(); |
| 384 | - } catch(PDOException $e) { |
|
| 384 | + } catch (PDOException $e) { |
|
| 385 | 385 | return "error : ".$e->getMessage(); |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -391,13 +391,13 @@ discard block |
||
| 391 | 391 | $Connection = new Connection(); |
| 392 | 392 | $sth = $Connection->db->prepare($query); |
| 393 | 393 | $sth->execute(array(':source' => $database_file)); |
| 394 | - } catch(PDOException $e) { |
|
| 394 | + } catch (PDOException $e) { |
|
| 395 | 395 | return "error : ".$e->getMessage(); |
| 396 | 396 | } |
| 397 | 397 | return ''; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
| 400 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
| 401 | 401 | global $globalTransaction, $globalMasterSource; |
| 402 | 402 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
| 403 | 403 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;"; |
@@ -405,12 +405,12 @@ discard block |
||
| 405 | 405 | $Connection = new Connection(); |
| 406 | 406 | $sth = $Connection->db->prepare($query); |
| 407 | 407 | $sth->execute(array(':source' => $database_file)); |
| 408 | - } catch(PDOException $e) { |
|
| 408 | + } catch (PDOException $e) { |
|
| 409 | 409 | return "error : ".$e->getMessage(); |
| 410 | 410 | } |
| 411 | 411 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 412 | 412 | $Spotter = new Spotter(); |
| 413 | - if ($fh = fopen($database_file,"r")) { |
|
| 413 | + if ($fh = fopen($database_file, "r")) { |
|
| 414 | 414 | //$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)'; |
| 415 | 415 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 416 | 416 | $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)'; |
@@ -420,9 +420,9 @@ discard block |
||
| 420 | 420 | $sth_modes = $Connection->db->prepare($query_modes); |
| 421 | 421 | try { |
| 422 | 422 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 423 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
| 423 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
| 424 | 424 | while (!feof($fh)) { |
| 425 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 425 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
| 426 | 426 | $values = array(); |
| 427 | 427 | //print_r($line); |
| 428 | 428 | if ($country == 'F') { |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | $values['base'] = $line[4]; |
| 431 | 431 | $values['owner'] = $line[5]; |
| 432 | 432 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 433 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 434 | 434 | $values['cancel'] = $line[7]; |
| 435 | 435 | } elseif ($country == 'EI') { |
| 436 | 436 | // TODO : add modeS & reg to aircraft_modes |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | $values['base'] = $line[3]; |
| 439 | 439 | $values['owner'] = $line[2]; |
| 440 | 440 | if ($line[1] == '') $values['date_first_reg'] = null; |
| 441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 441 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
| 442 | 442 | $values['cancel'] = ''; |
| 443 | 443 | $values['modes'] = $line[7]; |
| 444 | 444 | $values['icao'] = $line[8]; |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | $values['base'] = null; |
| 459 | 459 | $values['owner'] = $line[5]; |
| 460 | 460 | if ($line[18] == '') $values['date_first_reg'] = null; |
| 461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 461 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
| 462 | 462 | $values['cancel'] = ''; |
| 463 | 463 | } elseif ($country == 'VH') { |
| 464 | 464 | // TODO : add modeS & reg to aircraft_modes |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | $values['base'] = null; |
| 467 | 467 | $values['owner'] = $line[12]; |
| 468 | 468 | if ($line[28] == '') $values['date_first_reg'] = null; |
| 469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 469 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
| 470 | 470 | |
| 471 | 471 | $values['cancel'] = $line[39]; |
| 472 | 472 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -486,28 +486,28 @@ discard block |
||
| 486 | 486 | $values['base'] = null; |
| 487 | 487 | $values['owner'] = $line[8]; |
| 488 | 488 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 489 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 490 | 490 | $values['cancel'] = ''; |
| 491 | 491 | } elseif ($country == 'PP') { |
| 492 | 492 | $values['registration'] = $line[0]; |
| 493 | 493 | $values['base'] = null; |
| 494 | 494 | $values['owner'] = $line[4]; |
| 495 | 495 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 496 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 497 | 497 | $values['cancel'] = $line[7]; |
| 498 | 498 | } elseif ($country == 'E7') { |
| 499 | 499 | $values['registration'] = $line[0]; |
| 500 | 500 | $values['base'] = null; |
| 501 | 501 | $values['owner'] = $line[4]; |
| 502 | 502 | if ($line[5] == '') $values['date_first_reg'] = null; |
| 503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 503 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
| 504 | 504 | $values['cancel'] = ''; |
| 505 | 505 | } elseif ($country == '8Q') { |
| 506 | 506 | $values['registration'] = $line[0]; |
| 507 | 507 | $values['base'] = null; |
| 508 | 508 | $values['owner'] = $line[3]; |
| 509 | 509 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 510 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 511 | 511 | $values['cancel'] = ''; |
| 512 | 512 | } elseif ($country == 'ZK') { |
| 513 | 513 | $values['registration'] = $line[0]; |
@@ -521,18 +521,18 @@ discard block |
||
| 521 | 521 | $values['registration'] = $line[0]; |
| 522 | 522 | $values['base'] = null; |
| 523 | 523 | $values['owner'] = $line[6]; |
| 524 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 525 | - $values['cancel'] = date("Y-m-d",strtotime($line[8])); |
|
| 524 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
| 525 | + $values['cancel'] = date("Y-m-d", strtotime($line[8])); |
|
| 526 | 526 | $values['modes'] = $line[4]; |
| 527 | 527 | $values['icao'] = $line[10]; |
| 528 | 528 | } elseif ($country == 'OY') { |
| 529 | 529 | $values['registration'] = $line[0]; |
| 530 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[4])); |
|
| 530 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[4])); |
|
| 531 | 531 | $values['modes'] = $line[5]; |
| 532 | 532 | $values['icao'] = $line[6]; |
| 533 | 533 | } elseif ($country == 'PH') { |
| 534 | 534 | $values['registration'] = $line[0]; |
| 535 | - $values['date_first_reg'] = date("Y-m-d",strtotime($line[3])); |
|
| 535 | + $values['date_first_reg'] = date("Y-m-d", strtotime($line[3])); |
|
| 536 | 536 | $values['modes'] = $line[4]; |
| 537 | 537 | $values['icao'] = $line[5]; |
| 538 | 538 | } elseif ($country == 'OM' || $country == 'TF') { |
@@ -543,17 +543,17 @@ discard block |
||
| 543 | 543 | $values['cancel'] = ''; |
| 544 | 544 | } |
| 545 | 545 | if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) { |
| 546 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
| 546 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
| 547 | 547 | $sth_dest->execute($query_dest_values); |
| 548 | 548 | } |
| 549 | 549 | if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') { |
| 550 | 550 | $modescountry = $Spotter->countryFromAircraftRegistration($values['registration']); |
| 551 | - $query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file); |
|
| 551 | + $query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file); |
|
| 552 | 552 | $sth_modes->execute($query_modes_values); |
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | if ($globalTransaction) $Connection->db->commit(); |
| 556 | - } catch(PDOException $e) { |
|
| 556 | + } catch (PDOException $e) { |
|
| 557 | 557 | return "error : ".$e->getMessage(); |
| 558 | 558 | } |
| 559 | 559 | } |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 692 | 692 | |
| 693 | 693 | $i = 0; |
| 694 | - while($row = sparql_fetch_array($result)) |
|
| 694 | + while ($row = sparql_fetch_array($result)) |
|
| 695 | 695 | { |
| 696 | 696 | if ($i >= 1) { |
| 697 | 697 | //print_r($row); |
@@ -711,33 +711,33 @@ discard block |
||
| 711 | 711 | $row['image'] = ''; |
| 712 | 712 | $row['image_thumb'] = ''; |
| 713 | 713 | } else { |
| 714 | - $image = str_replace(' ','_',$row['image']); |
|
| 714 | + $image = str_replace(' ', '_', $row['image']); |
|
| 715 | 715 | $digest = md5($image); |
| 716 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
| 717 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
| 718 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
| 719 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
| 716 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
| 717 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
| 718 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
| 719 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - $country = explode('-',$row['country']); |
|
| 722 | + $country = explode('-', $row['country']); |
|
| 723 | 723 | $row['country'] = $country[0]; |
| 724 | 724 | |
| 725 | 725 | $row['type'] = trim($row['type']); |
| 726 | - 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'])) { |
|
| 726 | + 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'])) { |
|
| 727 | 727 | $row['type'] = 'military'; |
| 728 | 728 | } 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') { |
| 729 | 729 | $row['type'] = 'small_airport'; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
| 733 | - $query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($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']); |
|
| 732 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
| 733 | + $query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($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']); |
|
| 734 | 734 | //print_r($query_dest_values); |
| 735 | 735 | |
| 736 | 736 | if ($row['icao'] != '') { |
| 737 | 737 | try { |
| 738 | 738 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
| 739 | 739 | $sth->execute(array(':icao' => $row['icao'])); |
| 740 | - } catch(PDOException $e) { |
|
| 740 | + } catch (PDOException $e) { |
|
| 741 | 741 | return "error : ".$e->getMessage(); |
| 742 | 742 | } |
| 743 | 743 | if ($sth->fetchColumn() > 0) { |
@@ -745,15 +745,15 @@ discard block |
||
| 745 | 745 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
| 746 | 746 | try { |
| 747 | 747 | $sth = $Connection->db->prepare($query); |
| 748 | - $sth->execute(array(':icao' => $row['icao'],':type' => $row['type'])); |
|
| 749 | - } catch(PDOException $e) { |
|
| 748 | + $sth->execute(array(':icao' => $row['icao'], ':type' => $row['type'])); |
|
| 749 | + } catch (PDOException $e) { |
|
| 750 | 750 | return "error : ".$e->getMessage(); |
| 751 | 751 | } |
| 752 | 752 | echo $row['icao'].' : '.$row['type']."\n"; |
| 753 | 753 | } else { |
| 754 | 754 | try { |
| 755 | 755 | $sth_dest->execute($query_dest_values); |
| 756 | - } catch(PDOException $e) { |
|
| 756 | + } catch (PDOException $e) { |
|
| 757 | 757 | return "error : ".$e->getMessage(); |
| 758 | 758 | } |
| 759 | 759 | } |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | echo "Download data from ourairports.com...\n"; |
| 805 | 805 | $delimiter = ','; |
| 806 | 806 | $out_file = $tmp_dir.'airports.csv'; |
| 807 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
| 807 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
| 808 | 808 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 809 | 809 | echo "Add data from ourairports.com...\n"; |
| 810 | 810 | |
@@ -815,33 +815,33 @@ discard block |
||
| 815 | 815 | //$Connection->db->beginTransaction(); |
| 816 | 816 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 817 | 817 | { |
| 818 | - if(!$header) $header = $row; |
|
| 818 | + if (!$header) $header = $row; |
|
| 819 | 819 | else { |
| 820 | 820 | $data = array(); |
| 821 | 821 | $data = array_combine($header, $row); |
| 822 | 822 | try { |
| 823 | 823 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao'); |
| 824 | 824 | $sth->execute(array(':icao' => $data['ident'])); |
| 825 | - } catch(PDOException $e) { |
|
| 825 | + } catch (PDOException $e) { |
|
| 826 | 826 | return "error : ".$e->getMessage(); |
| 827 | 827 | } |
| 828 | 828 | if ($sth->fetchColumn() > 0) { |
| 829 | 829 | $query = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
| 830 | 830 | try { |
| 831 | 831 | $sth = $Connection->db->prepare($query); |
| 832 | - $sth->execute(array(':icao' => $data['ident'],':type' => $data['type'])); |
|
| 833 | - } catch(PDOException $e) { |
|
| 832 | + $sth->execute(array(':icao' => $data['ident'], ':type' => $data['type'])); |
|
| 833 | + } catch (PDOException $e) { |
|
| 834 | 834 | return "error : ".$e->getMessage(); |
| 835 | 835 | } |
| 836 | 836 | } else { |
| 837 | 837 | if ($data['gps_code'] == $data['ident']) { |
| 838 | 838 | $query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link) |
| 839 | 839 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
| 840 | - $query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
| 840 | + $query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
| 841 | 841 | try { |
| 842 | 842 | $sth = $Connection->db->prepare($query); |
| 843 | 843 | $sth->execute($query_values); |
| 844 | - } catch(PDOException $e) { |
|
| 844 | + } catch (PDOException $e) { |
|
| 845 | 845 | return "error : ".$e->getMessage(); |
| 846 | 846 | } |
| 847 | 847 | $i++; |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | |
| 857 | 857 | echo "Download data from another free database...\n"; |
| 858 | 858 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 859 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
| 859 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
| 860 | 860 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 861 | 861 | update_db::unzip($out_file); |
| 862 | 862 | $header = NULL; |
@@ -868,15 +868,15 @@ discard block |
||
| 868 | 868 | //$Connection->db->beginTransaction(); |
| 869 | 869 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 870 | 870 | { |
| 871 | - if(!$header) $header = $row; |
|
| 871 | + if (!$header) $header = $row; |
|
| 872 | 872 | else { |
| 873 | 873 | $data = $row; |
| 874 | 874 | |
| 875 | 875 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
| 876 | 876 | try { |
| 877 | 877 | $sth = $Connection->db->prepare($query); |
| 878 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
| 879 | - } catch(PDOException $e) { |
|
| 878 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
| 879 | + } catch (PDOException $e) { |
|
| 880 | 880 | return "error : ".$e->getMessage(); |
| 881 | 881 | } |
| 882 | 882 | } |
@@ -890,15 +890,15 @@ discard block |
||
| 890 | 890 | try { |
| 891 | 891 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'"); |
| 892 | 892 | $sth->execute(); |
| 893 | - } catch(PDOException $e) { |
|
| 893 | + } catch (PDOException $e) { |
|
| 894 | 894 | return "error : ".$e->getMessage(); |
| 895 | 895 | } |
| 896 | 896 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 897 | 897 | $query2 = 'UPDATE airport SET type = :type WHERE icao = :icao'; |
| 898 | 898 | try { |
| 899 | 899 | $sth2 = $Connection->db->prepare($query2); |
| 900 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
| 901 | - } catch(PDOException $e) { |
|
| 900 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
| 901 | + } catch (PDOException $e) { |
|
| 902 | 902 | return "error : ".$e->getMessage(); |
| 903 | 903 | } |
| 904 | 904 | } |
@@ -919,7 +919,7 @@ discard block |
||
| 919 | 919 | $Connection = new Connection(); |
| 920 | 920 | $sth = $Connection->db->prepare($query); |
| 921 | 921 | $sth->execute(array(':source' => 'translation.csv')); |
| 922 | - } catch(PDOException $e) { |
|
| 922 | + } catch (PDOException $e) { |
|
| 923 | 923 | return "error : ".$e->getMessage(); |
| 924 | 924 | } |
| 925 | 925 | |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 937 | 937 | { |
| 938 | 938 | $i++; |
| 939 | - if($i > 12) { |
|
| 939 | + if ($i > 12) { |
|
| 940 | 940 | $data = $row; |
| 941 | 941 | $operator = $data[2]; |
| 942 | 942 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | //echo substr($operator, 0, 2)."\n";; |
| 945 | 945 | if (count($airline_array) > 0) { |
| 946 | 946 | //print_r($airline_array); |
| 947 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
| 947 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
| 948 | 948 | } |
| 949 | 949 | } |
| 950 | 950 | |
@@ -952,14 +952,14 @@ discard block |
||
| 952 | 952 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 953 | 953 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
| 954 | 954 | if (count($airline_array) > 0) { |
| 955 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 955 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
| 956 | 956 | } |
| 957 | 957 | } |
| 958 | 958 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 959 | 959 | try { |
| 960 | 960 | $sth = $Connection->db->prepare($query); |
| 961 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 962 | - } catch(PDOException $e) { |
|
| 961 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 962 | + } catch (PDOException $e) { |
|
| 963 | 963 | return "error : ".$e->getMessage(); |
| 964 | 964 | } |
| 965 | 965 | } |
@@ -979,7 +979,7 @@ discard block |
||
| 979 | 979 | $Connection = new Connection(); |
| 980 | 980 | $sth = $Connection->db->prepare($query); |
| 981 | 981 | $sth->execute(array(':source' => 'website_fam')); |
| 982 | - } catch(PDOException $e) { |
|
| 982 | + } catch (PDOException $e) { |
|
| 983 | 983 | return "error : ".$e->getMessage(); |
| 984 | 984 | } |
| 985 | 985 | |
@@ -999,8 +999,8 @@ discard block |
||
| 999 | 999 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 1000 | 1000 | try { |
| 1001 | 1001 | $sth = $Connection->db->prepare($query); |
| 1002 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 1003 | - } catch(PDOException $e) { |
|
| 1002 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 1003 | + } catch (PDOException $e) { |
|
| 1004 | 1004 | return "error : ".$e->getMessage(); |
| 1005 | 1005 | } |
| 1006 | 1006 | } |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | $Connection = new Connection(); |
| 1024 | 1024 | $sth = $Connection->db->prepare($query); |
| 1025 | 1025 | $sth->execute(array(':source' => 'website_faa')); |
| 1026 | - } catch(PDOException $e) { |
|
| 1026 | + } catch (PDOException $e) { |
|
| 1027 | 1027 | return "error : ".$e->getMessage(); |
| 1028 | 1028 | } |
| 1029 | 1029 | |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | $Connection = new Connection(); |
| 1033 | 1033 | $sth = $Connection->db->prepare($query); |
| 1034 | 1034 | $sth->execute(array(':source' => 'website_faa')); |
| 1035 | - } catch(PDOException $e) { |
|
| 1035 | + } catch (PDOException $e) { |
|
| 1036 | 1036 | return "error : ".$e->getMessage(); |
| 1037 | 1037 | } |
| 1038 | 1038 | |
@@ -1049,8 +1049,8 @@ discard block |
||
| 1049 | 1049 | $query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1'; |
| 1050 | 1050 | try { |
| 1051 | 1051 | $sths = $Connection->db->prepare($query_search); |
| 1052 | - $sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa')); |
|
| 1053 | - } catch(PDOException $e) { |
|
| 1052 | + $sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa')); |
|
| 1053 | + } catch (PDOException $e) { |
|
| 1054 | 1054 | return "error s : ".$e->getMessage(); |
| 1055 | 1055 | } |
| 1056 | 1056 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
@@ -1063,8 +1063,8 @@ discard block |
||
| 1063 | 1063 | //} |
| 1064 | 1064 | try { |
| 1065 | 1065 | $sthi = $Connection->db->prepare($queryi); |
| 1066 | - $sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode'])); |
|
| 1067 | - } catch(PDOException $e) { |
|
| 1066 | + $sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode'])); |
|
| 1067 | + } catch (PDOException $e) { |
|
| 1068 | 1068 | return "error u : ".$e->getMessage(); |
| 1069 | 1069 | } |
| 1070 | 1070 | } else { |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | try { |
| 1073 | 1073 | $sthsm = $Connection->db->prepare($query_search_mfr); |
| 1074 | 1074 | $sthsm->execute(array(':mfr' => $data[2])); |
| 1075 | - } catch(PDOException $e) { |
|
| 1075 | + } catch (PDOException $e) { |
|
| 1076 | 1076 | return "error mfr : ".$e->getMessage(); |
| 1077 | 1077 | } |
| 1078 | 1078 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
@@ -1082,8 +1082,8 @@ discard block |
||
| 1082 | 1082 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
| 1083 | 1083 | try { |
| 1084 | 1084 | $sthf = $Connection->db->prepare($queryf); |
| 1085 | - $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')); |
|
| 1086 | - } catch(PDOException $e) { |
|
| 1085 | + $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')); |
|
| 1086 | + } catch (PDOException $e) { |
|
| 1087 | 1087 | return "error f : ".$e->getMessage(); |
| 1088 | 1088 | } |
| 1089 | 1089 | } |
@@ -1093,13 +1093,13 @@ discard block |
||
| 1093 | 1093 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 1094 | 1094 | try { |
| 1095 | 1095 | $sth = $Connection->db->prepare($query); |
| 1096 | - $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')); |
|
| 1097 | - } catch(PDOException $e) { |
|
| 1096 | + $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')); |
|
| 1097 | + } catch (PDOException $e) { |
|
| 1098 | 1098 | return "error i : ".$e->getMessage(); |
| 1099 | 1099 | } |
| 1100 | 1100 | } |
| 1101 | 1101 | } |
| 1102 | - if ($i % 90 == 0) { |
|
| 1102 | + if ($i%90 == 0) { |
|
| 1103 | 1103 | if ($globalTransaction) $Connection->db->commit(); |
| 1104 | 1104 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 1105 | 1105 | } |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | $Connection = new Connection(); |
| 1119 | 1119 | $sth = $Connection->db->prepare($query); |
| 1120 | 1120 | $sth->execute(array(':source' => 'website_fam')); |
| 1121 | - } catch(PDOException $e) { |
|
| 1121 | + } catch (PDOException $e) { |
|
| 1122 | 1122 | return "error : ".$e->getMessage(); |
| 1123 | 1123 | } |
| 1124 | 1124 | |
@@ -1139,8 +1139,8 @@ discard block |
||
| 1139 | 1139 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
| 1140 | 1140 | try { |
| 1141 | 1141 | $sth = $Connection->db->prepare($query); |
| 1142 | - $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')); |
|
| 1143 | - } catch(PDOException $e) { |
|
| 1142 | + $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')); |
|
| 1143 | + } catch (PDOException $e) { |
|
| 1144 | 1144 | return "error : ".$e->getMessage(); |
| 1145 | 1145 | } |
| 1146 | 1146 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | $Connection = new Connection(); |
| 1160 | 1160 | $sth = $Connection->db->prepare($query); |
| 1161 | 1161 | $sth->execute(array(':source' => 'website_fam')); |
| 1162 | - } catch(PDOException $e) { |
|
| 1162 | + } catch (PDOException $e) { |
|
| 1163 | 1163 | return "error : ".$e->getMessage(); |
| 1164 | 1164 | } |
| 1165 | 1165 | |
@@ -1175,8 +1175,8 @@ discard block |
||
| 1175 | 1175 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)'; |
| 1176 | 1176 | try { |
| 1177 | 1177 | $sth = $Connection->db->prepare($query); |
| 1178 | - $sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam')); |
|
| 1179 | - } catch(PDOException $e) { |
|
| 1178 | + $sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam')); |
|
| 1179 | + } catch (PDOException $e) { |
|
| 1180 | 1180 | print_r($data); |
| 1181 | 1181 | return "error : ".$e->getMessage(); |
| 1182 | 1182 | } |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | $Connection = new Connection(); |
| 1197 | 1197 | $sth = $Connection->db->prepare($query); |
| 1198 | 1198 | $sth->execute(array(':source' => 'website_fam')); |
| 1199 | - } catch(PDOException $e) { |
|
| 1199 | + } catch (PDOException $e) { |
|
| 1200 | 1200 | return "error : ".$e->getMessage(); |
| 1201 | 1201 | } |
| 1202 | 1202 | $delimiter = "\t"; |
@@ -1211,9 +1211,9 @@ discard block |
||
| 1211 | 1211 | $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)'; |
| 1212 | 1212 | try { |
| 1213 | 1213 | $sth = $Connection->db->prepare($query); |
| 1214 | - $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')); |
|
| 1215 | - } catch(PDOException $e) { |
|
| 1216 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1214 | + $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')); |
|
| 1215 | + } catch (PDOException $e) { |
|
| 1216 | + if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data); |
|
| 1217 | 1217 | } |
| 1218 | 1218 | } |
| 1219 | 1219 | $i++; |
@@ -1231,7 +1231,7 @@ discard block |
||
| 1231 | 1231 | $Connection = new Connection(); |
| 1232 | 1232 | $sth = $Connection->db->prepare($query); |
| 1233 | 1233 | $sth->execute(); |
| 1234 | - } catch(PDOException $e) { |
|
| 1234 | + } catch (PDOException $e) { |
|
| 1235 | 1235 | return "error : ".$e->getMessage(); |
| 1236 | 1236 | } |
| 1237 | 1237 | |
@@ -1252,8 +1252,8 @@ discard block |
||
| 1252 | 1252 | $query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)'; |
| 1253 | 1253 | try { |
| 1254 | 1254 | $sth = $Connection->db->prepare($query); |
| 1255 | - $sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10])); |
|
| 1256 | - } catch(PDOException $e) { |
|
| 1255 | + $sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10])); |
|
| 1256 | + } catch (PDOException $e) { |
|
| 1257 | 1257 | return "error : ".$e->getMessage(); |
| 1258 | 1258 | } |
| 1259 | 1259 | } |
@@ -1272,7 +1272,7 @@ discard block |
||
| 1272 | 1272 | $Connection = new Connection(); |
| 1273 | 1273 | $sth = $Connection->db->prepare($query); |
| 1274 | 1274 | $sth->execute(); |
| 1275 | - } catch(PDOException $e) { |
|
| 1275 | + } catch (PDOException $e) { |
|
| 1276 | 1276 | return "error : ".$e->getMessage(); |
| 1277 | 1277 | } |
| 1278 | 1278 | |
@@ -1288,7 +1288,7 @@ discard block |
||
| 1288 | 1288 | try { |
| 1289 | 1289 | $sth = $Connection->db->prepare($query); |
| 1290 | 1290 | $sth->execute(array(':icao' => $icao)); |
| 1291 | - } catch(PDOException $e) { |
|
| 1291 | + } catch (PDOException $e) { |
|
| 1292 | 1292 | return "error : ".$e->getMessage(); |
| 1293 | 1293 | } |
| 1294 | 1294 | } |
@@ -1299,7 +1299,7 @@ discard block |
||
| 1299 | 1299 | return ''; |
| 1300 | 1300 | } |
| 1301 | 1301 | |
| 1302 | - public static function tle($filename,$tletype) { |
|
| 1302 | + public static function tle($filename, $tletype) { |
|
| 1303 | 1303 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 1304 | 1304 | global $tmp_dir, $globalTransaction; |
| 1305 | 1305 | //$Spotter = new Spotter(); |
@@ -1309,7 +1309,7 @@ discard block |
||
| 1309 | 1309 | $Connection = new Connection(); |
| 1310 | 1310 | $sth = $Connection->db->prepare($query); |
| 1311 | 1311 | $sth->execute(array(':source' => $filename)); |
| 1312 | - } catch(PDOException $e) { |
|
| 1312 | + } catch (PDOException $e) { |
|
| 1313 | 1313 | return "error : ".$e->getMessage(); |
| 1314 | 1314 | } |
| 1315 | 1315 | |
@@ -1334,8 +1334,8 @@ discard block |
||
| 1334 | 1334 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
| 1335 | 1335 | try { |
| 1336 | 1336 | $sth = $Connection->db->prepare($query); |
| 1337 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
| 1338 | - } catch(PDOException $e) { |
|
| 1337 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
| 1338 | + } catch (PDOException $e) { |
|
| 1339 | 1339 | return "error : ".$e->getMessage(); |
| 1340 | 1340 | } |
| 1341 | 1341 | |
@@ -1355,28 +1355,28 @@ discard block |
||
| 1355 | 1355 | */ |
| 1356 | 1356 | private static function table2array($data) { |
| 1357 | 1357 | $html = str_get_html($data); |
| 1358 | - $tabledata=array(); |
|
| 1359 | - foreach($html->find('tr') as $element) |
|
| 1358 | + $tabledata = array(); |
|
| 1359 | + foreach ($html->find('tr') as $element) |
|
| 1360 | 1360 | { |
| 1361 | 1361 | $td = array(); |
| 1362 | - foreach( $element->find('th') as $row) |
|
| 1362 | + foreach ($element->find('th') as $row) |
|
| 1363 | 1363 | { |
| 1364 | 1364 | $td [] = trim($row->plaintext); |
| 1365 | 1365 | } |
| 1366 | - $td=array_filter($td); |
|
| 1366 | + $td = array_filter($td); |
|
| 1367 | 1367 | $tabledata[] = $td; |
| 1368 | 1368 | |
| 1369 | 1369 | $td = array(); |
| 1370 | 1370 | $tdi = array(); |
| 1371 | - foreach( $element->find('td') as $row) |
|
| 1371 | + foreach ($element->find('td') as $row) |
|
| 1372 | 1372 | { |
| 1373 | 1373 | $td [] = trim($row->plaintext); |
| 1374 | 1374 | $tdi [] = trim($row->innertext); |
| 1375 | 1375 | } |
| 1376 | - $td=array_filter($td); |
|
| 1377 | - $tdi=array_filter($tdi); |
|
| 1376 | + $td = array_filter($td); |
|
| 1377 | + $tdi = array_filter($tdi); |
|
| 1378 | 1378 | // $tabledata[]=array_merge($td,$tdi); |
| 1379 | - $tabledata[]=$td; |
|
| 1379 | + $tabledata[] = $td; |
|
| 1380 | 1380 | } |
| 1381 | 1381 | return(array_filter($tabledata)); |
| 1382 | 1382 | } |
@@ -1449,13 +1449,13 @@ discard block |
||
| 1449 | 1449 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1450 | 1450 | { |
| 1451 | 1451 | $i++; |
| 1452 | - if($i > 3 && count($row) > 2) { |
|
| 1452 | + if ($i > 3 && count($row) > 2) { |
|
| 1453 | 1453 | $data = array_values(array_filter($row)); |
| 1454 | 1454 | $cntdata = count($data); |
| 1455 | 1455 | if ($cntdata > 10) { |
| 1456 | 1456 | $value = $data[9]; |
| 1457 | 1457 | |
| 1458 | - for ($i =10;$i < $cntdata;$i++) { |
|
| 1458 | + for ($i = 10; $i < $cntdata; $i++) { |
|
| 1459 | 1459 | $value .= ' '.$data[$i]; |
| 1460 | 1460 | } |
| 1461 | 1461 | $data[9] = $value; |
@@ -1465,8 +1465,8 @@ discard block |
||
| 1465 | 1465 | $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)'; |
| 1466 | 1466 | try { |
| 1467 | 1467 | $sth = $Connection->db->prepare($query); |
| 1468 | - $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])); |
|
| 1469 | - } catch(PDOException $e) { |
|
| 1468 | + $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])); |
|
| 1469 | + } catch (PDOException $e) { |
|
| 1470 | 1470 | return "error : ".$e->getMessage(); |
| 1471 | 1471 | } |
| 1472 | 1472 | } |
@@ -1487,7 +1487,7 @@ discard block |
||
| 1487 | 1487 | $Connection = new Connection(); |
| 1488 | 1488 | $sth = $Connection->db->prepare($query); |
| 1489 | 1489 | $sth->execute(); |
| 1490 | - } catch(PDOException $e) { |
|
| 1490 | + } catch (PDOException $e) { |
|
| 1491 | 1491 | return "error : ".$e->getMessage(); |
| 1492 | 1492 | } |
| 1493 | 1493 | |
@@ -1499,12 +1499,12 @@ discard block |
||
| 1499 | 1499 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 1500 | 1500 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1501 | 1501 | { |
| 1502 | - if(count($row) > 1) { |
|
| 1502 | + if (count($row) > 1) { |
|
| 1503 | 1503 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
| 1504 | 1504 | try { |
| 1505 | 1505 | $sth = $Connection->db->prepare($query); |
| 1506 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
| 1507 | - } catch(PDOException $e) { |
|
| 1506 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
| 1507 | + } catch (PDOException $e) { |
|
| 1508 | 1508 | return "error : ".$e->getMessage(); |
| 1509 | 1509 | } |
| 1510 | 1510 | } |
@@ -1524,21 +1524,21 @@ discard block |
||
| 1524 | 1524 | try { |
| 1525 | 1525 | $sth = $Connection->db->prepare($query); |
| 1526 | 1526 | $sth->execute(); |
| 1527 | - } catch(PDOException $e) { |
|
| 1527 | + } catch (PDOException $e) { |
|
| 1528 | 1528 | return "error : ".$e->getMessage(); |
| 1529 | 1529 | } |
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | 1532 | |
| 1533 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1533 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1534 | 1534 | else { |
| 1535 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1535 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1536 | 1536 | $query = "CREATE EXTENSION postgis"; |
| 1537 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
| 1537 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
| 1538 | 1538 | try { |
| 1539 | 1539 | $sth = $Connection->db->prepare($query); |
| 1540 | 1540 | $sth->execute(); |
| 1541 | - } catch(PDOException $e) { |
|
| 1541 | + } catch (PDOException $e) { |
|
| 1542 | 1542 | return "error : ".$e->getMessage(); |
| 1543 | 1543 | } |
| 1544 | 1544 | } |
@@ -1551,7 +1551,7 @@ discard block |
||
| 1551 | 1551 | include_once('class.create_db.php'); |
| 1552 | 1552 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1553 | 1553 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
| 1554 | - update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
| 1554 | + update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
| 1555 | 1555 | $error = ''; |
| 1556 | 1556 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1557 | 1557 | if ($globalDebug) echo "Gunzip..."; |
@@ -1583,14 +1583,14 @@ discard block |
||
| 1583 | 1583 | try { |
| 1584 | 1584 | $sth = $Connection->db->prepare($query); |
| 1585 | 1585 | $sth->execute(); |
| 1586 | - } catch(PDOException $e) { |
|
| 1586 | + } catch (PDOException $e) { |
|
| 1587 | 1587 | echo "error : ".$e->getMessage(); |
| 1588 | 1588 | } |
| 1589 | 1589 | } |
| 1590 | 1590 | if ($globalDBdriver == 'mysql') { |
| 1591 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1591 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1592 | 1592 | } else { |
| 1593 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1593 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1594 | 1594 | } |
| 1595 | 1595 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
| 1596 | 1596 | return $error; |
@@ -1603,7 +1603,7 @@ discard block |
||
| 1603 | 1603 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
| 1604 | 1604 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
| 1605 | 1605 | // 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'); |
| 1606 | - 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'); |
|
| 1606 | + 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'); |
|
| 1607 | 1607 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
| 1608 | 1608 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
| 1609 | 1609 | return $error; |
@@ -1623,7 +1623,7 @@ discard block |
||
| 1623 | 1623 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1624 | 1624 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
| 1625 | 1625 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1626 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1626 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1627 | 1627 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
| 1628 | 1628 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
| 1629 | 1629 | if ($error != '') { |
@@ -1636,7 +1636,7 @@ discard block |
||
| 1636 | 1636 | global $tmp_dir, $globalDebug; |
| 1637 | 1637 | $error = ''; |
| 1638 | 1638 | if ($globalDebug) echo "Routes : Download..."; |
| 1639 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
| 1639 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
| 1640 | 1640 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1641 | 1641 | if ($globalDebug) echo "Gunzip..."; |
| 1642 | 1642 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1652,7 +1652,7 @@ discard block |
||
| 1652 | 1652 | global $tmp_dir, $globalDebug; |
| 1653 | 1653 | $error = ''; |
| 1654 | 1654 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
| 1655 | - update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
| 1655 | + update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
| 1656 | 1656 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1657 | 1657 | if ($globalDebug) echo "Gunzip..."; |
| 1658 | 1658 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1668,7 +1668,7 @@ discard block |
||
| 1668 | 1668 | global $tmp_dir, $globalDebug; |
| 1669 | 1669 | $error = ''; |
| 1670 | 1670 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
| 1671 | - update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
| 1671 | + update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
| 1672 | 1672 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 1673 | 1673 | if ($globalDebug) echo "Gunzip..."; |
| 1674 | 1674 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -1696,7 +1696,7 @@ discard block |
||
| 1696 | 1696 | */ |
| 1697 | 1697 | if ($globalDebug) echo "Modes : Download..."; |
| 1698 | 1698 | // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
| 1699 | - update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
|
| 1699 | + update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz'); |
|
| 1700 | 1700 | |
| 1701 | 1701 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1702 | 1702 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
@@ -1716,7 +1716,7 @@ discard block |
||
| 1716 | 1716 | public static function update_ModeS_faa() { |
| 1717 | 1717 | global $tmp_dir, $globalDebug; |
| 1718 | 1718 | if ($globalDebug) echo "Modes FAA: Download..."; |
| 1719 | - update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
|
| 1719 | + update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip'); |
|
| 1720 | 1720 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
| 1721 | 1721 | if ($globalDebug) echo "Unzip..."; |
| 1722 | 1722 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
@@ -1732,7 +1732,7 @@ discard block |
||
| 1732 | 1732 | public static function update_ModeS_flarm() { |
| 1733 | 1733 | global $tmp_dir, $globalDebug; |
| 1734 | 1734 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
| 1735 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
| 1735 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
| 1736 | 1736 | if (file_exists($tmp_dir.'data.fln')) { |
| 1737 | 1737 | if ($globalDebug) echo "Add to DB..."; |
| 1738 | 1738 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1746,7 +1746,7 @@ discard block |
||
| 1746 | 1746 | public static function update_ModeS_ogn() { |
| 1747 | 1747 | global $tmp_dir, $globalDebug; |
| 1748 | 1748 | if ($globalDebug) echo "Modes OGN: Download..."; |
| 1749 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
| 1749 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
| 1750 | 1750 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1751 | 1751 | if ($globalDebug) echo "Add to DB..."; |
| 1752 | 1752 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1761,201 +1761,201 @@ discard block |
||
| 1761 | 1761 | global $tmp_dir, $globalDebug, $globalMasterSource; |
| 1762 | 1762 | |
| 1763 | 1763 | if ($globalDebug) echo "Owner France: Download..."; |
| 1764 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
| 1764 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
| 1765 | 1765 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1766 | 1766 | if ($globalDebug) echo "Add to DB..."; |
| 1767 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
| 1767 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
| 1768 | 1768 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
| 1769 | 1769 | if ($error != '') { |
| 1770 | 1770 | return $error; |
| 1771 | 1771 | } elseif ($globalDebug) echo "Done\n"; |
| 1772 | 1772 | |
| 1773 | 1773 | if ($globalDebug) echo "Owner Ireland: Download..."; |
| 1774 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
| 1774 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
| 1775 | 1775 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1776 | 1776 | if ($globalDebug) echo "Add to DB..."; |
| 1777 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
| 1777 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
| 1778 | 1778 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
| 1779 | 1779 | if ($error != '') { |
| 1780 | 1780 | return $error; |
| 1781 | 1781 | } elseif ($globalDebug) echo "Done\n"; |
| 1782 | 1782 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
| 1783 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
| 1783 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
| 1784 | 1784 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1785 | 1785 | if ($globalDebug) echo "Add to DB..."; |
| 1786 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
| 1786 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
| 1787 | 1787 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
| 1788 | 1788 | if ($error != '') { |
| 1789 | 1789 | return $error; |
| 1790 | 1790 | } elseif ($globalDebug) echo "Done\n"; |
| 1791 | 1791 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
| 1792 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
| 1792 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
| 1793 | 1793 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1794 | 1794 | if ($globalDebug) echo "Add to DB..."; |
| 1795 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
| 1795 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
| 1796 | 1796 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
| 1797 | 1797 | if ($error != '') { |
| 1798 | 1798 | return $error; |
| 1799 | 1799 | } elseif ($globalDebug) echo "Done\n"; |
| 1800 | 1800 | if ($globalDebug) echo "Owner Australia: Download..."; |
| 1801 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
| 1801 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
| 1802 | 1802 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1803 | 1803 | if ($globalDebug) echo "Add to DB..."; |
| 1804 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
| 1804 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
| 1805 | 1805 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
| 1806 | 1806 | if ($error != '') { |
| 1807 | 1807 | return $error; |
| 1808 | 1808 | } elseif ($globalDebug) echo "Done\n"; |
| 1809 | 1809 | if ($globalDebug) echo "Owner Austria: Download..."; |
| 1810 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
| 1810 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
| 1811 | 1811 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1812 | 1812 | if ($globalDebug) echo "Add to DB..."; |
| 1813 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
| 1813 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
| 1814 | 1814 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
| 1815 | 1815 | if ($error != '') { |
| 1816 | 1816 | return $error; |
| 1817 | 1817 | } elseif ($globalDebug) echo "Done\n"; |
| 1818 | 1818 | if ($globalDebug) echo "Owner Chile: Download..."; |
| 1819 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
| 1819 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
| 1820 | 1820 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1821 | 1821 | if ($globalDebug) echo "Add to DB..."; |
| 1822 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
| 1822 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
| 1823 | 1823 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
| 1824 | 1824 | if ($error != '') { |
| 1825 | 1825 | return $error; |
| 1826 | 1826 | } elseif ($globalDebug) echo "Done\n"; |
| 1827 | 1827 | if ($globalDebug) echo "Owner Colombia: Download..."; |
| 1828 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
| 1828 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
| 1829 | 1829 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1830 | 1830 | if ($globalDebug) echo "Add to DB..."; |
| 1831 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
| 1831 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
| 1832 | 1832 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
| 1833 | 1833 | if ($error != '') { |
| 1834 | 1834 | return $error; |
| 1835 | 1835 | } elseif ($globalDebug) echo "Done\n"; |
| 1836 | 1836 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
| 1837 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
| 1837 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
| 1838 | 1838 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1839 | 1839 | if ($globalDebug) echo "Add to DB..."; |
| 1840 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
| 1840 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
| 1841 | 1841 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
| 1842 | 1842 | if ($error != '') { |
| 1843 | 1843 | return $error; |
| 1844 | 1844 | } elseif ($globalDebug) echo "Done\n"; |
| 1845 | 1845 | if ($globalDebug) echo "Owner Brazil: Download..."; |
| 1846 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
| 1846 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
| 1847 | 1847 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1848 | 1848 | if ($globalDebug) echo "Add to DB..."; |
| 1849 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
| 1849 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
| 1850 | 1850 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
| 1851 | 1851 | if ($error != '') { |
| 1852 | 1852 | return $error; |
| 1853 | 1853 | } elseif ($globalDebug) echo "Done\n"; |
| 1854 | 1854 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
| 1855 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
| 1855 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
| 1856 | 1856 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1857 | 1857 | if ($globalDebug) echo "Add to DB..."; |
| 1858 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
| 1858 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
| 1859 | 1859 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
| 1860 | 1860 | if ($error != '') { |
| 1861 | 1861 | return $error; |
| 1862 | 1862 | } elseif ($globalDebug) echo "Done\n"; |
| 1863 | 1863 | if ($globalDebug) echo "Owner Croatia: Download..."; |
| 1864 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
| 1864 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
| 1865 | 1865 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1866 | 1866 | if ($globalDebug) echo "Add to DB..."; |
| 1867 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
| 1867 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
| 1868 | 1868 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
| 1869 | 1869 | if ($error != '') { |
| 1870 | 1870 | return $error; |
| 1871 | 1871 | } elseif ($globalDebug) echo "Done\n"; |
| 1872 | 1872 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
| 1873 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
| 1873 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
| 1874 | 1874 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1875 | 1875 | if ($globalDebug) echo "Add to DB..."; |
| 1876 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
| 1876 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
| 1877 | 1877 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
| 1878 | 1878 | if ($error != '') { |
| 1879 | 1879 | return $error; |
| 1880 | 1880 | } elseif ($globalDebug) echo "Done\n"; |
| 1881 | 1881 | if ($globalDebug) echo "Owner Maldives: Download..."; |
| 1882 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
| 1882 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
| 1883 | 1883 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1884 | 1884 | if ($globalDebug) echo "Add to DB..."; |
| 1885 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
| 1885 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
| 1886 | 1886 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
| 1887 | 1887 | if ($error != '') { |
| 1888 | 1888 | return $error; |
| 1889 | 1889 | } elseif ($globalDebug) echo "Done\n"; |
| 1890 | 1890 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
| 1891 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
| 1891 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
| 1892 | 1892 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1893 | 1893 | if ($globalDebug) echo "Add to DB..."; |
| 1894 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
| 1894 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
| 1895 | 1895 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
| 1896 | 1896 | if ($error != '') { |
| 1897 | 1897 | return $error; |
| 1898 | 1898 | } elseif ($globalDebug) echo "Done\n"; |
| 1899 | 1899 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
| 1900 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
| 1900 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
| 1901 | 1901 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1902 | 1902 | if ($globalDebug) echo "Add to DB..."; |
| 1903 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
| 1903 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
| 1904 | 1904 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
| 1905 | 1905 | if ($error != '') { |
| 1906 | 1906 | return $error; |
| 1907 | 1907 | } elseif ($globalDebug) echo "Done\n"; |
| 1908 | 1908 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
| 1909 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
| 1909 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
| 1910 | 1910 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1911 | 1911 | if ($globalDebug) echo "Add to DB..."; |
| 1912 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
| 1912 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
| 1913 | 1913 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
| 1914 | 1914 | if ($error != '') { |
| 1915 | 1915 | return $error; |
| 1916 | 1916 | } elseif ($globalDebug) echo "Done\n"; |
| 1917 | 1917 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
| 1918 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
| 1918 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
| 1919 | 1919 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1920 | 1920 | if ($globalDebug) echo "Add to DB..."; |
| 1921 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
| 1921 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
| 1922 | 1922 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
| 1923 | 1923 | if ($error != '') { |
| 1924 | 1924 | return $error; |
| 1925 | 1925 | } elseif ($globalDebug) echo "Done\n"; |
| 1926 | 1926 | if ($globalDebug) echo "Owner Iceland: Download..."; |
| 1927 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
| 1927 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
| 1928 | 1928 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1929 | 1929 | if ($globalDebug) echo "Add to DB..."; |
| 1930 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
| 1930 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
| 1931 | 1931 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
| 1932 | 1932 | if ($error != '') { |
| 1933 | 1933 | return $error; |
| 1934 | 1934 | } elseif ($globalDebug) echo "Done\n"; |
| 1935 | 1935 | if ($globalDebug) echo "Owner Isle of Man: Download..."; |
| 1936 | - update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
|
| 1936 | + update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv'); |
|
| 1937 | 1937 | if (file_exists($tmp_dir.'owner_m.csv')) { |
| 1938 | 1938 | if ($globalDebug) echo "Add to DB..."; |
| 1939 | - $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
|
| 1939 | + $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M'); |
|
| 1940 | 1940 | } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
| 1941 | 1941 | if ($error != '') { |
| 1942 | 1942 | return $error; |
| 1943 | 1943 | } elseif ($globalDebug) echo "Done\n"; |
| 1944 | 1944 | if ($globalMasterSource) { |
| 1945 | 1945 | if ($globalDebug) echo "ModeS Netherlands: Download..."; |
| 1946 | - update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
|
| 1946 | + update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv'); |
|
| 1947 | 1947 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
| 1948 | 1948 | if ($globalDebug) echo "Add to DB..."; |
| 1949 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
|
| 1949 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH'); |
|
| 1950 | 1950 | } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
| 1951 | 1951 | if ($error != '') { |
| 1952 | 1952 | return $error; |
| 1953 | 1953 | } elseif ($globalDebug) echo "Done\n"; |
| 1954 | 1954 | if ($globalDebug) echo "ModeS Denmark: Download..."; |
| 1955 | - update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
|
| 1955 | + update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv'); |
|
| 1956 | 1956 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
| 1957 | 1957 | if ($globalDebug) echo "Add to DB..."; |
| 1958 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
|
| 1958 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY'); |
|
| 1959 | 1959 | } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
| 1960 | 1960 | if ($error != '') { |
| 1961 | 1961 | return $error; |
@@ -1968,7 +1968,7 @@ discard block |
||
| 1968 | 1968 | global $tmp_dir, $globalDebug; |
| 1969 | 1969 | $error = ''; |
| 1970 | 1970 | if ($globalDebug) echo "Translation : Download..."; |
| 1971 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
| 1971 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
| 1972 | 1972 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1973 | 1973 | if ($globalDebug) echo "Unzip..."; |
| 1974 | 1974 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1984,7 +1984,7 @@ discard block |
||
| 1984 | 1984 | public static function update_translation_fam() { |
| 1985 | 1985 | global $tmp_dir, $globalDebug; |
| 1986 | 1986 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
| 1987 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
| 1987 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
| 1988 | 1988 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1989 | 1989 | if ($globalDebug) echo "Gunzip..."; |
| 1990 | 1990 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1999,7 +1999,7 @@ discard block |
||
| 1999 | 1999 | public static function update_ModeS_fam() { |
| 2000 | 2000 | global $tmp_dir, $globalDebug; |
| 2001 | 2001 | if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
| 2002 | - update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
|
| 2002 | + update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz'); |
|
| 2003 | 2003 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
| 2004 | 2004 | if ($globalDebug) echo "Gunzip..."; |
| 2005 | 2005 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
@@ -2015,9 +2015,9 @@ discard block |
||
| 2015 | 2015 | global $tmp_dir, $globalDebug, $globalOwner; |
| 2016 | 2016 | if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
| 2017 | 2017 | if ($globalOwner === TRUE) { |
| 2018 | - update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
| 2018 | + update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
| 2019 | 2019 | } else { |
| 2020 | - update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
|
| 2020 | + update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz'); |
|
| 2021 | 2021 | } |
| 2022 | 2022 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
| 2023 | 2023 | if ($globalDebug) echo "Gunzip..."; |
@@ -2033,7 +2033,7 @@ discard block |
||
| 2033 | 2033 | public static function update_routes_fam() { |
| 2034 | 2034 | global $tmp_dir, $globalDebug; |
| 2035 | 2035 | if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
| 2036 | - update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
|
| 2036 | + update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz'); |
|
| 2037 | 2037 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
| 2038 | 2038 | if ($globalDebug) echo "Gunzip..."; |
| 2039 | 2039 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
@@ -2047,13 +2047,13 @@ discard block |
||
| 2047 | 2047 | } |
| 2048 | 2048 | public static function update_marine_identity_fam() { |
| 2049 | 2049 | global $tmp_dir, $globalDebug; |
| 2050 | - update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5'); |
|
| 2050 | + update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5'); |
|
| 2051 | 2051 | if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) { |
| 2052 | - $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
| 2052 | + $marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
|
| 2053 | 2053 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
| 2054 | 2054 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
| 2055 | 2055 | if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
| 2056 | - update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
|
| 2056 | + update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz'); |
|
| 2057 | 2057 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
| 2058 | 2058 | if ($globalDebug) echo "Gunzip..."; |
| 2059 | 2059 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
@@ -2073,7 +2073,7 @@ discard block |
||
| 2073 | 2073 | public static function update_banned_fam() { |
| 2074 | 2074 | global $tmp_dir, $globalDebug; |
| 2075 | 2075 | if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
| 2076 | - update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
|
| 2076 | + update_db::download('http://data.flightairmap.fr/data/ban-eu.csv', $tmp_dir.'ban_eu.csv'); |
|
| 2077 | 2077 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
| 2078 | 2078 | //if ($globalDebug) echo "Gunzip..."; |
| 2079 | 2079 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
@@ -2092,18 +2092,18 @@ discard block |
||
| 2092 | 2092 | $error = ''; |
| 2093 | 2093 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
| 2094 | 2094 | if ($globalDBdriver == 'mysql') { |
| 2095 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 2095 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 2096 | 2096 | } else { |
| 2097 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 2097 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 2098 | 2098 | } |
| 2099 | 2099 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
| 2100 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 2100 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 2101 | 2101 | $airspace_md5 = $airspace_md5_file[0]; |
| 2102 | 2102 | if (!update_db::check_airspace_version($airspace_md5)) { |
| 2103 | 2103 | if ($globalDBdriver == 'mysql') { |
| 2104 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 2104 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 2105 | 2105 | } else { |
| 2106 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 2106 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 2107 | 2107 | } |
| 2108 | 2108 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 2109 | 2109 | if ($globalDebug) echo "Gunzip..."; |
@@ -2115,7 +2115,7 @@ discard block |
||
| 2115 | 2115 | try { |
| 2116 | 2116 | $sth = $Connection->db->prepare($query); |
| 2117 | 2117 | $sth->execute(); |
| 2118 | - } catch(PDOException $e) { |
|
| 2118 | + } catch (PDOException $e) { |
|
| 2119 | 2119 | return "error : ".$e->getMessage(); |
| 2120 | 2120 | } |
| 2121 | 2121 | } |
@@ -2134,15 +2134,15 @@ discard block |
||
| 2134 | 2134 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
| 2135 | 2135 | $error = ''; |
| 2136 | 2136 | if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
| 2137 | - update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
| 2137 | + update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
|
| 2138 | 2138 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
| 2139 | - $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
| 2139 | + $geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
|
| 2140 | 2140 | $geoid_md5 = $geoid_md5_file[0]; |
| 2141 | 2141 | if (!update_db::check_geoid_version($geoid_md5)) { |
| 2142 | - update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
| 2142 | + update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz'); |
|
| 2143 | 2143 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
| 2144 | 2144 | if ($globalDebug) echo "Gunzip..."; |
| 2145 | - update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
| 2145 | + update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
|
| 2146 | 2146 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
| 2147 | 2147 | update_db::insert_geoid_version($geoid_md5); |
| 2148 | 2148 | } |
@@ -2158,15 +2158,15 @@ discard block |
||
| 2158 | 2158 | public static function update_tle() { |
| 2159 | 2159 | global $tmp_dir, $globalDebug; |
| 2160 | 2160 | if ($globalDebug) echo "Download TLE : Download..."; |
| 2161 | - $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', |
|
| 2162 | - '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', |
|
| 2163 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
| 2161 | + $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', |
|
| 2162 | + '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', |
|
| 2163 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
| 2164 | 2164 | foreach ($alltle as $filename) { |
| 2165 | 2165 | if ($globalDebug) echo "downloading ".$filename.'...'; |
| 2166 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
| 2166 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
| 2167 | 2167 | if (file_exists($tmp_dir.$filename)) { |
| 2168 | 2168 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
| 2169 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
| 2169 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
| 2170 | 2170 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
| 2171 | 2171 | if ($error != '') { |
| 2172 | 2172 | echo $error."\n"; |
@@ -2179,32 +2179,32 @@ discard block |
||
| 2179 | 2179 | global $tmp_dir, $globalDebug; |
| 2180 | 2180 | $error = ''; |
| 2181 | 2181 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
| 2182 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
| 2182 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
| 2183 | 2183 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 2184 | 2184 | if ($globalDebug) echo "Check files...\n"; |
| 2185 | 2185 | $newmodelsdb = array(); |
| 2186 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
| 2187 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2186 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
| 2187 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2188 | 2188 | $model = trim($row[2]); |
| 2189 | 2189 | $newmodelsdb[$model] = trim($row[0]); |
| 2190 | 2190 | } |
| 2191 | 2191 | } |
| 2192 | 2192 | $modelsdb = array(); |
| 2193 | 2193 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
| 2194 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
| 2195 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2194 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
| 2195 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2196 | 2196 | $model = trim($row[2]); |
| 2197 | 2197 | $modelsdb[$model] = trim($row[0]); |
| 2198 | 2198 | } |
| 2199 | 2199 | } |
| 2200 | 2200 | } |
| 2201 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2201 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2202 | 2202 | foreach ($diff as $key => $value) { |
| 2203 | 2203 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
| 2204 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
| 2204 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
| 2205 | 2205 | |
| 2206 | 2206 | } |
| 2207 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
| 2207 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
| 2208 | 2208 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 2209 | 2209 | if ($error != '') { |
| 2210 | 2210 | return $error; |
@@ -2216,32 +2216,32 @@ discard block |
||
| 2216 | 2216 | global $tmp_dir, $globalDebug; |
| 2217 | 2217 | $error = ''; |
| 2218 | 2218 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
| 2219 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
| 2219 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
| 2220 | 2220 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 2221 | 2221 | if ($globalDebug) echo "Check files...\n"; |
| 2222 | 2222 | $newmodelsdb = array(); |
| 2223 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
| 2224 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2223 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
| 2224 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2225 | 2225 | $model = trim($row[2]); |
| 2226 | 2226 | $newmodelsdb[$model] = trim($row[0]); |
| 2227 | 2227 | } |
| 2228 | 2228 | } |
| 2229 | 2229 | $modelsdb = array(); |
| 2230 | 2230 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
| 2231 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
| 2232 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2231 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
| 2232 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2233 | 2233 | $model = trim($row[2]); |
| 2234 | 2234 | $modelsdb[$model] = trim($row[0]); |
| 2235 | 2235 | } |
| 2236 | 2236 | } |
| 2237 | 2237 | } |
| 2238 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2238 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2239 | 2239 | foreach ($diff as $key => $value) { |
| 2240 | 2240 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
| 2241 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
| 2241 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
| 2242 | 2242 | |
| 2243 | 2243 | } |
| 2244 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 2244 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 2245 | 2245 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 2246 | 2246 | if ($error != '') { |
| 2247 | 2247 | return $error; |
@@ -2253,32 +2253,32 @@ discard block |
||
| 2253 | 2253 | global $tmp_dir, $globalDebug; |
| 2254 | 2254 | $error = ''; |
| 2255 | 2255 | if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
| 2256 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
|
| 2256 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum'); |
|
| 2257 | 2257 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
| 2258 | 2258 | if ($globalDebug) echo "Check files...\n"; |
| 2259 | 2259 | $newmodelsdb = array(); |
| 2260 | - if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
|
| 2261 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2260 | + if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) { |
|
| 2261 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2262 | 2262 | $model = trim($row[2]); |
| 2263 | 2263 | $newmodelsdb[$model] = trim($row[0]); |
| 2264 | 2264 | } |
| 2265 | 2265 | } |
| 2266 | 2266 | $modelsdb = array(); |
| 2267 | 2267 | if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) { |
| 2268 | - if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) { |
|
| 2269 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 2268 | + if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) { |
|
| 2269 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 2270 | 2270 | $model = trim($row[2]); |
| 2271 | 2271 | $modelsdb[$model] = trim($row[0]); |
| 2272 | 2272 | } |
| 2273 | 2273 | } |
| 2274 | 2274 | } |
| 2275 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 2275 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 2276 | 2276 | foreach ($diff as $key => $value) { |
| 2277 | 2277 | if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
| 2278 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
|
| 2278 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key); |
|
| 2279 | 2279 | |
| 2280 | 2280 | } |
| 2281 | - update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
| 2281 | + update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
|
| 2282 | 2282 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 2283 | 2283 | if ($error != '') { |
| 2284 | 2284 | return $error; |
@@ -2301,8 +2301,8 @@ discard block |
||
| 2301 | 2301 | */ |
| 2302 | 2302 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 2303 | 2303 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
| 2304 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 2305 | - $result = fread($fh,100000000); |
|
| 2304 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
| 2305 | + $result = fread($fh, 100000000); |
|
| 2306 | 2306 | //echo $result; |
| 2307 | 2307 | //var_dump(str_get_html($result)); |
| 2308 | 2308 | //print_r(self::table2array($result)); |
@@ -2320,23 +2320,23 @@ 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 | |
| 2327 | 2327 | $error = ''; |
| 2328 | 2328 | if ($globalDebug) echo "Notam : Download..."; |
| 2329 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
| 2329 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
| 2330 | 2330 | if (file_exists($tmp_dir.'notam.rss')) { |
| 2331 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
| 2331 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
| 2332 | 2332 | foreach ($notams['channel']['item'] as $notam) { |
| 2333 | - $title = explode(':',$notam['title']); |
|
| 2333 | + $title = explode(':', $notam['title']); |
|
| 2334 | 2334 | $data['ref'] = trim($title[0]); |
| 2335 | 2335 | unset($title[0]); |
| 2336 | - $data['title'] = trim(implode(':',$title)); |
|
| 2337 | - $description = strip_tags($notam['description'],'<pre>'); |
|
| 2338 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
| 2339 | - $q = explode('/',$match[1]); |
|
| 2336 | + $data['title'] = trim(implode(':', $title)); |
|
| 2337 | + $description = strip_tags($notam['description'], '<pre>'); |
|
| 2338 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
| 2339 | + $q = explode('/', $match[1]); |
|
| 2340 | 2340 | $data['fir'] = $q[0]; |
| 2341 | 2341 | $data['code'] = $q[1]; |
| 2342 | 2342 | $ifrvfr = $q[2]; |
@@ -2352,30 +2352,30 @@ discard block |
||
| 2352 | 2352 | $data['lower_limit'] = $q[5]; |
| 2353 | 2353 | $data['upper_limit'] = $q[6]; |
| 2354 | 2354 | $latlonrad = $q[7]; |
| 2355 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
| 2356 | - $latitude = $Common->convertDec($las,'latitude'); |
|
| 2357 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
| 2355 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
| 2356 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
| 2357 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
| 2358 | 2358 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 2359 | 2359 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 2360 | 2360 | $data['center_latitude'] = $latitude; |
| 2361 | 2361 | $data['center_longitude'] = $longitude; |
| 2362 | 2362 | $data['radius'] = intval($radius); |
| 2363 | 2363 | |
| 2364 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
| 2364 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
| 2365 | 2365 | $data['text'] = $match[1]; |
| 2366 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
| 2366 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
| 2367 | 2367 | $fromto = $match[1]; |
| 2368 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
| 2368 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
| 2369 | 2369 | $fromall = trim($match[1]); |
| 2370 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
| 2370 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
| 2371 | 2371 | $from = trim($match[1]); |
| 2372 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
| 2373 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
| 2372 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
| 2373 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
| 2374 | 2374 | $toall = trim($match[1]); |
| 2375 | - if (!preg_match(':Permanent:',$toall)) { |
|
| 2376 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
| 2375 | + if (!preg_match(':Permanent:', $toall)) { |
|
| 2376 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
| 2377 | 2377 | $to = trim($match[1]); |
| 2378 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
| 2378 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
| 2379 | 2379 | $data['permanent'] = 0; |
| 2380 | 2380 | } else { |
| 2381 | 2381 | $data['date_end'] = NULL; |
@@ -2383,7 +2383,7 @@ discard block |
||
| 2383 | 2383 | } |
| 2384 | 2384 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 2385 | 2385 | $NOTAM = new NOTAM(); |
| 2386 | - $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']); |
|
| 2386 | + $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']); |
|
| 2387 | 2387 | unset($data); |
| 2388 | 2388 | } |
| 2389 | 2389 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -2406,16 +2406,16 @@ discard block |
||
| 2406 | 2406 | $Connection = new Connection(); |
| 2407 | 2407 | $sth = $Connection->db->prepare($query); |
| 2408 | 2408 | $sth->execute(); |
| 2409 | - } catch(PDOException $e) { |
|
| 2409 | + } catch (PDOException $e) { |
|
| 2410 | 2410 | return "error : ".$e->getMessage(); |
| 2411 | 2411 | } |
| 2412 | 2412 | } |
| 2413 | 2413 | $Common = new Common(); |
| 2414 | 2414 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 2415 | - $airspace_json = json_decode($airspace_lst,true); |
|
| 2415 | + $airspace_json = json_decode($airspace_lst, true); |
|
| 2416 | 2416 | foreach ($airspace_json['records'] as $airspace) { |
| 2417 | 2417 | if ($globalDebug) echo $airspace['name']."...\n"; |
| 2418 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
| 2418 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
| 2419 | 2419 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 2420 | 2420 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
| 2421 | 2421 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -2437,7 +2437,7 @@ discard block |
||
| 2437 | 2437 | $Connection = new Connection(); |
| 2438 | 2438 | $sth = $Connection->db->prepare($query); |
| 2439 | 2439 | $sth->execute(array(':new' => $new, ':old' => $old)); |
| 2440 | - } catch(PDOException $e) { |
|
| 2440 | + } catch (PDOException $e) { |
|
| 2441 | 2441 | return "error : ".$e->getMessage(); |
| 2442 | 2442 | } |
| 2443 | 2443 | } |
@@ -2454,7 +2454,7 @@ discard block |
||
| 2454 | 2454 | $Connection = new Connection(); |
| 2455 | 2455 | $sth = $Connection->db->prepare($query); |
| 2456 | 2456 | $sth->execute(); |
| 2457 | - } catch(PDOException $e) { |
|
| 2457 | + } catch (PDOException $e) { |
|
| 2458 | 2458 | return "error : ".$e->getMessage(); |
| 2459 | 2459 | } |
| 2460 | 2460 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2469,7 +2469,7 @@ discard block |
||
| 2469 | 2469 | $Connection = new Connection(); |
| 2470 | 2470 | $sth = $Connection->db->prepare($query); |
| 2471 | 2471 | $sth->execute(); |
| 2472 | - } catch(PDOException $e) { |
|
| 2472 | + } catch (PDOException $e) { |
|
| 2473 | 2473 | return "error : ".$e->getMessage(); |
| 2474 | 2474 | } |
| 2475 | 2475 | } |
@@ -2480,7 +2480,7 @@ discard block |
||
| 2480 | 2480 | $Connection = new Connection(); |
| 2481 | 2481 | $sth = $Connection->db->prepare($query); |
| 2482 | 2482 | $sth->execute(array(':version' => $version)); |
| 2483 | - } catch(PDOException $e) { |
|
| 2483 | + } catch (PDOException $e) { |
|
| 2484 | 2484 | return "error : ".$e->getMessage(); |
| 2485 | 2485 | } |
| 2486 | 2486 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2494,7 +2494,7 @@ discard block |
||
| 2494 | 2494 | $Connection = new Connection(); |
| 2495 | 2495 | $sth = $Connection->db->prepare($query); |
| 2496 | 2496 | $sth->execute(array(':version' => $version)); |
| 2497 | - } catch(PDOException $e) { |
|
| 2497 | + } catch (PDOException $e) { |
|
| 2498 | 2498 | return "error : ".$e->getMessage(); |
| 2499 | 2499 | } |
| 2500 | 2500 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2508,7 +2508,7 @@ discard block |
||
| 2508 | 2508 | $Connection = new Connection(); |
| 2509 | 2509 | $sth = $Connection->db->prepare($query); |
| 2510 | 2510 | $sth->execute(array(':version' => $version)); |
| 2511 | - } catch(PDOException $e) { |
|
| 2511 | + } catch (PDOException $e) { |
|
| 2512 | 2512 | return "error : ".$e->getMessage(); |
| 2513 | 2513 | } |
| 2514 | 2514 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2524,7 +2524,7 @@ discard block |
||
| 2524 | 2524 | $Connection = new Connection(); |
| 2525 | 2525 | $sth = $Connection->db->prepare($query); |
| 2526 | 2526 | $sth->execute(array(':version' => $version)); |
| 2527 | - } catch(PDOException $e) { |
|
| 2527 | + } catch (PDOException $e) { |
|
| 2528 | 2528 | return "error : ".$e->getMessage(); |
| 2529 | 2529 | } |
| 2530 | 2530 | } |
@@ -2536,7 +2536,7 @@ discard block |
||
| 2536 | 2536 | $Connection = new Connection(); |
| 2537 | 2537 | $sth = $Connection->db->prepare($query); |
| 2538 | 2538 | $sth->execute(array(':version' => $version)); |
| 2539 | - } catch(PDOException $e) { |
|
| 2539 | + } catch (PDOException $e) { |
|
| 2540 | 2540 | return "error : ".$e->getMessage(); |
| 2541 | 2541 | } |
| 2542 | 2542 | } |
@@ -2548,7 +2548,7 @@ discard block |
||
| 2548 | 2548 | $Connection = new Connection(); |
| 2549 | 2549 | $sth = $Connection->db->prepare($query); |
| 2550 | 2550 | $sth->execute(array(':version' => $version)); |
| 2551 | - } catch(PDOException $e) { |
|
| 2551 | + } catch (PDOException $e) { |
|
| 2552 | 2552 | return "error : ".$e->getMessage(); |
| 2553 | 2553 | } |
| 2554 | 2554 | } |
@@ -2564,7 +2564,7 @@ discard block |
||
| 2564 | 2564 | $Connection = new Connection(); |
| 2565 | 2565 | $sth = $Connection->db->prepare($query); |
| 2566 | 2566 | $sth->execute(); |
| 2567 | - } catch(PDOException $e) { |
|
| 2567 | + } catch (PDOException $e) { |
|
| 2568 | 2568 | return "error : ".$e->getMessage(); |
| 2569 | 2569 | } |
| 2570 | 2570 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2579,7 +2579,7 @@ discard block |
||
| 2579 | 2579 | $Connection = new Connection(); |
| 2580 | 2580 | $sth = $Connection->db->prepare($query); |
| 2581 | 2581 | $sth->execute(); |
| 2582 | - } catch(PDOException $e) { |
|
| 2582 | + } catch (PDOException $e) { |
|
| 2583 | 2583 | return "error : ".$e->getMessage(); |
| 2584 | 2584 | } |
| 2585 | 2585 | } |
@@ -2595,7 +2595,7 @@ discard block |
||
| 2595 | 2595 | $Connection = new Connection(); |
| 2596 | 2596 | $sth = $Connection->db->prepare($query); |
| 2597 | 2597 | $sth->execute(); |
| 2598 | - } catch(PDOException $e) { |
|
| 2598 | + } catch (PDOException $e) { |
|
| 2599 | 2599 | return "error : ".$e->getMessage(); |
| 2600 | 2600 | } |
| 2601 | 2601 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2610,7 +2610,7 @@ discard block |
||
| 2610 | 2610 | $Connection = new Connection(); |
| 2611 | 2611 | $sth = $Connection->db->prepare($query); |
| 2612 | 2612 | $sth->execute(); |
| 2613 | - } catch(PDOException $e) { |
|
| 2613 | + } catch (PDOException $e) { |
|
| 2614 | 2614 | return "error : ".$e->getMessage(); |
| 2615 | 2615 | } |
| 2616 | 2616 | } |
@@ -2626,7 +2626,7 @@ discard block |
||
| 2626 | 2626 | $Connection = new Connection(); |
| 2627 | 2627 | $sth = $Connection->db->prepare($query); |
| 2628 | 2628 | $sth->execute(); |
| 2629 | - } catch(PDOException $e) { |
|
| 2629 | + } catch (PDOException $e) { |
|
| 2630 | 2630 | return "error : ".$e->getMessage(); |
| 2631 | 2631 | } |
| 2632 | 2632 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2641,7 +2641,7 @@ discard block |
||
| 2641 | 2641 | $Connection = new Connection(); |
| 2642 | 2642 | $sth = $Connection->db->prepare($query); |
| 2643 | 2643 | $sth->execute(); |
| 2644 | - } catch(PDOException $e) { |
|
| 2644 | + } catch (PDOException $e) { |
|
| 2645 | 2645 | return "error : ".$e->getMessage(); |
| 2646 | 2646 | } |
| 2647 | 2647 | } |
@@ -2657,7 +2657,7 @@ discard block |
||
| 2657 | 2657 | $Connection = new Connection(); |
| 2658 | 2658 | $sth = $Connection->db->prepare($query); |
| 2659 | 2659 | $sth->execute(); |
| 2660 | - } catch(PDOException $e) { |
|
| 2660 | + } catch (PDOException $e) { |
|
| 2661 | 2661 | return "error : ".$e->getMessage(); |
| 2662 | 2662 | } |
| 2663 | 2663 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2672,7 +2672,7 @@ discard block |
||
| 2672 | 2672 | $Connection = new Connection(); |
| 2673 | 2673 | $sth = $Connection->db->prepare($query); |
| 2674 | 2674 | $sth->execute(); |
| 2675 | - } catch(PDOException $e) { |
|
| 2675 | + } catch (PDOException $e) { |
|
| 2676 | 2676 | return "error : ".$e->getMessage(); |
| 2677 | 2677 | } |
| 2678 | 2678 | } |
@@ -2687,7 +2687,7 @@ discard block |
||
| 2687 | 2687 | $Connection = new Connection(); |
| 2688 | 2688 | $sth = $Connection->db->prepare($query); |
| 2689 | 2689 | $sth->execute(); |
| 2690 | - } catch(PDOException $e) { |
|
| 2690 | + } catch (PDOException $e) { |
|
| 2691 | 2691 | return "error : ".$e->getMessage(); |
| 2692 | 2692 | } |
| 2693 | 2693 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2702,7 +2702,7 @@ discard block |
||
| 2702 | 2702 | $Connection = new Connection(); |
| 2703 | 2703 | $sth = $Connection->db->prepare($query); |
| 2704 | 2704 | $sth->execute(); |
| 2705 | - } catch(PDOException $e) { |
|
| 2705 | + } catch (PDOException $e) { |
|
| 2706 | 2706 | return "error : ".$e->getMessage(); |
| 2707 | 2707 | } |
| 2708 | 2708 | } |
@@ -2717,7 +2717,7 @@ discard block |
||
| 2717 | 2717 | $Connection = new Connection(); |
| 2718 | 2718 | $sth = $Connection->db->prepare($query); |
| 2719 | 2719 | $sth->execute(); |
| 2720 | - } catch(PDOException $e) { |
|
| 2720 | + } catch (PDOException $e) { |
|
| 2721 | 2721 | return "error : ".$e->getMessage(); |
| 2722 | 2722 | } |
| 2723 | 2723 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2732,7 +2732,7 @@ discard block |
||
| 2732 | 2732 | $Connection = new Connection(); |
| 2733 | 2733 | $sth = $Connection->db->prepare($query); |
| 2734 | 2734 | $sth->execute(); |
| 2735 | - } catch(PDOException $e) { |
|
| 2735 | + } catch (PDOException $e) { |
|
| 2736 | 2736 | return "error : ".$e->getMessage(); |
| 2737 | 2737 | } |
| 2738 | 2738 | } |
@@ -2747,7 +2747,7 @@ discard block |
||
| 2747 | 2747 | $Connection = new Connection(); |
| 2748 | 2748 | $sth = $Connection->db->prepare($query); |
| 2749 | 2749 | $sth->execute(); |
| 2750 | - } catch(PDOException $e) { |
|
| 2750 | + } catch (PDOException $e) { |
|
| 2751 | 2751 | return "error : ".$e->getMessage(); |
| 2752 | 2752 | } |
| 2753 | 2753 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2762,7 +2762,7 @@ discard block |
||
| 2762 | 2762 | $Connection = new Connection(); |
| 2763 | 2763 | $sth = $Connection->db->prepare($query); |
| 2764 | 2764 | $sth->execute(); |
| 2765 | - } catch(PDOException $e) { |
|
| 2765 | + } catch (PDOException $e) { |
|
| 2766 | 2766 | return "error : ".$e->getMessage(); |
| 2767 | 2767 | } |
| 2768 | 2768 | } |
@@ -2777,7 +2777,7 @@ discard block |
||
| 2777 | 2777 | $Connection = new Connection(); |
| 2778 | 2778 | $sth = $Connection->db->prepare($query); |
| 2779 | 2779 | $sth->execute(); |
| 2780 | - } catch(PDOException $e) { |
|
| 2780 | + } catch (PDOException $e) { |
|
| 2781 | 2781 | return "error : ".$e->getMessage(); |
| 2782 | 2782 | } |
| 2783 | 2783 | } |
@@ -2792,7 +2792,7 @@ discard block |
||
| 2792 | 2792 | $Connection = new Connection(); |
| 2793 | 2793 | $sth = $Connection->db->prepare($query); |
| 2794 | 2794 | $sth->execute(); |
| 2795 | - } catch(PDOException $e) { |
|
| 2795 | + } catch (PDOException $e) { |
|
| 2796 | 2796 | return "error : ".$e->getMessage(); |
| 2797 | 2797 | } |
| 2798 | 2798 | } |
@@ -17,7 +17,9 @@ discard block |
||
| 17 | 17 | curl_setopt($ch, CURLOPT_URL, $url); |
| 18 | 18 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 19 | 19 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 20 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 20 | + if ($referer != '') { |
|
| 21 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 22 | + } |
|
| 21 | 23 | 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'); |
| 22 | 24 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 23 | 25 | curl_exec($ch); |
@@ -28,12 +30,16 @@ discard block |
||
| 28 | 30 | public static function gunzip($in_file,$out_file_name = '') { |
| 29 | 31 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 30 | 32 | $buffer_size = 4096; // read 4kb at a time |
| 31 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 33 | + if ($out_file_name == '') { |
|
| 34 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 35 | + } |
|
| 32 | 36 | if ($in_file != '' && file_exists($in_file)) { |
| 33 | 37 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 34 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 35 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 36 | - else { |
|
| 38 | + if (function_exists('gzopen')) { |
|
| 39 | + $file = gzopen($in_file,'rb'); |
|
| 40 | + } elseif (function_exists('gzopen64')) { |
|
| 41 | + $file = gzopen64($in_file,'rb'); |
|
| 42 | + } else { |
|
| 37 | 43 | echo 'gzopen not available'; |
| 38 | 44 | die; |
| 39 | 45 | } |
@@ -54,8 +60,12 @@ discard block |
||
| 54 | 60 | if ($res === TRUE) { |
| 55 | 61 | $zip->extractTo($path); |
| 56 | 62 | $zip->close(); |
| 57 | - } else return false; |
|
| 58 | - } else return false; |
|
| 63 | + } else { |
|
| 64 | + return false; |
|
| 65 | + } |
|
| 66 | + } else { |
|
| 67 | + return false; |
|
| 68 | + } |
|
| 59 | 69 | } |
| 60 | 70 | |
| 61 | 71 | public static function connect_sqlite($database) { |
@@ -70,7 +80,9 @@ discard block |
||
| 70 | 80 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 71 | 81 | global $globalDebug, $globalTransaction; |
| 72 | 82 | //$query = 'TRUNCATE TABLE routes'; |
| 73 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 83 | + if ($globalDebug) { |
|
| 84 | + echo " - Delete previous routes from DB -"; |
|
| 85 | + } |
|
| 74 | 86 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 75 | 87 | $Connection = new Connection(); |
| 76 | 88 | try { |
@@ -81,7 +93,9 @@ discard block |
||
| 81 | 93 | return "error : ".$e->getMessage(); |
| 82 | 94 | } |
| 83 | 95 | |
| 84 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 96 | + if ($globalDebug) { |
|
| 97 | + echo " - Add routes to DB -"; |
|
| 98 | + } |
|
| 85 | 99 | update_db::connect_sqlite($database_file); |
| 86 | 100 | //$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'; |
| 87 | 101 | $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"; |
@@ -96,15 +110,21 @@ discard block |
||
| 96 | 110 | $Connection = new Connection(); |
| 97 | 111 | $sth_dest = $Connection->db->prepare($query_dest); |
| 98 | 112 | try { |
| 99 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 113 | + if ($globalTransaction) { |
|
| 114 | + $Connection->db->beginTransaction(); |
|
| 115 | + } |
|
| 100 | 116 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 101 | 117 | //$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); |
| 102 | 118 | $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); |
| 103 | 119 | $sth_dest->execute($query_dest_values); |
| 104 | 120 | } |
| 105 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 121 | + if ($globalTransaction) { |
|
| 122 | + $Connection->db->commit(); |
|
| 123 | + } |
|
| 106 | 124 | } catch(PDOException $e) { |
| 107 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 125 | + if ($globalTransaction) { |
|
| 126 | + $Connection->db->rollBack(); |
|
| 127 | + } |
|
| 108 | 128 | return "error : ".$e->getMessage(); |
| 109 | 129 | } |
| 110 | 130 | return ''; |
@@ -112,7 +132,9 @@ discard block |
||
| 112 | 132 | public static function retrieve_route_oneworld($database_file) { |
| 113 | 133 | global $globalDebug, $globalTransaction; |
| 114 | 134 | //$query = 'TRUNCATE TABLE routes'; |
| 115 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 135 | + if ($globalDebug) { |
|
| 136 | + echo " - Delete previous routes from DB -"; |
|
| 137 | + } |
|
| 116 | 138 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 117 | 139 | $Connection = new Connection(); |
| 118 | 140 | try { |
@@ -123,14 +145,18 @@ discard block |
||
| 123 | 145 | return "error : ".$e->getMessage(); |
| 124 | 146 | } |
| 125 | 147 | |
| 126 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 148 | + if ($globalDebug) { |
|
| 149 | + echo " - Add routes to DB -"; |
|
| 150 | + } |
|
| 127 | 151 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 128 | 152 | $Spotter = new Spotter(); |
| 129 | 153 | if ($fh = fopen($database_file,"r")) { |
| 130 | 154 | $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)'; |
| 131 | 155 | $Connection = new Connection(); |
| 132 | 156 | $sth_dest = $Connection->db->prepare($query_dest); |
| 133 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 157 | + if ($globalTransaction) { |
|
| 158 | + $Connection->db->beginTransaction(); |
|
| 159 | + } |
|
| 134 | 160 | while (!feof($fh)) { |
| 135 | 161 | $line = fgetcsv($fh,9999,','); |
| 136 | 162 | if ($line[0] != '') { |
@@ -139,13 +165,17 @@ discard block |
||
| 139 | 165 | $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'); |
| 140 | 166 | $sth_dest->execute($query_dest_values); |
| 141 | 167 | } catch(PDOException $e) { |
| 142 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 168 | + if ($globalTransaction) { |
|
| 169 | + $Connection->db->rollBack(); |
|
| 170 | + } |
|
| 143 | 171 | return "error : ".$e->getMessage(); |
| 144 | 172 | } |
| 145 | 173 | } |
| 146 | 174 | } |
| 147 | 175 | } |
| 148 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 176 | + if ($globalTransaction) { |
|
| 177 | + $Connection->db->commit(); |
|
| 178 | + } |
|
| 149 | 179 | } |
| 150 | 180 | return ''; |
| 151 | 181 | } |
@@ -153,7 +183,9 @@ discard block |
||
| 153 | 183 | public static function retrieve_route_skyteam($database_file) { |
| 154 | 184 | global $globalDebug, $globalTransaction; |
| 155 | 185 | //$query = 'TRUNCATE TABLE routes'; |
| 156 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 186 | + if ($globalDebug) { |
|
| 187 | + echo " - Delete previous routes from DB -"; |
|
| 188 | + } |
|
| 157 | 189 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 158 | 190 | $Connection = new Connection(); |
| 159 | 191 | try { |
@@ -164,7 +196,9 @@ discard block |
||
| 164 | 196 | return "error : ".$e->getMessage(); |
| 165 | 197 | } |
| 166 | 198 | |
| 167 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 199 | + if ($globalDebug) { |
|
| 200 | + echo " - Add routes to DB -"; |
|
| 201 | + } |
|
| 168 | 202 | |
| 169 | 203 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 170 | 204 | $Spotter = new Spotter(); |
@@ -173,7 +207,9 @@ discard block |
||
| 173 | 207 | $Connection = new Connection(); |
| 174 | 208 | $sth_dest = $Connection->db->prepare($query_dest); |
| 175 | 209 | try { |
| 176 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 210 | + if ($globalTransaction) { |
|
| 211 | + $Connection->db->beginTransaction(); |
|
| 212 | + } |
|
| 177 | 213 | while (!feof($fh)) { |
| 178 | 214 | $line = fgetcsv($fh,9999,','); |
| 179 | 215 | if ($line[0] != '') { |
@@ -184,9 +220,13 @@ discard block |
||
| 184 | 220 | } |
| 185 | 221 | } |
| 186 | 222 | } |
| 187 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 223 | + if ($globalTransaction) { |
|
| 224 | + $Connection->db->commit(); |
|
| 225 | + } |
|
| 188 | 226 | } catch(PDOException $e) { |
| 189 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 227 | + if ($globalTransaction) { |
|
| 228 | + $Connection->db->rollBack(); |
|
| 229 | + } |
|
| 190 | 230 | return "error : ".$e->getMessage(); |
| 191 | 231 | } |
| 192 | 232 | } |
@@ -229,11 +269,16 @@ discard block |
||
| 229 | 269 | $sth_dest = $Connection->db->prepare($query_dest); |
| 230 | 270 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 231 | 271 | try { |
| 232 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 272 | + if ($globalTransaction) { |
|
| 273 | + $Connection->db->beginTransaction(); |
|
| 274 | + } |
|
| 233 | 275 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 234 | 276 | //$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']); |
| 235 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
| 236 | - else $type = null; |
|
| 277 | + if ($values['UserString4'] == 'M') { |
|
| 278 | + $type = 'military'; |
|
| 279 | + } else { |
|
| 280 | + $type = null; |
|
| 281 | + } |
|
| 237 | 282 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 238 | 283 | $sth_dest->execute($query_dest_values); |
| 239 | 284 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -241,7 +286,9 @@ discard block |
||
| 241 | 286 | $sth_dest_owner->execute($query_dest_owner_values); |
| 242 | 287 | } |
| 243 | 288 | } |
| 244 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 289 | + if ($globalTransaction) { |
|
| 290 | + $Connection->db->commit(); |
|
| 291 | + } |
|
| 245 | 292 | } catch(PDOException $e) { |
| 246 | 293 | return "error : ".$e->getMessage(); |
| 247 | 294 | } |
@@ -278,7 +325,9 @@ discard block |
||
| 278 | 325 | $Connection = new Connection(); |
| 279 | 326 | $sth_dest = $Connection->db->prepare($query_dest); |
| 280 | 327 | try { |
| 281 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 328 | + if ($globalTransaction) { |
|
| 329 | + $Connection->db->beginTransaction(); |
|
| 330 | + } |
|
| 282 | 331 | while (!feof($fh)) { |
| 283 | 332 | $values = array(); |
| 284 | 333 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -289,7 +338,9 @@ discard block |
||
| 289 | 338 | // Check if we can find ICAO, else set it to GLID |
| 290 | 339 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 291 | 340 | $search_more = ''; |
| 292 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 341 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 342 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 343 | + } |
|
| 293 | 344 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 294 | 345 | $sth_search = $Connection->db->prepare($query_search); |
| 295 | 346 | try { |
@@ -302,7 +353,9 @@ discard block |
||
| 302 | 353 | } catch(PDOException $e) { |
| 303 | 354 | return "error : ".$e->getMessage(); |
| 304 | 355 | } |
| 305 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
| 356 | + if (!isset($values['ICAOTypeCode'])) { |
|
| 357 | + $values['ICAOTypeCode'] = 'GLID'; |
|
| 358 | + } |
|
| 306 | 359 | // Add data to db |
| 307 | 360 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
| 308 | 361 | //$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']); |
@@ -311,7 +364,9 @@ discard block |
||
| 311 | 364 | $sth_dest->execute($query_dest_values); |
| 312 | 365 | } |
| 313 | 366 | } |
| 314 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 367 | + if ($globalTransaction) { |
|
| 368 | + $Connection->db->commit(); |
|
| 369 | + } |
|
| 315 | 370 | } catch(PDOException $e) { |
| 316 | 371 | return "error : ".$e->getMessage(); |
| 317 | 372 | } |
@@ -347,7 +402,9 @@ discard block |
||
| 347 | 402 | $Connection = new Connection(); |
| 348 | 403 | $sth_dest = $Connection->db->prepare($query_dest); |
| 349 | 404 | try { |
| 350 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 405 | + if ($globalTransaction) { |
|
| 406 | + $Connection->db->beginTransaction(); |
|
| 407 | + } |
|
| 351 | 408 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 352 | 409 | while (!feof($fh)) { |
| 353 | 410 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -361,13 +418,17 @@ discard block |
||
| 361 | 418 | // Check if we can find ICAO, else set it to GLID |
| 362 | 419 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 363 | 420 | $search_more = ''; |
| 364 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 421 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 422 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 423 | + } |
|
| 365 | 424 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 366 | 425 | $sth_search = $Connection->db->prepare($query_search); |
| 367 | 426 | try { |
| 368 | 427 | $sth_search->execute(); |
| 369 | 428 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 370 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 429 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 430 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 431 | + } |
|
| 371 | 432 | } catch(PDOException $e) { |
| 372 | 433 | return "error : ".$e->getMessage(); |
| 373 | 434 | } |
@@ -380,7 +441,9 @@ discard block |
||
| 380 | 441 | $sth_dest->execute($query_dest_values); |
| 381 | 442 | } |
| 382 | 443 | } |
| 383 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 444 | + if ($globalTransaction) { |
|
| 445 | + $Connection->db->commit(); |
|
| 446 | + } |
|
| 384 | 447 | } catch(PDOException $e) { |
| 385 | 448 | return "error : ".$e->getMessage(); |
| 386 | 449 | } |
@@ -419,7 +482,9 @@ discard block |
||
| 419 | 482 | $sth_dest = $Connection->db->prepare($query_dest); |
| 420 | 483 | $sth_modes = $Connection->db->prepare($query_modes); |
| 421 | 484 | try { |
| 422 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 485 | + if ($globalTransaction) { |
|
| 486 | + $Connection->db->beginTransaction(); |
|
| 487 | + } |
|
| 423 | 488 | $tmp = fgetcsv($fh,9999,',','"'); |
| 424 | 489 | while (!feof($fh)) { |
| 425 | 490 | $line = fgetcsv($fh,9999,',','"'); |
@@ -429,16 +494,22 @@ discard block |
||
| 429 | 494 | $values['registration'] = $line[0]; |
| 430 | 495 | $values['base'] = $line[4]; |
| 431 | 496 | $values['owner'] = $line[5]; |
| 432 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 433 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 497 | + if ($line[6] == '') { |
|
| 498 | + $values['date_first_reg'] = null; |
|
| 499 | + } else { |
|
| 500 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 501 | + } |
|
| 434 | 502 | $values['cancel'] = $line[7]; |
| 435 | 503 | } elseif ($country == 'EI') { |
| 436 | 504 | // TODO : add modeS & reg to aircraft_modes |
| 437 | 505 | $values['registration'] = $line[0]; |
| 438 | 506 | $values['base'] = $line[3]; |
| 439 | 507 | $values['owner'] = $line[2]; |
| 440 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 441 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 508 | + if ($line[1] == '') { |
|
| 509 | + $values['date_first_reg'] = null; |
|
| 510 | + } else { |
|
| 511 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 512 | + } |
|
| 442 | 513 | $values['cancel'] = ''; |
| 443 | 514 | $values['modes'] = $line[7]; |
| 444 | 515 | $values['icao'] = $line[8]; |
@@ -457,16 +528,22 @@ discard block |
||
| 457 | 528 | $values['registration'] = $line[3]; |
| 458 | 529 | $values['base'] = null; |
| 459 | 530 | $values['owner'] = $line[5]; |
| 460 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 461 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 531 | + if ($line[18] == '') { |
|
| 532 | + $values['date_first_reg'] = null; |
|
| 533 | + } else { |
|
| 534 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 535 | + } |
|
| 462 | 536 | $values['cancel'] = ''; |
| 463 | 537 | } elseif ($country == 'VH') { |
| 464 | 538 | // TODO : add modeS & reg to aircraft_modes |
| 465 | 539 | $values['registration'] = $line[0]; |
| 466 | 540 | $values['base'] = null; |
| 467 | 541 | $values['owner'] = $line[12]; |
| 468 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 469 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 542 | + if ($line[28] == '') { |
|
| 543 | + $values['date_first_reg'] = null; |
|
| 544 | + } else { |
|
| 545 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 546 | + } |
|
| 470 | 547 | |
| 471 | 548 | $values['cancel'] = $line[39]; |
| 472 | 549 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -485,29 +562,41 @@ discard block |
||
| 485 | 562 | $values['registration'] = $line[0]; |
| 486 | 563 | $values['base'] = null; |
| 487 | 564 | $values['owner'] = $line[8]; |
| 488 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 489 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 565 | + if ($line[7] == '') { |
|
| 566 | + $values['date_first_reg'] = null; |
|
| 567 | + } else { |
|
| 568 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 569 | + } |
|
| 490 | 570 | $values['cancel'] = ''; |
| 491 | 571 | } elseif ($country == 'PP') { |
| 492 | 572 | $values['registration'] = $line[0]; |
| 493 | 573 | $values['base'] = null; |
| 494 | 574 | $values['owner'] = $line[4]; |
| 495 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 496 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 575 | + if ($line[6] == '') { |
|
| 576 | + $values['date_first_reg'] = null; |
|
| 577 | + } else { |
|
| 578 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 579 | + } |
|
| 497 | 580 | $values['cancel'] = $line[7]; |
| 498 | 581 | } elseif ($country == 'E7') { |
| 499 | 582 | $values['registration'] = $line[0]; |
| 500 | 583 | $values['base'] = null; |
| 501 | 584 | $values['owner'] = $line[4]; |
| 502 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 503 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 585 | + if ($line[5] == '') { |
|
| 586 | + $values['date_first_reg'] = null; |
|
| 587 | + } else { |
|
| 588 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 589 | + } |
|
| 504 | 590 | $values['cancel'] = ''; |
| 505 | 591 | } elseif ($country == '8Q') { |
| 506 | 592 | $values['registration'] = $line[0]; |
| 507 | 593 | $values['base'] = null; |
| 508 | 594 | $values['owner'] = $line[3]; |
| 509 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 510 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 595 | + if ($line[7] == '') { |
|
| 596 | + $values['date_first_reg'] = null; |
|
| 597 | + } else { |
|
| 598 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 599 | + } |
|
| 511 | 600 | $values['cancel'] = ''; |
| 512 | 601 | } elseif ($country == 'ZK') { |
| 513 | 602 | $values['registration'] = $line[0]; |
@@ -552,7 +641,9 @@ discard block |
||
| 552 | 641 | $sth_modes->execute($query_modes_values); |
| 553 | 642 | } |
| 554 | 643 | } |
| 555 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 644 | + if ($globalTransaction) { |
|
| 645 | + $Connection->db->commit(); |
|
| 646 | + } |
|
| 556 | 647 | } catch(PDOException $e) { |
| 557 | 648 | return "error : ".$e->getMessage(); |
| 558 | 649 | } |
@@ -688,25 +779,45 @@ discard block |
||
| 688 | 779 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
| 689 | 780 | $Connection = new Connection(); |
| 690 | 781 | $sth_dest = $Connection->db->prepare($query_dest); |
| 691 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 782 | + if ($globalTransaction) { |
|
| 783 | + $Connection->db->beginTransaction(); |
|
| 784 | + } |
|
| 692 | 785 | |
| 693 | 786 | $i = 0; |
| 694 | 787 | while($row = sparql_fetch_array($result)) |
| 695 | 788 | { |
| 696 | 789 | if ($i >= 1) { |
| 697 | 790 | //print_r($row); |
| 698 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
| 699 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
| 700 | - if (!isset($row['type'])) $row['type'] = ''; |
|
| 701 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
| 791 | + if (!isset($row['iata'])) { |
|
| 792 | + $row['iata'] = ''; |
|
| 793 | + } |
|
| 794 | + if (!isset($row['icao'])) { |
|
| 795 | + $row['icao'] = ''; |
|
| 796 | + } |
|
| 797 | + if (!isset($row['type'])) { |
|
| 798 | + $row['type'] = ''; |
|
| 799 | + } |
|
| 800 | + if (!isset($row['altitude'])) { |
|
| 801 | + $row['altitude'] = ''; |
|
| 802 | + } |
|
| 702 | 803 | if (isset($row['city_bis'])) { |
| 703 | 804 | $row['city'] = $row['city_bis']; |
| 704 | 805 | } |
| 705 | - if (!isset($row['city'])) $row['city'] = ''; |
|
| 706 | - if (!isset($row['country'])) $row['country'] = ''; |
|
| 707 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
| 708 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
| 709 | - if (!isset($row['name'])) continue; |
|
| 806 | + if (!isset($row['city'])) { |
|
| 807 | + $row['city'] = ''; |
|
| 808 | + } |
|
| 809 | + if (!isset($row['country'])) { |
|
| 810 | + $row['country'] = ''; |
|
| 811 | + } |
|
| 812 | + if (!isset($row['homepage'])) { |
|
| 813 | + $row['homepage'] = ''; |
|
| 814 | + } |
|
| 815 | + if (!isset($row['wikipedia_page'])) { |
|
| 816 | + $row['wikipedia_page'] = ''; |
|
| 817 | + } |
|
| 818 | + if (!isset($row['name'])) { |
|
| 819 | + continue; |
|
| 820 | + } |
|
| 710 | 821 | if (!isset($row['image'])) { |
| 711 | 822 | $row['image'] = ''; |
| 712 | 823 | $row['image_thumb'] = ''; |
@@ -762,7 +873,9 @@ discard block |
||
| 762 | 873 | |
| 763 | 874 | $i++; |
| 764 | 875 | } |
| 765 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 876 | + if ($globalTransaction) { |
|
| 877 | + $Connection->db->commit(); |
|
| 878 | + } |
|
| 766 | 879 | /* |
| 767 | 880 | echo "Delete duplicate rows...\n"; |
| 768 | 881 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
@@ -805,7 +918,9 @@ discard block |
||
| 805 | 918 | $delimiter = ','; |
| 806 | 919 | $out_file = $tmp_dir.'airports.csv'; |
| 807 | 920 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
| 808 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 921 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 922 | + return FALSE; |
|
| 923 | + } |
|
| 809 | 924 | echo "Add data from ourairports.com...\n"; |
| 810 | 925 | |
| 811 | 926 | $header = NULL; |
@@ -815,8 +930,9 @@ discard block |
||
| 815 | 930 | //$Connection->db->beginTransaction(); |
| 816 | 931 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 817 | 932 | { |
| 818 | - if(!$header) $header = $row; |
|
| 819 | - else { |
|
| 933 | + if(!$header) { |
|
| 934 | + $header = $row; |
|
| 935 | + } else { |
|
| 820 | 936 | $data = array(); |
| 821 | 937 | $data = array_combine($header, $row); |
| 822 | 938 | try { |
@@ -857,7 +973,9 @@ discard block |
||
| 857 | 973 | echo "Download data from another free database...\n"; |
| 858 | 974 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 859 | 975 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
| 860 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 976 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 977 | + return FALSE; |
|
| 978 | + } |
|
| 861 | 979 | update_db::unzip($out_file); |
| 862 | 980 | $header = NULL; |
| 863 | 981 | echo "Add data from another free database...\n"; |
@@ -868,8 +986,9 @@ discard block |
||
| 868 | 986 | //$Connection->db->beginTransaction(); |
| 869 | 987 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 870 | 988 | { |
| 871 | - if(!$header) $header = $row; |
|
| 872 | - else { |
|
| 989 | + if(!$header) { |
|
| 990 | + $header = $row; |
|
| 991 | + } else { |
|
| 873 | 992 | $data = $row; |
| 874 | 993 | |
| 875 | 994 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
@@ -1042,7 +1161,9 @@ discard block |
||
| 1042 | 1161 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
| 1043 | 1162 | { |
| 1044 | 1163 | $i = 0; |
| 1045 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1164 | + if ($globalTransaction) { |
|
| 1165 | + $Connection->db->beginTransaction(); |
|
| 1166 | + } |
|
| 1046 | 1167 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1047 | 1168 | { |
| 1048 | 1169 | if ($i > 0) { |
@@ -1055,7 +1176,9 @@ discard block |
||
| 1055 | 1176 | } |
| 1056 | 1177 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
| 1057 | 1178 | if (!empty($result_search)) { |
| 1058 | - if ($globalDebug) echo '.'; |
|
| 1179 | + if ($globalDebug) { |
|
| 1180 | + echo '.'; |
|
| 1181 | + } |
|
| 1059 | 1182 | //if ($globalDBdriver == 'mysql') { |
| 1060 | 1183 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
| 1061 | 1184 | //} else { |
@@ -1077,8 +1200,12 @@ discard block |
||
| 1077 | 1200 | } |
| 1078 | 1201 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
| 1079 | 1202 | if (!empty($result_search_mfr)) { |
| 1080 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
| 1081 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
| 1203 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
| 1204 | + $data[16] = $data[23]; |
|
| 1205 | + } |
|
| 1206 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
| 1207 | + $data[16] = $data[15]; |
|
| 1208 | + } |
|
| 1082 | 1209 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
| 1083 | 1210 | try { |
| 1084 | 1211 | $sthf = $Connection->db->prepare($queryf); |
@@ -1089,7 +1216,9 @@ discard block |
||
| 1089 | 1216 | } |
| 1090 | 1217 | } |
| 1091 | 1218 | if (strtotime($data[29]) > time()) { |
| 1092 | - if ($globalDebug) echo 'i'; |
|
| 1219 | + if ($globalDebug) { |
|
| 1220 | + echo 'i'; |
|
| 1221 | + } |
|
| 1093 | 1222 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 1094 | 1223 | try { |
| 1095 | 1224 | $sth = $Connection->db->prepare($query); |
@@ -1100,13 +1229,19 @@ discard block |
||
| 1100 | 1229 | } |
| 1101 | 1230 | } |
| 1102 | 1231 | if ($i % 90 == 0) { |
| 1103 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1104 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1232 | + if ($globalTransaction) { |
|
| 1233 | + $Connection->db->commit(); |
|
| 1234 | + } |
|
| 1235 | + if ($globalTransaction) { |
|
| 1236 | + $Connection->db->beginTransaction(); |
|
| 1237 | + } |
|
| 1105 | 1238 | } |
| 1106 | 1239 | $i++; |
| 1107 | 1240 | } |
| 1108 | 1241 | fclose($handle); |
| 1109 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1242 | + if ($globalTransaction) { |
|
| 1243 | + $Connection->db->commit(); |
|
| 1244 | + } |
|
| 1110 | 1245 | } |
| 1111 | 1246 | print_r($mfr); |
| 1112 | 1247 | return ''; |
@@ -1131,11 +1266,15 @@ discard block |
||
| 1131 | 1266 | $i = 0; |
| 1132 | 1267 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1133 | 1268 | //$Connection->db->beginTransaction(); |
| 1134 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1269 | + if ($globalTransaction) { |
|
| 1270 | + $Connection->db->beginTransaction(); |
|
| 1271 | + } |
|
| 1135 | 1272 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1136 | 1273 | { |
| 1137 | 1274 | if ($i > 0) { |
| 1138 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
| 1275 | + if ($data[1] == 'NULL') { |
|
| 1276 | + $data[1] = $data[0]; |
|
| 1277 | + } |
|
| 1139 | 1278 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
| 1140 | 1279 | try { |
| 1141 | 1280 | $sth = $Connection->db->prepare($query); |
@@ -1147,7 +1286,9 @@ discard block |
||
| 1147 | 1286 | $i++; |
| 1148 | 1287 | } |
| 1149 | 1288 | fclose($handle); |
| 1150 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1289 | + if ($globalTransaction) { |
|
| 1290 | + $Connection->db->commit(); |
|
| 1291 | + } |
|
| 1151 | 1292 | } |
| 1152 | 1293 | return ''; |
| 1153 | 1294 | } |
@@ -1168,7 +1309,9 @@ discard block |
||
| 1168 | 1309 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
| 1169 | 1310 | { |
| 1170 | 1311 | $i = 0; |
| 1171 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1312 | + if ($globalTransaction) { |
|
| 1313 | + $Connection->db->beginTransaction(); |
|
| 1314 | + } |
|
| 1172 | 1315 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1173 | 1316 | { |
| 1174 | 1317 | if ($i > 0) { |
@@ -1184,7 +1327,9 @@ discard block |
||
| 1184 | 1327 | $i++; |
| 1185 | 1328 | } |
| 1186 | 1329 | fclose($handle); |
| 1187 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1330 | + if ($globalTransaction) { |
|
| 1331 | + $Connection->db->commit(); |
|
| 1332 | + } |
|
| 1188 | 1333 | } |
| 1189 | 1334 | return ''; |
| 1190 | 1335 | } |
@@ -1204,7 +1349,9 @@ discard block |
||
| 1204 | 1349 | if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE) |
| 1205 | 1350 | { |
| 1206 | 1351 | $i = 0; |
| 1207 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1352 | + if ($globalTransaction) { |
|
| 1353 | + $Connection->db->beginTransaction(); |
|
| 1354 | + } |
|
| 1208 | 1355 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1209 | 1356 | { |
| 1210 | 1357 | if ($i > 0) { |
@@ -1213,13 +1360,17 @@ discard block |
||
| 1213 | 1360 | $sth = $Connection->db->prepare($query); |
| 1214 | 1361 | $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')); |
| 1215 | 1362 | } catch(PDOException $e) { |
| 1216 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1363 | + if ($globalDebug) { |
|
| 1364 | + echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
| 1365 | + } |
|
| 1217 | 1366 | } |
| 1218 | 1367 | } |
| 1219 | 1368 | $i++; |
| 1220 | 1369 | } |
| 1221 | 1370 | fclose($handle); |
| 1222 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1371 | + if ($globalTransaction) { |
|
| 1372 | + $Connection->db->commit(); |
|
| 1373 | + } |
|
| 1223 | 1374 | } |
| 1224 | 1375 | return ''; |
| 1225 | 1376 | } |
@@ -1244,7 +1395,9 @@ discard block |
||
| 1244 | 1395 | $i = 0; |
| 1245 | 1396 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
| 1246 | 1397 | //$Connection->db->beginTransaction(); |
| 1247 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1398 | + if ($globalTransaction) { |
|
| 1399 | + $Connection->db->beginTransaction(); |
|
| 1400 | + } |
|
| 1248 | 1401 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1249 | 1402 | { |
| 1250 | 1403 | if ($i > 0) { |
@@ -1260,7 +1413,9 @@ discard block |
||
| 1260 | 1413 | $i++; |
| 1261 | 1414 | } |
| 1262 | 1415 | fclose($handle); |
| 1263 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1416 | + if ($globalTransaction) { |
|
| 1417 | + $Connection->db->commit(); |
|
| 1418 | + } |
|
| 1264 | 1419 | } |
| 1265 | 1420 | return ''; |
| 1266 | 1421 | } |
@@ -1279,7 +1434,9 @@ discard block |
||
| 1279 | 1434 | $Connection = new Connection(); |
| 1280 | 1435 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
| 1281 | 1436 | { |
| 1282 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1437 | + if ($globalTransaction) { |
|
| 1438 | + $Connection->db->beginTransaction(); |
|
| 1439 | + } |
|
| 1283 | 1440 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
| 1284 | 1441 | { |
| 1285 | 1442 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1294,7 +1451,9 @@ discard block |
||
| 1294 | 1451 | } |
| 1295 | 1452 | } |
| 1296 | 1453 | fclose($handle); |
| 1297 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1454 | + if ($globalTransaction) { |
|
| 1455 | + $Connection->db->commit(); |
|
| 1456 | + } |
|
| 1298 | 1457 | } |
| 1299 | 1458 | return ''; |
| 1300 | 1459 | } |
@@ -1445,7 +1604,9 @@ discard block |
||
| 1445 | 1604 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1446 | 1605 | { |
| 1447 | 1606 | $i = 0; |
| 1448 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1607 | + if ($globalTransaction) { |
|
| 1608 | + $Connection->db->beginTransaction(); |
|
| 1609 | + } |
|
| 1449 | 1610 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1450 | 1611 | { |
| 1451 | 1612 | $i++; |
@@ -1473,7 +1634,9 @@ discard block |
||
| 1473 | 1634 | } |
| 1474 | 1635 | } |
| 1475 | 1636 | fclose($handle); |
| 1476 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1637 | + if ($globalTransaction) { |
|
| 1638 | + $Connection->db->commit(); |
|
| 1639 | + } |
|
| 1477 | 1640 | } |
| 1478 | 1641 | return ''; |
| 1479 | 1642 | } |
@@ -1496,7 +1659,9 @@ discard block |
||
| 1496 | 1659 | $Connection = new Connection(); |
| 1497 | 1660 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1498 | 1661 | { |
| 1499 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1662 | + if ($globalTransaction) { |
|
| 1663 | + $Connection->db->beginTransaction(); |
|
| 1664 | + } |
|
| 1500 | 1665 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1501 | 1666 | { |
| 1502 | 1667 | if(count($row) > 1) { |
@@ -1510,7 +1675,9 @@ discard block |
||
| 1510 | 1675 | } |
| 1511 | 1676 | } |
| 1512 | 1677 | fclose($handle); |
| 1513 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1678 | + if ($globalTransaction) { |
|
| 1679 | + $Connection->db->commit(); |
|
| 1680 | + } |
|
| 1514 | 1681 | } |
| 1515 | 1682 | return ''; |
| 1516 | 1683 | } |
@@ -1530,8 +1697,9 @@ discard block |
||
| 1530 | 1697 | } |
| 1531 | 1698 | |
| 1532 | 1699 | |
| 1533 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1534 | - else { |
|
| 1700 | + if ($globalDBdriver == 'mysql') { |
|
| 1701 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1702 | + } else { |
|
| 1535 | 1703 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
| 1536 | 1704 | $query = "CREATE EXTENSION postgis"; |
| 1537 | 1705 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1550,20 +1718,30 @@ discard block |
||
| 1550 | 1718 | global $tmp_dir, $globalDebug; |
| 1551 | 1719 | include_once('class.create_db.php'); |
| 1552 | 1720 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1553 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1721 | + if ($globalDebug) { |
|
| 1722 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1723 | + } |
|
| 1554 | 1724 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
| 1555 | 1725 | $error = ''; |
| 1556 | 1726 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1557 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1727 | + if ($globalDebug) { |
|
| 1728 | + echo "Gunzip..."; |
|
| 1729 | + } |
|
| 1558 | 1730 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
| 1559 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1731 | + if ($globalDebug) { |
|
| 1732 | + echo "Add to DB..."; |
|
| 1733 | + } |
|
| 1560 | 1734 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
| 1561 | 1735 | $NOTAM = new NOTAM(); |
| 1562 | 1736 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
| 1563 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1737 | + } else { |
|
| 1738 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1739 | + } |
|
| 1564 | 1740 | if ($error != '') { |
| 1565 | 1741 | return $error; |
| 1566 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1742 | + } elseif ($globalDebug) { |
|
| 1743 | + echo "Done\n"; |
|
| 1744 | + } |
|
| 1567 | 1745 | return ''; |
| 1568 | 1746 | } |
| 1569 | 1747 | |
@@ -1617,67 +1795,111 @@ discard block |
||
| 1617 | 1795 | //if ($globalDebug) echo "IVAO : Download..."; |
| 1618 | 1796 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
| 1619 | 1797 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
| 1620 | - if ($globalDebug) echo "Unzip..."; |
|
| 1798 | + if ($globalDebug) { |
|
| 1799 | + echo "Unzip..."; |
|
| 1800 | + } |
|
| 1621 | 1801 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
| 1622 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1802 | + if ($globalDebug) { |
|
| 1803 | + echo "Add to DB..."; |
|
| 1804 | + } |
|
| 1623 | 1805 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1624 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
| 1806 | + if ($globalDebug) { |
|
| 1807 | + echo "Copy airlines logos to airlines images directory..."; |
|
| 1808 | + } |
|
| 1625 | 1809 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1626 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1627 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1628 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1810 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
| 1811 | + $error = "Failed to copy airlines logo."; |
|
| 1812 | + } |
|
| 1813 | + } else { |
|
| 1814 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1815 | + } |
|
| 1816 | + } else { |
|
| 1817 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1818 | + } |
|
| 1629 | 1819 | if ($error != '') { |
| 1630 | 1820 | return $error; |
| 1631 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1821 | + } elseif ($globalDebug) { |
|
| 1822 | + echo "Done\n"; |
|
| 1823 | + } |
|
| 1632 | 1824 | return ''; |
| 1633 | 1825 | } |
| 1634 | 1826 | |
| 1635 | 1827 | public static function update_routes() { |
| 1636 | 1828 | global $tmp_dir, $globalDebug; |
| 1637 | 1829 | $error = ''; |
| 1638 | - if ($globalDebug) echo "Routes : Download..."; |
|
| 1830 | + if ($globalDebug) { |
|
| 1831 | + echo "Routes : Download..."; |
|
| 1832 | + } |
|
| 1639 | 1833 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
| 1640 | 1834 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1641 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1835 | + if ($globalDebug) { |
|
| 1836 | + echo "Gunzip..."; |
|
| 1837 | + } |
|
| 1642 | 1838 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
| 1643 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1839 | + if ($globalDebug) { |
|
| 1840 | + echo "Add to DB..."; |
|
| 1841 | + } |
|
| 1644 | 1842 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
| 1645 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1843 | + } else { |
|
| 1844 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1845 | + } |
|
| 1646 | 1846 | if ($error != '') { |
| 1647 | 1847 | return $error; |
| 1648 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1848 | + } elseif ($globalDebug) { |
|
| 1849 | + echo "Done\n"; |
|
| 1850 | + } |
|
| 1649 | 1851 | return ''; |
| 1650 | 1852 | } |
| 1651 | 1853 | public static function update_oneworld() { |
| 1652 | 1854 | global $tmp_dir, $globalDebug; |
| 1653 | 1855 | $error = ''; |
| 1654 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
| 1856 | + if ($globalDebug) { |
|
| 1857 | + echo "Schedules Oneworld : Download..."; |
|
| 1858 | + } |
|
| 1655 | 1859 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
| 1656 | 1860 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1657 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1861 | + if ($globalDebug) { |
|
| 1862 | + echo "Gunzip..."; |
|
| 1863 | + } |
|
| 1658 | 1864 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
| 1659 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1865 | + if ($globalDebug) { |
|
| 1866 | + echo "Add to DB..."; |
|
| 1867 | + } |
|
| 1660 | 1868 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
| 1661 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1869 | + } else { |
|
| 1870 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1871 | + } |
|
| 1662 | 1872 | if ($error != '') { |
| 1663 | 1873 | return $error; |
| 1664 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1874 | + } elseif ($globalDebug) { |
|
| 1875 | + echo "Done\n"; |
|
| 1876 | + } |
|
| 1665 | 1877 | return ''; |
| 1666 | 1878 | } |
| 1667 | 1879 | public static function update_skyteam() { |
| 1668 | 1880 | global $tmp_dir, $globalDebug; |
| 1669 | 1881 | $error = ''; |
| 1670 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
| 1882 | + if ($globalDebug) { |
|
| 1883 | + echo "Schedules Skyteam : Download..."; |
|
| 1884 | + } |
|
| 1671 | 1885 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
| 1672 | 1886 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 1673 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1887 | + if ($globalDebug) { |
|
| 1888 | + echo "Gunzip..."; |
|
| 1889 | + } |
|
| 1674 | 1890 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
| 1675 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1891 | + if ($globalDebug) { |
|
| 1892 | + echo "Add to DB..."; |
|
| 1893 | + } |
|
| 1676 | 1894 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
| 1677 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1895 | + } else { |
|
| 1896 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1897 | + } |
|
| 1678 | 1898 | if ($error != '') { |
| 1679 | 1899 | return $error; |
| 1680 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1900 | + } elseif ($globalDebug) { |
|
| 1901 | + echo "Done\n"; |
|
| 1902 | + } |
|
| 1681 | 1903 | return ''; |
| 1682 | 1904 | } |
| 1683 | 1905 | public static function update_ModeS() { |
@@ -1694,355 +1916,619 @@ discard block |
||
| 1694 | 1916 | exit; |
| 1695 | 1917 | } elseif ($globalDebug) echo "Done\n"; |
| 1696 | 1918 | */ |
| 1697 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 1698 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 1919 | + if ($globalDebug) { |
|
| 1920 | + echo "Modes : Download..."; |
|
| 1921 | + } |
|
| 1922 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 1699 | 1923 | update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
| 1700 | 1924 | |
| 1701 | 1925 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1702 | 1926 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
| 1703 | - if ($globalDebug) echo "Unzip..."; |
|
| 1704 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 1927 | + if ($globalDebug) { |
|
| 1928 | + echo "Unzip..."; |
|
| 1929 | + } |
|
| 1930 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
| 1705 | 1931 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
| 1706 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1932 | + if ($globalDebug) { |
|
| 1933 | + echo "Add to DB..."; |
|
| 1934 | + } |
|
| 1707 | 1935 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 1708 | 1936 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
| 1709 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1937 | + } else { |
|
| 1938 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1939 | + } |
|
| 1710 | 1940 | if ($error != '') { |
| 1711 | 1941 | return $error; |
| 1712 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1942 | + } elseif ($globalDebug) { |
|
| 1943 | + echo "Done\n"; |
|
| 1944 | + } |
|
| 1713 | 1945 | return ''; |
| 1714 | 1946 | } |
| 1715 | 1947 | |
| 1716 | 1948 | public static function update_ModeS_faa() { |
| 1717 | 1949 | global $tmp_dir, $globalDebug; |
| 1718 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
| 1950 | + if ($globalDebug) { |
|
| 1951 | + echo "Modes FAA: Download..."; |
|
| 1952 | + } |
|
| 1719 | 1953 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
| 1720 | 1954 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
| 1721 | - if ($globalDebug) echo "Unzip..."; |
|
| 1955 | + if ($globalDebug) { |
|
| 1956 | + echo "Unzip..."; |
|
| 1957 | + } |
|
| 1722 | 1958 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
| 1723 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1959 | + if ($globalDebug) { |
|
| 1960 | + echo "Add to DB..."; |
|
| 1961 | + } |
|
| 1724 | 1962 | $error = update_db::modes_faa(); |
| 1725 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 1963 | + } else { |
|
| 1964 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
| 1965 | + } |
|
| 1726 | 1966 | if ($error != '') { |
| 1727 | 1967 | return $error; |
| 1728 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1968 | + } elseif ($globalDebug) { |
|
| 1969 | + echo "Done\n"; |
|
| 1970 | + } |
|
| 1729 | 1971 | return ''; |
| 1730 | 1972 | } |
| 1731 | 1973 | |
| 1732 | 1974 | public static function update_ModeS_flarm() { |
| 1733 | 1975 | global $tmp_dir, $globalDebug; |
| 1734 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 1976 | + if ($globalDebug) { |
|
| 1977 | + echo "Modes Flarmnet: Download..."; |
|
| 1978 | + } |
|
| 1735 | 1979 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 1736 | 1980 | if (file_exists($tmp_dir.'data.fln')) { |
| 1737 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1981 | + if ($globalDebug) { |
|
| 1982 | + echo "Add to DB..."; |
|
| 1983 | + } |
|
| 1738 | 1984 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 1739 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1985 | + } else { |
|
| 1986 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1987 | + } |
|
| 1740 | 1988 | if ($error != '') { |
| 1741 | 1989 | return $error; |
| 1742 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1990 | + } elseif ($globalDebug) { |
|
| 1991 | + echo "Done\n"; |
|
| 1992 | + } |
|
| 1743 | 1993 | return ''; |
| 1744 | 1994 | } |
| 1745 | 1995 | |
| 1746 | 1996 | public static function update_ModeS_ogn() { |
| 1747 | 1997 | global $tmp_dir, $globalDebug; |
| 1748 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 1998 | + if ($globalDebug) { |
|
| 1999 | + echo "Modes OGN: Download..."; |
|
| 2000 | + } |
|
| 1749 | 2001 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 1750 | 2002 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1751 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2003 | + if ($globalDebug) { |
|
| 2004 | + echo "Add to DB..."; |
|
| 2005 | + } |
|
| 1752 | 2006 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 1753 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2007 | + } else { |
|
| 2008 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 2009 | + } |
|
| 1754 | 2010 | if ($error != '') { |
| 1755 | 2011 | return $error; |
| 1756 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2012 | + } elseif ($globalDebug) { |
|
| 2013 | + echo "Done\n"; |
|
| 2014 | + } |
|
| 1757 | 2015 | return ''; |
| 1758 | 2016 | } |
| 1759 | 2017 | |
| 1760 | 2018 | public static function update_owner() { |
| 1761 | 2019 | global $tmp_dir, $globalDebug, $globalMasterSource; |
| 1762 | 2020 | |
| 1763 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 2021 | + if ($globalDebug) { |
|
| 2022 | + echo "Owner France: Download..."; |
|
| 2023 | + } |
|
| 1764 | 2024 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 1765 | 2025 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1766 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2026 | + if ($globalDebug) { |
|
| 2027 | + echo "Add to DB..."; |
|
| 2028 | + } |
|
| 1767 | 2029 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 1768 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2030 | + } else { |
|
| 2031 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 2032 | + } |
|
| 1769 | 2033 | if ($error != '') { |
| 1770 | 2034 | return $error; |
| 1771 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2035 | + } elseif ($globalDebug) { |
|
| 2036 | + echo "Done\n"; |
|
| 2037 | + } |
|
| 1772 | 2038 | |
| 1773 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 2039 | + if ($globalDebug) { |
|
| 2040 | + echo "Owner Ireland: Download..."; |
|
| 2041 | + } |
|
| 1774 | 2042 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 1775 | 2043 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1776 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2044 | + if ($globalDebug) { |
|
| 2045 | + echo "Add to DB..."; |
|
| 2046 | + } |
|
| 1777 | 2047 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 1778 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2048 | + } else { |
|
| 2049 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 2050 | + } |
|
| 1779 | 2051 | if ($error != '') { |
| 1780 | 2052 | return $error; |
| 1781 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1782 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 2053 | + } elseif ($globalDebug) { |
|
| 2054 | + echo "Done\n"; |
|
| 2055 | + } |
|
| 2056 | + if ($globalDebug) { |
|
| 2057 | + echo "Owner Switzerland: Download..."; |
|
| 2058 | + } |
|
| 1783 | 2059 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 1784 | 2060 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1785 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2061 | + if ($globalDebug) { |
|
| 2062 | + echo "Add to DB..."; |
|
| 2063 | + } |
|
| 1786 | 2064 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 1787 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2065 | + } else { |
|
| 2066 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 2067 | + } |
|
| 1788 | 2068 | if ($error != '') { |
| 1789 | 2069 | return $error; |
| 1790 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1791 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 2070 | + } elseif ($globalDebug) { |
|
| 2071 | + echo "Done\n"; |
|
| 2072 | + } |
|
| 2073 | + if ($globalDebug) { |
|
| 2074 | + echo "Owner Czech Republic: Download..."; |
|
| 2075 | + } |
|
| 1792 | 2076 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 1793 | 2077 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1794 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2078 | + if ($globalDebug) { |
|
| 2079 | + echo "Add to DB..."; |
|
| 2080 | + } |
|
| 1795 | 2081 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 1796 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2082 | + } else { |
|
| 2083 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 2084 | + } |
|
| 1797 | 2085 | if ($error != '') { |
| 1798 | 2086 | return $error; |
| 1799 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1800 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 2087 | + } elseif ($globalDebug) { |
|
| 2088 | + echo "Done\n"; |
|
| 2089 | + } |
|
| 2090 | + if ($globalDebug) { |
|
| 2091 | + echo "Owner Australia: Download..."; |
|
| 2092 | + } |
|
| 1801 | 2093 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 1802 | 2094 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1803 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2095 | + if ($globalDebug) { |
|
| 2096 | + echo "Add to DB..."; |
|
| 2097 | + } |
|
| 1804 | 2098 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 1805 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2099 | + } else { |
|
| 2100 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 2101 | + } |
|
| 1806 | 2102 | if ($error != '') { |
| 1807 | 2103 | return $error; |
| 1808 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1809 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 2104 | + } elseif ($globalDebug) { |
|
| 2105 | + echo "Done\n"; |
|
| 2106 | + } |
|
| 2107 | + if ($globalDebug) { |
|
| 2108 | + echo "Owner Austria: Download..."; |
|
| 2109 | + } |
|
| 1810 | 2110 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 1811 | 2111 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1812 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2112 | + if ($globalDebug) { |
|
| 2113 | + echo "Add to DB..."; |
|
| 2114 | + } |
|
| 1813 | 2115 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 1814 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2116 | + } else { |
|
| 2117 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 2118 | + } |
|
| 1815 | 2119 | if ($error != '') { |
| 1816 | 2120 | return $error; |
| 1817 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1818 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 2121 | + } elseif ($globalDebug) { |
|
| 2122 | + echo "Done\n"; |
|
| 2123 | + } |
|
| 2124 | + if ($globalDebug) { |
|
| 2125 | + echo "Owner Chile: Download..."; |
|
| 2126 | + } |
|
| 1819 | 2127 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 1820 | 2128 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1821 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2129 | + if ($globalDebug) { |
|
| 2130 | + echo "Add to DB..."; |
|
| 2131 | + } |
|
| 1822 | 2132 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 1823 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2133 | + } else { |
|
| 2134 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 2135 | + } |
|
| 1824 | 2136 | if ($error != '') { |
| 1825 | 2137 | return $error; |
| 1826 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1827 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 2138 | + } elseif ($globalDebug) { |
|
| 2139 | + echo "Done\n"; |
|
| 2140 | + } |
|
| 2141 | + if ($globalDebug) { |
|
| 2142 | + echo "Owner Colombia: Download..."; |
|
| 2143 | + } |
|
| 1828 | 2144 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 1829 | 2145 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1830 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2146 | + if ($globalDebug) { |
|
| 2147 | + echo "Add to DB..."; |
|
| 2148 | + } |
|
| 1831 | 2149 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 1832 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2150 | + } else { |
|
| 2151 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 2152 | + } |
|
| 1833 | 2153 | if ($error != '') { |
| 1834 | 2154 | return $error; |
| 1835 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1836 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2155 | + } elseif ($globalDebug) { |
|
| 2156 | + echo "Done\n"; |
|
| 2157 | + } |
|
| 2158 | + if ($globalDebug) { |
|
| 2159 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 2160 | + } |
|
| 1837 | 2161 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 1838 | 2162 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1839 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2163 | + if ($globalDebug) { |
|
| 2164 | + echo "Add to DB..."; |
|
| 2165 | + } |
|
| 1840 | 2166 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 1841 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2167 | + } else { |
|
| 2168 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 2169 | + } |
|
| 1842 | 2170 | if ($error != '') { |
| 1843 | 2171 | return $error; |
| 1844 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1845 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 2172 | + } elseif ($globalDebug) { |
|
| 2173 | + echo "Done\n"; |
|
| 2174 | + } |
|
| 2175 | + if ($globalDebug) { |
|
| 2176 | + echo "Owner Brazil: Download..."; |
|
| 2177 | + } |
|
| 1846 | 2178 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 1847 | 2179 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1848 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2180 | + if ($globalDebug) { |
|
| 2181 | + echo "Add to DB..."; |
|
| 2182 | + } |
|
| 1849 | 2183 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 1850 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2184 | + } else { |
|
| 2185 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 2186 | + } |
|
| 1851 | 2187 | if ($error != '') { |
| 1852 | 2188 | return $error; |
| 1853 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1854 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 2189 | + } elseif ($globalDebug) { |
|
| 2190 | + echo "Done\n"; |
|
| 2191 | + } |
|
| 2192 | + if ($globalDebug) { |
|
| 2193 | + echo "Owner Cayman Islands: Download..."; |
|
| 2194 | + } |
|
| 1855 | 2195 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 1856 | 2196 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1857 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2197 | + if ($globalDebug) { |
|
| 2198 | + echo "Add to DB..."; |
|
| 2199 | + } |
|
| 1858 | 2200 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 1859 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2201 | + } else { |
|
| 2202 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 2203 | + } |
|
| 1860 | 2204 | if ($error != '') { |
| 1861 | 2205 | return $error; |
| 1862 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1863 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 2206 | + } elseif ($globalDebug) { |
|
| 2207 | + echo "Done\n"; |
|
| 2208 | + } |
|
| 2209 | + if ($globalDebug) { |
|
| 2210 | + echo "Owner Croatia: Download..."; |
|
| 2211 | + } |
|
| 1864 | 2212 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 1865 | 2213 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1866 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2214 | + if ($globalDebug) { |
|
| 2215 | + echo "Add to DB..."; |
|
| 2216 | + } |
|
| 1867 | 2217 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 1868 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2218 | + } else { |
|
| 2219 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 2220 | + } |
|
| 1869 | 2221 | if ($error != '') { |
| 1870 | 2222 | return $error; |
| 1871 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1872 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 2223 | + } elseif ($globalDebug) { |
|
| 2224 | + echo "Done\n"; |
|
| 2225 | + } |
|
| 2226 | + if ($globalDebug) { |
|
| 2227 | + echo "Owner Luxembourg: Download..."; |
|
| 2228 | + } |
|
| 1873 | 2229 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 1874 | 2230 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1875 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2231 | + if ($globalDebug) { |
|
| 2232 | + echo "Add to DB..."; |
|
| 2233 | + } |
|
| 1876 | 2234 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 1877 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2235 | + } else { |
|
| 2236 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 2237 | + } |
|
| 1878 | 2238 | if ($error != '') { |
| 1879 | 2239 | return $error; |
| 1880 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1881 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 2240 | + } elseif ($globalDebug) { |
|
| 2241 | + echo "Done\n"; |
|
| 2242 | + } |
|
| 2243 | + if ($globalDebug) { |
|
| 2244 | + echo "Owner Maldives: Download..."; |
|
| 2245 | + } |
|
| 1882 | 2246 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 1883 | 2247 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1884 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2248 | + if ($globalDebug) { |
|
| 2249 | + echo "Add to DB..."; |
|
| 2250 | + } |
|
| 1885 | 2251 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 1886 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2252 | + } else { |
|
| 2253 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 2254 | + } |
|
| 1887 | 2255 | if ($error != '') { |
| 1888 | 2256 | return $error; |
| 1889 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1890 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 2257 | + } elseif ($globalDebug) { |
|
| 2258 | + echo "Done\n"; |
|
| 2259 | + } |
|
| 2260 | + if ($globalDebug) { |
|
| 2261 | + echo "Owner New Zealand: Download..."; |
|
| 2262 | + } |
|
| 1891 | 2263 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 1892 | 2264 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1893 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2265 | + if ($globalDebug) { |
|
| 2266 | + echo "Add to DB..."; |
|
| 2267 | + } |
|
| 1894 | 2268 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 1895 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2269 | + } else { |
|
| 2270 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 2271 | + } |
|
| 1896 | 2272 | if ($error != '') { |
| 1897 | 2273 | return $error; |
| 1898 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1899 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 2274 | + } elseif ($globalDebug) { |
|
| 2275 | + echo "Done\n"; |
|
| 2276 | + } |
|
| 2277 | + if ($globalDebug) { |
|
| 2278 | + echo "Owner Papua New Guinea: Download..."; |
|
| 2279 | + } |
|
| 1900 | 2280 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 1901 | 2281 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1902 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2282 | + if ($globalDebug) { |
|
| 2283 | + echo "Add to DB..."; |
|
| 2284 | + } |
|
| 1903 | 2285 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 1904 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2286 | + } else { |
|
| 2287 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 2288 | + } |
|
| 1905 | 2289 | if ($error != '') { |
| 1906 | 2290 | return $error; |
| 1907 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1908 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 2291 | + } elseif ($globalDebug) { |
|
| 2292 | + echo "Done\n"; |
|
| 2293 | + } |
|
| 2294 | + if ($globalDebug) { |
|
| 2295 | + echo "Owner Slovakia: Download..."; |
|
| 2296 | + } |
|
| 1909 | 2297 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 1910 | 2298 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1911 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2299 | + if ($globalDebug) { |
|
| 2300 | + echo "Add to DB..."; |
|
| 2301 | + } |
|
| 1912 | 2302 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 1913 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2303 | + } else { |
|
| 2304 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 2305 | + } |
|
| 1914 | 2306 | if ($error != '') { |
| 1915 | 2307 | return $error; |
| 1916 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1917 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 2308 | + } elseif ($globalDebug) { |
|
| 2309 | + echo "Done\n"; |
|
| 2310 | + } |
|
| 2311 | + if ($globalDebug) { |
|
| 2312 | + echo "Owner Ecuador: Download..."; |
|
| 2313 | + } |
|
| 1918 | 2314 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 1919 | 2315 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1920 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2316 | + if ($globalDebug) { |
|
| 2317 | + echo "Add to DB..."; |
|
| 2318 | + } |
|
| 1921 | 2319 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 1922 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2320 | + } else { |
|
| 2321 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 2322 | + } |
|
| 1923 | 2323 | if ($error != '') { |
| 1924 | 2324 | return $error; |
| 1925 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1926 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 2325 | + } elseif ($globalDebug) { |
|
| 2326 | + echo "Done\n"; |
|
| 2327 | + } |
|
| 2328 | + if ($globalDebug) { |
|
| 2329 | + echo "Owner Iceland: Download..."; |
|
| 2330 | + } |
|
| 1927 | 2331 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 1928 | 2332 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1929 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2333 | + if ($globalDebug) { |
|
| 2334 | + echo "Add to DB..."; |
|
| 2335 | + } |
|
| 1930 | 2336 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 1931 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2337 | + } else { |
|
| 2338 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 2339 | + } |
|
| 1932 | 2340 | if ($error != '') { |
| 1933 | 2341 | return $error; |
| 1934 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1935 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
| 2342 | + } elseif ($globalDebug) { |
|
| 2343 | + echo "Done\n"; |
|
| 2344 | + } |
|
| 2345 | + if ($globalDebug) { |
|
| 2346 | + echo "Owner Isle of Man: Download..."; |
|
| 2347 | + } |
|
| 1936 | 2348 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
| 1937 | 2349 | if (file_exists($tmp_dir.'owner_m.csv')) { |
| 1938 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2350 | + if ($globalDebug) { |
|
| 2351 | + echo "Add to DB..."; |
|
| 2352 | + } |
|
| 1939 | 2353 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
| 1940 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2354 | + } else { |
|
| 2355 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
| 2356 | + } |
|
| 1941 | 2357 | if ($error != '') { |
| 1942 | 2358 | return $error; |
| 1943 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2359 | + } elseif ($globalDebug) { |
|
| 2360 | + echo "Done\n"; |
|
| 2361 | + } |
|
| 1944 | 2362 | if ($globalMasterSource) { |
| 1945 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
| 2363 | + if ($globalDebug) { |
|
| 2364 | + echo "ModeS Netherlands: Download..."; |
|
| 2365 | + } |
|
| 1946 | 2366 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
| 1947 | 2367 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
| 1948 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2368 | + if ($globalDebug) { |
|
| 2369 | + echo "Add to DB..."; |
|
| 2370 | + } |
|
| 1949 | 2371 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
| 1950 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2372 | + } else { |
|
| 2373 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
| 2374 | + } |
|
| 1951 | 2375 | if ($error != '') { |
| 1952 | 2376 | return $error; |
| 1953 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1954 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
| 2377 | + } elseif ($globalDebug) { |
|
| 2378 | + echo "Done\n"; |
|
| 2379 | + } |
|
| 2380 | + if ($globalDebug) { |
|
| 2381 | + echo "ModeS Denmark: Download..."; |
|
| 2382 | + } |
|
| 1955 | 2383 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
| 1956 | 2384 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
| 1957 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2385 | + if ($globalDebug) { |
|
| 2386 | + echo "Add to DB..."; |
|
| 2387 | + } |
|
| 1958 | 2388 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
| 1959 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2389 | + } else { |
|
| 2390 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
| 2391 | + } |
|
| 1960 | 2392 | if ($error != '') { |
| 1961 | 2393 | return $error; |
| 1962 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1963 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2394 | + } elseif ($globalDebug) { |
|
| 2395 | + echo "Done\n"; |
|
| 2396 | + } |
|
| 2397 | + } elseif ($globalDebug) { |
|
| 2398 | + echo "Done\n"; |
|
| 2399 | + } |
|
| 1964 | 2400 | return ''; |
| 1965 | 2401 | } |
| 1966 | 2402 | |
| 1967 | 2403 | public static function update_translation() { |
| 1968 | 2404 | global $tmp_dir, $globalDebug; |
| 1969 | 2405 | $error = ''; |
| 1970 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 2406 | + if ($globalDebug) { |
|
| 2407 | + echo "Translation : Download..."; |
|
| 2408 | + } |
|
| 1971 | 2409 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 1972 | 2410 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1973 | - if ($globalDebug) echo "Unzip..."; |
|
| 2411 | + if ($globalDebug) { |
|
| 2412 | + echo "Unzip..."; |
|
| 2413 | + } |
|
| 1974 | 2414 | update_db::unzip($tmp_dir.'translation.zip'); |
| 1975 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2415 | + if ($globalDebug) { |
|
| 2416 | + echo "Add to DB..."; |
|
| 2417 | + } |
|
| 1976 | 2418 | $error = update_db::translation(); |
| 1977 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2419 | + } else { |
|
| 2420 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 2421 | + } |
|
| 1978 | 2422 | if ($error != '') { |
| 1979 | 2423 | return $error; |
| 1980 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2424 | + } elseif ($globalDebug) { |
|
| 2425 | + echo "Done\n"; |
|
| 2426 | + } |
|
| 1981 | 2427 | return ''; |
| 1982 | 2428 | } |
| 1983 | 2429 | |
| 1984 | 2430 | public static function update_translation_fam() { |
| 1985 | 2431 | global $tmp_dir, $globalDebug; |
| 1986 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 2432 | + if ($globalDebug) { |
|
| 2433 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 2434 | + } |
|
| 1987 | 2435 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 1988 | 2436 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1989 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2437 | + if ($globalDebug) { |
|
| 2438 | + echo "Gunzip..."; |
|
| 2439 | + } |
|
| 1990 | 2440 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 1991 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2441 | + if ($globalDebug) { |
|
| 2442 | + echo "Add to DB..."; |
|
| 2443 | + } |
|
| 1992 | 2444 | $error = update_db::translation_fam(); |
| 1993 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 2445 | + } else { |
|
| 2446 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 2447 | + } |
|
| 1994 | 2448 | if ($error != '') { |
| 1995 | 2449 | return $error; |
| 1996 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2450 | + } elseif ($globalDebug) { |
|
| 2451 | + echo "Done\n"; |
|
| 2452 | + } |
|
| 1997 | 2453 | return ''; |
| 1998 | 2454 | } |
| 1999 | 2455 | public static function update_ModeS_fam() { |
| 2000 | 2456 | global $tmp_dir, $globalDebug; |
| 2001 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
| 2457 | + if ($globalDebug) { |
|
| 2458 | + echo "ModeS from FlightAirMap website : Download..."; |
|
| 2459 | + } |
|
| 2002 | 2460 | update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
| 2003 | 2461 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
| 2004 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2462 | + if ($globalDebug) { |
|
| 2463 | + echo "Gunzip..."; |
|
| 2464 | + } |
|
| 2005 | 2465 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
| 2006 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2466 | + if ($globalDebug) { |
|
| 2467 | + echo "Add to DB..."; |
|
| 2468 | + } |
|
| 2007 | 2469 | $error = update_db::modes_fam(); |
| 2008 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2470 | + } else { |
|
| 2471 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2472 | + } |
|
| 2009 | 2473 | if ($error != '') { |
| 2010 | 2474 | return $error; |
| 2011 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2475 | + } elseif ($globalDebug) { |
|
| 2476 | + echo "Done\n"; |
|
| 2477 | + } |
|
| 2012 | 2478 | return ''; |
| 2013 | 2479 | } |
| 2014 | 2480 | public static function update_owner_fam() { |
| 2015 | 2481 | global $tmp_dir, $globalDebug, $globalOwner; |
| 2016 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
| 2482 | + if ($globalDebug) { |
|
| 2483 | + echo "owner from FlightAirMap website : Download..."; |
|
| 2484 | + } |
|
| 2017 | 2485 | if ($globalOwner === TRUE) { |
| 2018 | 2486 | update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
| 2019 | 2487 | } else { |
| 2020 | 2488 | update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
| 2021 | 2489 | } |
| 2022 | 2490 | if (file_exists($tmp_dir.'owners.tsv.gz')) { |
| 2023 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2491 | + if ($globalDebug) { |
|
| 2492 | + echo "Gunzip..."; |
|
| 2493 | + } |
|
| 2024 | 2494 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
| 2025 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2495 | + if ($globalDebug) { |
|
| 2496 | + echo "Add to DB..."; |
|
| 2497 | + } |
|
| 2026 | 2498 | $error = update_db::owner_fam(); |
| 2027 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 2499 | + } else { |
|
| 2500 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
| 2501 | + } |
|
| 2028 | 2502 | if ($error != '') { |
| 2029 | 2503 | return $error; |
| 2030 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2504 | + } elseif ($globalDebug) { |
|
| 2505 | + echo "Done\n"; |
|
| 2506 | + } |
|
| 2031 | 2507 | return ''; |
| 2032 | 2508 | } |
| 2033 | 2509 | public static function update_routes_fam() { |
| 2034 | 2510 | global $tmp_dir, $globalDebug; |
| 2035 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
| 2511 | + if ($globalDebug) { |
|
| 2512 | + echo "Routes from FlightAirMap website : Download..."; |
|
| 2513 | + } |
|
| 2036 | 2514 | update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
| 2037 | 2515 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
| 2038 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2516 | + if ($globalDebug) { |
|
| 2517 | + echo "Gunzip..."; |
|
| 2518 | + } |
|
| 2039 | 2519 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
| 2040 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2520 | + if ($globalDebug) { |
|
| 2521 | + echo "Add to DB..."; |
|
| 2522 | + } |
|
| 2041 | 2523 | $error = update_db::routes_fam(); |
| 2042 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2524 | + } else { |
|
| 2525 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
| 2526 | + } |
|
| 2043 | 2527 | if ($error != '') { |
| 2044 | 2528 | return $error; |
| 2045 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2529 | + } elseif ($globalDebug) { |
|
| 2530 | + echo "Done\n"; |
|
| 2531 | + } |
|
| 2046 | 2532 | return ''; |
| 2047 | 2533 | } |
| 2048 | 2534 | public static function update_marine_identity_fam() { |
@@ -2052,14 +2538,22 @@ discard block |
||
| 2052 | 2538 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
| 2053 | 2539 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
| 2054 | 2540 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
| 2055 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
| 2541 | + if ($globalDebug) { |
|
| 2542 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
| 2543 | + } |
|
| 2056 | 2544 | update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
| 2057 | 2545 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
| 2058 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2546 | + if ($globalDebug) { |
|
| 2547 | + echo "Gunzip..."; |
|
| 2548 | + } |
|
| 2059 | 2549 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
| 2060 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2550 | + if ($globalDebug) { |
|
| 2551 | + echo "Add to DB..."; |
|
| 2552 | + } |
|
| 2061 | 2553 | $error = update_db::marine_identity_fam(); |
| 2062 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 2554 | + } else { |
|
| 2555 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
| 2556 | + } |
|
| 2063 | 2557 | if ($error != '') { |
| 2064 | 2558 | return $error; |
| 2065 | 2559 | } elseif ($globalDebug) { |
@@ -2072,17 +2566,25 @@ discard block |
||
| 2072 | 2566 | } |
| 2073 | 2567 | public static function update_banned_fam() { |
| 2074 | 2568 | global $tmp_dir, $globalDebug; |
| 2075 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 2569 | + if ($globalDebug) { |
|
| 2570 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
| 2571 | + } |
|
| 2076 | 2572 | update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
| 2077 | 2573 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
| 2078 | 2574 | //if ($globalDebug) echo "Gunzip..."; |
| 2079 | 2575 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
| 2080 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2576 | + if ($globalDebug) { |
|
| 2577 | + echo "Add to DB..."; |
|
| 2578 | + } |
|
| 2081 | 2579 | $error = update_db::banned_fam(); |
| 2082 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 2580 | + } else { |
|
| 2581 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
| 2582 | + } |
|
| 2083 | 2583 | if ($error != '') { |
| 2084 | 2584 | return $error; |
| 2085 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2585 | + } elseif ($globalDebug) { |
|
| 2586 | + echo "Done\n"; |
|
| 2587 | + } |
|
| 2086 | 2588 | return ''; |
| 2087 | 2589 | } |
| 2088 | 2590 | |
@@ -2090,7 +2592,9 @@ discard block |
||
| 2090 | 2592 | global $tmp_dir, $globalDebug, $globalDBdriver; |
| 2091 | 2593 | include_once('class.create_db.php'); |
| 2092 | 2594 | $error = ''; |
| 2093 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
| 2595 | + if ($globalDebug) { |
|
| 2596 | + echo "Airspace from FlightAirMap website : Download..."; |
|
| 2597 | + } |
|
| 2094 | 2598 | if ($globalDBdriver == 'mysql') { |
| 2095 | 2599 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
| 2096 | 2600 | } else { |
@@ -2106,9 +2610,13 @@ discard block |
||
| 2106 | 2610 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
| 2107 | 2611 | } |
| 2108 | 2612 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 2109 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2613 | + if ($globalDebug) { |
|
| 2614 | + echo "Gunzip..."; |
|
| 2615 | + } |
|
| 2110 | 2616 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
| 2111 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2617 | + if ($globalDebug) { |
|
| 2618 | + echo "Add to DB..."; |
|
| 2619 | + } |
|
| 2112 | 2620 | $Connection = new Connection(); |
| 2113 | 2621 | if ($Connection->tableExists('airspace')) { |
| 2114 | 2622 | $query = 'DROP TABLE airspace'; |
@@ -2121,19 +2629,27 @@ discard block |
||
| 2121 | 2629 | } |
| 2122 | 2630 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 2123 | 2631 | update_db::insert_airspace_version($airspace_md5); |
| 2124 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2632 | + } else { |
|
| 2633 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2634 | + } |
|
| 2125 | 2635 | } |
| 2126 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2636 | + } else { |
|
| 2637 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2638 | + } |
|
| 2127 | 2639 | if ($error != '') { |
| 2128 | 2640 | return $error; |
| 2129 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2641 | + } elseif ($globalDebug) { |
|
| 2642 | + echo "Done\n"; |
|
| 2643 | + } |
|
| 2130 | 2644 | return ''; |
| 2131 | 2645 | } |
| 2132 | 2646 | |
| 2133 | 2647 | public static function update_geoid_fam() { |
| 2134 | 2648 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
| 2135 | 2649 | $error = ''; |
| 2136 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
| 2650 | + if ($globalDebug) { |
|
| 2651 | + echo "Geoid from FlightAirMap website : Download..."; |
|
| 2652 | + } |
|
| 2137 | 2653 | update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
| 2138 | 2654 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
| 2139 | 2655 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2141,36 +2657,54 @@ discard block |
||
| 2141 | 2657 | if (!update_db::check_geoid_version($geoid_md5)) { |
| 2142 | 2658 | update_db::download('http://data.flightairmap.fr/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
| 2143 | 2659 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
| 2144 | - if ($globalDebug) echo "Gunzip..."; |
|
| 2660 | + if ($globalDebug) { |
|
| 2661 | + echo "Gunzip..."; |
|
| 2662 | + } |
|
| 2145 | 2663 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
| 2146 | 2664 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
| 2147 | 2665 | update_db::insert_geoid_version($geoid_md5); |
| 2148 | 2666 | } |
| 2149 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 2667 | + } else { |
|
| 2668 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
| 2669 | + } |
|
| 2150 | 2670 | } |
| 2151 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 2671 | + } else { |
|
| 2672 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
| 2673 | + } |
|
| 2152 | 2674 | if ($error != '') { |
| 2153 | 2675 | return $error; |
| 2154 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2676 | + } elseif ($globalDebug) { |
|
| 2677 | + echo "Done\n"; |
|
| 2678 | + } |
|
| 2155 | 2679 | return ''; |
| 2156 | 2680 | } |
| 2157 | 2681 | |
| 2158 | 2682 | public static function update_tle() { |
| 2159 | 2683 | global $tmp_dir, $globalDebug; |
| 2160 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
| 2684 | + if ($globalDebug) { |
|
| 2685 | + echo "Download TLE : Download..."; |
|
| 2686 | + } |
|
| 2161 | 2687 | $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', |
| 2162 | 2688 | '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', |
| 2163 | 2689 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
| 2164 | 2690 | foreach ($alltle as $filename) { |
| 2165 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
| 2691 | + if ($globalDebug) { |
|
| 2692 | + echo "downloading ".$filename.'...'; |
|
| 2693 | + } |
|
| 2166 | 2694 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
| 2167 | 2695 | if (file_exists($tmp_dir.$filename)) { |
| 2168 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
| 2696 | + if ($globalDebug) { |
|
| 2697 | + echo "Add to DB ".$filename."..."; |
|
| 2698 | + } |
|
| 2169 | 2699 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
| 2170 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2700 | + } else { |
|
| 2701 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2702 | + } |
|
| 2171 | 2703 | if ($error != '') { |
| 2172 | 2704 | echo $error."\n"; |
| 2173 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2705 | + } elseif ($globalDebug) { |
|
| 2706 | + echo "Done\n"; |
|
| 2707 | + } |
|
| 2174 | 2708 | } |
| 2175 | 2709 | return ''; |
| 2176 | 2710 | } |
@@ -2178,10 +2712,14 @@ discard block |
||
| 2178 | 2712 | public static function update_models() { |
| 2179 | 2713 | global $tmp_dir, $globalDebug; |
| 2180 | 2714 | $error = ''; |
| 2181 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
| 2715 | + if ($globalDebug) { |
|
| 2716 | + echo "Models from FlightAirMap website : Download..."; |
|
| 2717 | + } |
|
| 2182 | 2718 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
| 2183 | 2719 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 2184 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2720 | + if ($globalDebug) { |
|
| 2721 | + echo "Check files...\n"; |
|
| 2722 | + } |
|
| 2185 | 2723 | $newmodelsdb = array(); |
| 2186 | 2724 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
| 2187 | 2725 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2200,25 +2738,35 @@ discard block |
||
| 2200 | 2738 | } |
| 2201 | 2739 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2202 | 2740 | foreach ($diff as $key => $value) { |
| 2203 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2741 | + if ($globalDebug) { |
|
| 2742 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2743 | + } |
|
| 2204 | 2744 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
| 2205 | 2745 | |
| 2206 | 2746 | } |
| 2207 | 2747 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
| 2208 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2748 | + } else { |
|
| 2749 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2750 | + } |
|
| 2209 | 2751 | if ($error != '') { |
| 2210 | 2752 | return $error; |
| 2211 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2753 | + } elseif ($globalDebug) { |
|
| 2754 | + echo "Done\n"; |
|
| 2755 | + } |
|
| 2212 | 2756 | return ''; |
| 2213 | 2757 | } |
| 2214 | 2758 | |
| 2215 | 2759 | public static function update_space_models() { |
| 2216 | 2760 | global $tmp_dir, $globalDebug; |
| 2217 | 2761 | $error = ''; |
| 2218 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
| 2762 | + if ($globalDebug) { |
|
| 2763 | + echo "Space models from FlightAirMap website : Download..."; |
|
| 2764 | + } |
|
| 2219 | 2765 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
| 2220 | 2766 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 2221 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2767 | + if ($globalDebug) { |
|
| 2768 | + echo "Check files...\n"; |
|
| 2769 | + } |
|
| 2222 | 2770 | $newmodelsdb = array(); |
| 2223 | 2771 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
| 2224 | 2772 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2237,25 +2785,35 @@ discard block |
||
| 2237 | 2785 | } |
| 2238 | 2786 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2239 | 2787 | foreach ($diff as $key => $value) { |
| 2240 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2788 | + if ($globalDebug) { |
|
| 2789 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2790 | + } |
|
| 2241 | 2791 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
| 2242 | 2792 | |
| 2243 | 2793 | } |
| 2244 | 2794 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
| 2245 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2795 | + } else { |
|
| 2796 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2797 | + } |
|
| 2246 | 2798 | if ($error != '') { |
| 2247 | 2799 | return $error; |
| 2248 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2800 | + } elseif ($globalDebug) { |
|
| 2801 | + echo "Done\n"; |
|
| 2802 | + } |
|
| 2249 | 2803 | return ''; |
| 2250 | 2804 | } |
| 2251 | 2805 | |
| 2252 | 2806 | public static function update_vehicules_models() { |
| 2253 | 2807 | global $tmp_dir, $globalDebug; |
| 2254 | 2808 | $error = ''; |
| 2255 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 2809 | + if ($globalDebug) { |
|
| 2810 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
| 2811 | + } |
|
| 2256 | 2812 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
| 2257 | 2813 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
| 2258 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2814 | + if ($globalDebug) { |
|
| 2815 | + echo "Check files...\n"; |
|
| 2816 | + } |
|
| 2259 | 2817 | $newmodelsdb = array(); |
| 2260 | 2818 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
| 2261 | 2819 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2274,15 +2832,21 @@ discard block |
||
| 2274 | 2832 | } |
| 2275 | 2833 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 2276 | 2834 | foreach ($diff as $key => $value) { |
| 2277 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 2835 | + if ($globalDebug) { |
|
| 2836 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
| 2837 | + } |
|
| 2278 | 2838 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
| 2279 | 2839 | |
| 2280 | 2840 | } |
| 2281 | 2841 | update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
| 2282 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2842 | + } else { |
|
| 2843 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2844 | + } |
|
| 2283 | 2845 | if ($error != '') { |
| 2284 | 2846 | return $error; |
| 2285 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2847 | + } elseif ($globalDebug) { |
|
| 2848 | + echo "Done\n"; |
|
| 2849 | + } |
|
| 2286 | 2850 | return ''; |
| 2287 | 2851 | } |
| 2288 | 2852 | |
@@ -2325,7 +2889,9 @@ discard block |
||
| 2325 | 2889 | } |
| 2326 | 2890 | |
| 2327 | 2891 | $error = ''; |
| 2328 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 2892 | + if ($globalDebug) { |
|
| 2893 | + echo "Notam : Download..."; |
|
| 2894 | + } |
|
| 2329 | 2895 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 2330 | 2896 | if (file_exists($tmp_dir.'notam.rss')) { |
| 2331 | 2897 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2340,14 +2906,30 @@ discard block |
||
| 2340 | 2906 | $data['fir'] = $q[0]; |
| 2341 | 2907 | $data['code'] = $q[1]; |
| 2342 | 2908 | $ifrvfr = $q[2]; |
| 2343 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 2344 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 2345 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 2346 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 2347 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 2348 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 2349 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 2350 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 2909 | + if ($ifrvfr == 'IV') { |
|
| 2910 | + $data['rules'] = 'IFR/VFR'; |
|
| 2911 | + } |
|
| 2912 | + if ($ifrvfr == 'I') { |
|
| 2913 | + $data['rules'] = 'IFR'; |
|
| 2914 | + } |
|
| 2915 | + if ($ifrvfr == 'V') { |
|
| 2916 | + $data['rules'] = 'VFR'; |
|
| 2917 | + } |
|
| 2918 | + if ($q[4] == 'A') { |
|
| 2919 | + $data['scope'] = 'Airport warning'; |
|
| 2920 | + } |
|
| 2921 | + if ($q[4] == 'E') { |
|
| 2922 | + $data['scope'] = 'Enroute warning'; |
|
| 2923 | + } |
|
| 2924 | + if ($q[4] == 'W') { |
|
| 2925 | + $data['scope'] = 'Navigation warning'; |
|
| 2926 | + } |
|
| 2927 | + if ($q[4] == 'AE') { |
|
| 2928 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 2929 | + } |
|
| 2930 | + if ($q[4] == 'AW') { |
|
| 2931 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 2932 | + } |
|
| 2351 | 2933 | //$data['scope'] = $q[4]; |
| 2352 | 2934 | $data['lower_limit'] = $q[5]; |
| 2353 | 2935 | $data['upper_limit'] = $q[6]; |
@@ -2355,8 +2937,12 @@ discard block |
||
| 2355 | 2937 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 2356 | 2938 | $latitude = $Common->convertDec($las,'latitude'); |
| 2357 | 2939 | $longitude = $Common->convertDec($lns,'longitude'); |
| 2358 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 2359 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 2940 | + if ($lac == 'S') { |
|
| 2941 | + $latitude = '-'.$latitude; |
|
| 2942 | + } |
|
| 2943 | + if ($lnc == 'W') { |
|
| 2944 | + $longitude = '-'.$longitude; |
|
| 2945 | + } |
|
| 2360 | 2946 | $data['center_latitude'] = $latitude; |
| 2361 | 2947 | $data['center_longitude'] = $longitude; |
| 2362 | 2948 | $data['radius'] = intval($radius); |
@@ -2386,10 +2972,14 @@ discard block |
||
| 2386 | 2972 | $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']); |
| 2387 | 2973 | unset($data); |
| 2388 | 2974 | } |
| 2389 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2975 | + } else { |
|
| 2976 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2977 | + } |
|
| 2390 | 2978 | if ($error != '') { |
| 2391 | 2979 | return $error; |
| 2392 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2980 | + } elseif ($globalDebug) { |
|
| 2981 | + echo "Done\n"; |
|
| 2982 | + } |
|
| 2393 | 2983 | return ''; |
| 2394 | 2984 | } |
| 2395 | 2985 | |
@@ -2414,7 +3004,9 @@ discard block |
||
| 2414 | 3004 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 2415 | 3005 | $airspace_json = json_decode($airspace_lst,true); |
| 2416 | 3006 | foreach ($airspace_json['records'] as $airspace) { |
| 2417 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
| 3007 | + if ($globalDebug) { |
|
| 3008 | + echo $airspace['name']."...\n"; |
|
| 3009 | + } |
|
| 2418 | 3010 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
| 2419 | 3011 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 2420 | 3012 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -2458,8 +3050,11 @@ discard block |
||
| 2458 | 3050 | return "error : ".$e->getMessage(); |
| 2459 | 3051 | } |
| 2460 | 3052 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2461 | - if ($row['nb'] > 0) return false; |
|
| 2462 | - else return true; |
|
| 3053 | + if ($row['nb'] > 0) { |
|
| 3054 | + return false; |
|
| 3055 | + } else { |
|
| 3056 | + return true; |
|
| 3057 | + } |
|
| 2463 | 3058 | } |
| 2464 | 3059 | |
| 2465 | 3060 | public static function insert_last_update() { |
@@ -2484,8 +3079,11 @@ discard block |
||
| 2484 | 3079 | return "error : ".$e->getMessage(); |
| 2485 | 3080 | } |
| 2486 | 3081 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2487 | - if ($row['nb'] > 0) return true; |
|
| 2488 | - else return false; |
|
| 3082 | + if ($row['nb'] > 0) { |
|
| 3083 | + return true; |
|
| 3084 | + } else { |
|
| 3085 | + return false; |
|
| 3086 | + } |
|
| 2489 | 3087 | } |
| 2490 | 3088 | |
| 2491 | 3089 | public static function check_geoid_version($version) { |
@@ -2498,8 +3096,11 @@ discard block |
||
| 2498 | 3096 | return "error : ".$e->getMessage(); |
| 2499 | 3097 | } |
| 2500 | 3098 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2501 | - if ($row['nb'] > 0) return true; |
|
| 2502 | - else return false; |
|
| 3099 | + if ($row['nb'] > 0) { |
|
| 3100 | + return true; |
|
| 3101 | + } else { |
|
| 3102 | + return false; |
|
| 3103 | + } |
|
| 2503 | 3104 | } |
| 2504 | 3105 | |
| 2505 | 3106 | public static function check_marine_identity_version($version) { |
@@ -2512,8 +3113,11 @@ discard block |
||
| 2512 | 3113 | return "error : ".$e->getMessage(); |
| 2513 | 3114 | } |
| 2514 | 3115 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2515 | - if ($row['nb'] > 0) return true; |
|
| 2516 | - else return false; |
|
| 3116 | + if ($row['nb'] > 0) { |
|
| 3117 | + return true; |
|
| 3118 | + } else { |
|
| 3119 | + return false; |
|
| 3120 | + } |
|
| 2517 | 3121 | } |
| 2518 | 3122 | |
| 2519 | 3123 | |
@@ -2568,8 +3172,11 @@ discard block |
||
| 2568 | 3172 | return "error : ".$e->getMessage(); |
| 2569 | 3173 | } |
| 2570 | 3174 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2571 | - if ($row['nb'] > 0) return false; |
|
| 2572 | - else return true; |
|
| 3175 | + if ($row['nb'] > 0) { |
|
| 3176 | + return false; |
|
| 3177 | + } else { |
|
| 3178 | + return true; |
|
| 3179 | + } |
|
| 2573 | 3180 | } |
| 2574 | 3181 | |
| 2575 | 3182 | public static function insert_last_notam_update() { |
@@ -2599,8 +3206,11 @@ discard block |
||
| 2599 | 3206 | return "error : ".$e->getMessage(); |
| 2600 | 3207 | } |
| 2601 | 3208 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2602 | - if ($row['nb'] > 0) return false; |
|
| 2603 | - else return true; |
|
| 3209 | + if ($row['nb'] > 0) { |
|
| 3210 | + return false; |
|
| 3211 | + } else { |
|
| 3212 | + return true; |
|
| 3213 | + } |
|
| 2604 | 3214 | } |
| 2605 | 3215 | |
| 2606 | 3216 | public static function insert_last_airspace_update() { |
@@ -2630,8 +3240,11 @@ discard block |
||
| 2630 | 3240 | return "error : ".$e->getMessage(); |
| 2631 | 3241 | } |
| 2632 | 3242 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2633 | - if ($row['nb'] > 0) return false; |
|
| 2634 | - else return true; |
|
| 3243 | + if ($row['nb'] > 0) { |
|
| 3244 | + return false; |
|
| 3245 | + } else { |
|
| 3246 | + return true; |
|
| 3247 | + } |
|
| 2635 | 3248 | } |
| 2636 | 3249 | |
| 2637 | 3250 | public static function insert_last_geoid_update() { |
@@ -2661,8 +3274,11 @@ discard block |
||
| 2661 | 3274 | return "error : ".$e->getMessage(); |
| 2662 | 3275 | } |
| 2663 | 3276 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2664 | - if ($row['nb'] > 0) return false; |
|
| 2665 | - else return true; |
|
| 3277 | + if ($row['nb'] > 0) { |
|
| 3278 | + return false; |
|
| 3279 | + } else { |
|
| 3280 | + return true; |
|
| 3281 | + } |
|
| 2666 | 3282 | } |
| 2667 | 3283 | |
| 2668 | 3284 | public static function insert_last_owner_update() { |
@@ -2691,8 +3307,11 @@ discard block |
||
| 2691 | 3307 | return "error : ".$e->getMessage(); |
| 2692 | 3308 | } |
| 2693 | 3309 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2694 | - if ($row['nb'] > 0) return false; |
|
| 2695 | - else return true; |
|
| 3310 | + if ($row['nb'] > 0) { |
|
| 3311 | + return false; |
|
| 3312 | + } else { |
|
| 3313 | + return true; |
|
| 3314 | + } |
|
| 2696 | 3315 | } |
| 2697 | 3316 | |
| 2698 | 3317 | public static function insert_last_schedules_update() { |
@@ -2721,8 +3340,11 @@ discard block |
||
| 2721 | 3340 | return "error : ".$e->getMessage(); |
| 2722 | 3341 | } |
| 2723 | 3342 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2724 | - if ($row['nb'] > 0) return false; |
|
| 2725 | - else return true; |
|
| 3343 | + if ($row['nb'] > 0) { |
|
| 3344 | + return false; |
|
| 3345 | + } else { |
|
| 3346 | + return true; |
|
| 3347 | + } |
|
| 2726 | 3348 | } |
| 2727 | 3349 | |
| 2728 | 3350 | public static function insert_last_tle_update() { |
@@ -2751,8 +3373,11 @@ discard block |
||
| 2751 | 3373 | return "error : ".$e->getMessage(); |
| 2752 | 3374 | } |
| 2753 | 3375 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2754 | - if ($row['nb'] > 0) return false; |
|
| 2755 | - else return true; |
|
| 3376 | + if ($row['nb'] > 0) { |
|
| 3377 | + return false; |
|
| 3378 | + } else { |
|
| 3379 | + return true; |
|
| 3380 | + } |
|
| 2756 | 3381 | } |
| 2757 | 3382 | |
| 2758 | 3383 | public static function insert_last_marine_identity_update() { |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * Get SQL query part for filter used |
| 15 | 15 | * @param Array $filter the filter |
| 16 | - * @return Array the SQL part |
|
| 16 | + * @return string the SQL part |
|
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
@@ -566,25 +566,6 @@ discard block |
||
| 566 | 566 | * |
| 567 | 567 | * @param String $fammarine_id the ID |
| 568 | 568 | * @param String $ident the marine ident |
| 569 | - * @param String $departure_airport_icao the departure airport |
|
| 570 | - * @param String $arrival_airport_icao the arrival airport |
|
| 571 | - * @param String $latitude latitude of flight |
|
| 572 | - * @param String $longitude latitude of flight |
|
| 573 | - * @param String $waypoints waypoints of flight |
|
| 574 | - * @param String $heading heading of flight |
|
| 575 | - * @param String $groundspeed speed of flight |
|
| 576 | - * @param String $date date of flight |
|
| 577 | - * @param String $departure_airport_time departure time of flight |
|
| 578 | - * @param String $arrival_airport_time arrival time of flight |
|
| 579 | - * @param String $squawk squawk code of flight |
|
| 580 | - * @param String $route_stop route stop of flight |
|
| 581 | - * @param String $highlight highlight or not |
|
| 582 | - * @param String $ModeS ModesS code of flight |
|
| 583 | - * @param String $registration registration code of flight |
|
| 584 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 585 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 586 | - * @param String $verticalrate vertival rate of flight |
|
| 587 | - * @return String success or false |
|
| 588 | 569 | */ |
| 589 | 570 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
| 590 | 571 | { |
@@ -1467,7 +1448,7 @@ discard block |
||
| 1467 | 1448 | /** |
| 1468 | 1449 | * Parses the direction degrees to working |
| 1469 | 1450 | * |
| 1470 | - * @param Float $direction the direction in degrees |
|
| 1451 | + * @param integer $direction the direction in degrees |
|
| 1471 | 1452 | * @return Array the direction information |
| 1472 | 1453 | * |
| 1473 | 1454 | */ |
@@ -11,10 +11,10 @@ discard block |
||
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * Get SQL query part for filter used |
|
| 15 | - * @param Array $filter the filter |
|
| 16 | - * @return Array the SQL part |
|
| 17 | - */ |
|
| 14 | + * Get SQL query part for filter used |
|
| 15 | + * @param Array $filter the filter |
|
| 16 | + * @return Array the SQL part |
|
| 17 | + */ |
|
| 18 | 18 | |
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | - * Executes the SQL statements to get the spotter information |
|
| 82 | - * |
|
| 83 | - * @param String $query the SQL query |
|
| 84 | - * @param Array $params parameter of the query |
|
| 85 | - * @param String $limitQuery the limit query |
|
| 86 | - * @return Array the spotter information |
|
| 87 | - * |
|
| 88 | - */ |
|
| 81 | + * Executes the SQL statements to get the spotter information |
|
| 82 | + * |
|
| 83 | + * @param String $query the SQL query |
|
| 84 | + * @param Array $params parameter of the query |
|
| 85 | + * @param String $limitQuery the limit query |
|
| 86 | + * @return Array the spotter information |
|
| 87 | + * |
|
| 88 | + */ |
|
| 89 | 89 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
| 90 | 90 | { |
| 91 | 91 | date_default_timezone_set('UTC'); |
@@ -213,11 +213,11 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | - * Gets all the spotter information based on the latest data entry |
|
| 217 | - * |
|
| 218 | - * @return Array the spotter information |
|
| 219 | - * |
|
| 220 | - */ |
|
| 216 | + * Gets all the spotter information based on the latest data entry |
|
| 217 | + * |
|
| 218 | + * @return Array the spotter information |
|
| 219 | + * |
|
| 220 | + */ |
|
| 221 | 221 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
| 222 | 222 | { |
| 223 | 223 | global $global_query; |
@@ -266,11 +266,11 @@ discard block |
||
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
| 269 | - * Gets all the spotter information based on the callsign |
|
| 270 | - * |
|
| 271 | - * @return Array the spotter information |
|
| 272 | - * |
|
| 273 | - */ |
|
| 269 | + * Gets all the spotter information based on the callsign |
|
| 270 | + * |
|
| 271 | + * @return Array the spotter information |
|
| 272 | + * |
|
| 273 | + */ |
|
| 274 | 274 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
| 275 | 275 | { |
| 276 | 276 | global $global_query; |
@@ -381,12 +381,12 @@ discard block |
||
| 381 | 381 | |
| 382 | 382 | |
| 383 | 383 | /** |
| 384 | - * Gets all source name |
|
| 385 | - * |
|
| 386 | - * @param String type format of source |
|
| 387 | - * @return Array list of source name |
|
| 388 | - * |
|
| 389 | - */ |
|
| 384 | + * Gets all source name |
|
| 385 | + * |
|
| 386 | + * @param String type format of source |
|
| 387 | + * @return Array list of source name |
|
| 388 | + * |
|
| 389 | + */ |
|
| 390 | 390 | public function getAllSourceName($type = '',$filters = array()) |
| 391 | 391 | { |
| 392 | 392 | $filter_query = $this->getFilter($filters,true,true); |
@@ -416,11 +416,11 @@ discard block |
||
| 416 | 416 | |
| 417 | 417 | |
| 418 | 418 | /** |
| 419 | - * Gets a list of all idents/callsigns |
|
| 420 | - * |
|
| 421 | - * @return Array list of ident/callsign names |
|
| 422 | - * |
|
| 423 | - */ |
|
| 419 | + * Gets a list of all idents/callsigns |
|
| 420 | + * |
|
| 421 | + * @return Array list of ident/callsign names |
|
| 422 | + * |
|
| 423 | + */ |
|
| 424 | 424 | public function getAllIdents($filters = array()) |
| 425 | 425 | { |
| 426 | 426 | $filter_query = $this->getFilter($filters,true,true); |
@@ -444,11 +444,11 @@ discard block |
||
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | /** |
| 447 | - * Gets all info from a mmsi |
|
| 448 | - * |
|
| 449 | - * @return Array list of mmsi info |
|
| 450 | - * |
|
| 451 | - */ |
|
| 447 | + * Gets all info from a mmsi |
|
| 448 | + * |
|
| 449 | + * @return Array list of mmsi info |
|
| 450 | + * |
|
| 451 | + */ |
|
| 452 | 452 | public function getIdentity($mmsi) |
| 453 | 453 | { |
| 454 | 454 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -505,18 +505,18 @@ discard block |
||
| 505 | 505 | |
| 506 | 506 | |
| 507 | 507 | /** |
| 508 | - * Update ident tracker data |
|
| 509 | - * |
|
| 510 | - * @param String $fammarine_id the ID |
|
| 511 | - * @param String $ident the marine ident |
|
| 512 | - * @return String success or false |
|
| 513 | - * |
|
| 514 | - */ |
|
| 508 | + * Update ident tracker data |
|
| 509 | + * |
|
| 510 | + * @param String $fammarine_id the ID |
|
| 511 | + * @param String $ident the marine ident |
|
| 512 | + * @return String success or false |
|
| 513 | + * |
|
| 514 | + */ |
|
| 515 | 515 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
| 516 | 516 | { |
| 517 | 517 | |
| 518 | 518 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 519 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 519 | + $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 520 | 520 | |
| 521 | 521 | try { |
| 522 | 522 | $sth = $this->db->prepare($query); |
@@ -530,19 +530,19 @@ discard block |
||
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
| 533 | - * Update Status data |
|
| 534 | - * |
|
| 535 | - * @param String $fammarine_id the ID |
|
| 536 | - * @param String $status_id the marine status id |
|
| 537 | - * @param String $status the marine status |
|
| 538 | - * @return String success or false |
|
| 539 | - * |
|
| 540 | - */ |
|
| 533 | + * Update Status data |
|
| 534 | + * |
|
| 535 | + * @param String $fammarine_id the ID |
|
| 536 | + * @param String $status_id the marine status id |
|
| 537 | + * @param String $status the marine status |
|
| 538 | + * @return String success or false |
|
| 539 | + * |
|
| 540 | + */ |
|
| 541 | 541 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
| 542 | 542 | { |
| 543 | 543 | |
| 544 | 544 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 545 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 545 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 546 | 546 | |
| 547 | 547 | try { |
| 548 | 548 | $sth = $this->db->prepare($query); |
@@ -555,17 +555,17 @@ discard block |
||
| 555 | 555 | |
| 556 | 556 | } |
| 557 | 557 | /** |
| 558 | - * Update latest marine data |
|
| 559 | - * |
|
| 560 | - * @param String $fammarine_id the ID |
|
| 561 | - * @param String $ident the marine ident |
|
| 562 | - * @return String success or false |
|
| 563 | - * |
|
| 564 | - */ |
|
| 558 | + * Update latest marine data |
|
| 559 | + * |
|
| 560 | + * @param String $fammarine_id the ID |
|
| 561 | + * @param String $ident the marine ident |
|
| 562 | + * @return String success or false |
|
| 563 | + * |
|
| 564 | + */ |
|
| 565 | 565 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 566 | 566 | { |
| 567 | 567 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
| 568 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 568 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 569 | 569 | |
| 570 | 570 | try { |
| 571 | 571 | $sth = $this->db->prepare($query); |
@@ -579,30 +579,30 @@ discard block |
||
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | /** |
| 582 | - * Adds a new spotter data |
|
| 583 | - * |
|
| 584 | - * @param String $fammarine_id the ID |
|
| 585 | - * @param String $ident the marine ident |
|
| 586 | - * @param String $departure_airport_icao the departure airport |
|
| 587 | - * @param String $arrival_airport_icao the arrival airport |
|
| 588 | - * @param String $latitude latitude of flight |
|
| 589 | - * @param String $longitude latitude of flight |
|
| 590 | - * @param String $waypoints waypoints of flight |
|
| 591 | - * @param String $heading heading of flight |
|
| 592 | - * @param String $groundspeed speed of flight |
|
| 593 | - * @param String $date date of flight |
|
| 594 | - * @param String $departure_airport_time departure time of flight |
|
| 595 | - * @param String $arrival_airport_time arrival time of flight |
|
| 596 | - * @param String $squawk squawk code of flight |
|
| 597 | - * @param String $route_stop route stop of flight |
|
| 598 | - * @param String $highlight highlight or not |
|
| 599 | - * @param String $ModeS ModesS code of flight |
|
| 600 | - * @param String $registration registration code of flight |
|
| 601 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 602 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 603 | - * @param String $verticalrate vertival rate of flight |
|
| 604 | - * @return String success or false |
|
| 605 | - */ |
|
| 582 | + * Adds a new spotter data |
|
| 583 | + * |
|
| 584 | + * @param String $fammarine_id the ID |
|
| 585 | + * @param String $ident the marine ident |
|
| 586 | + * @param String $departure_airport_icao the departure airport |
|
| 587 | + * @param String $arrival_airport_icao the arrival airport |
|
| 588 | + * @param String $latitude latitude of flight |
|
| 589 | + * @param String $longitude latitude of flight |
|
| 590 | + * @param String $waypoints waypoints of flight |
|
| 591 | + * @param String $heading heading of flight |
|
| 592 | + * @param String $groundspeed speed of flight |
|
| 593 | + * @param String $date date of flight |
|
| 594 | + * @param String $departure_airport_time departure time of flight |
|
| 595 | + * @param String $arrival_airport_time arrival time of flight |
|
| 596 | + * @param String $squawk squawk code of flight |
|
| 597 | + * @param String $route_stop route stop of flight |
|
| 598 | + * @param String $highlight highlight or not |
|
| 599 | + * @param String $ModeS ModesS code of flight |
|
| 600 | + * @param String $registration registration code of flight |
|
| 601 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
| 602 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
| 603 | + * @param String $verticalrate vertival rate of flight |
|
| 604 | + * @return String success or false |
|
| 605 | + */ |
|
| 606 | 606 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
| 607 | 607 | { |
| 608 | 608 | global $globalURL, $globalMarineImageFetch; |
@@ -699,13 +699,13 @@ discard block |
||
| 699 | 699 | unset($Image); |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | - if ($latitude == '' && $longitude == '') { |
|
| 703 | - $latitude = 0; |
|
| 704 | - $longitude = 0; |
|
| 705 | - } |
|
| 706 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 707 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 708 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 702 | + if ($latitude == '' && $longitude == '') { |
|
| 703 | + $latitude = 0; |
|
| 704 | + $longitude = 0; |
|
| 705 | + } |
|
| 706 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 707 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 708 | + if ($arrival_date == '') $arrival_date = NULL; |
|
| 709 | 709 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
| 710 | 710 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 711 | 711 | |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | $sth->execute($query_values); |
| 717 | 717 | $this->db = null; |
| 718 | 718 | } catch (PDOException $e) { |
| 719 | - return "error : ".$e->getMessage(); |
|
| 719 | + return "error : ".$e->getMessage(); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | return "success"; |
@@ -725,11 +725,11 @@ discard block |
||
| 725 | 725 | |
| 726 | 726 | |
| 727 | 727 | /** |
| 728 | - * Gets the aircraft ident within the last hour |
|
| 729 | - * |
|
| 730 | - * @return String the ident |
|
| 731 | - * |
|
| 732 | - */ |
|
| 728 | + * Gets the aircraft ident within the last hour |
|
| 729 | + * |
|
| 730 | + * @return String the ident |
|
| 731 | + * |
|
| 732 | + */ |
|
| 733 | 733 | public function getIdentFromLastHour($ident) |
| 734 | 734 | { |
| 735 | 735 | global $globalDBdriver, $globalTimezone; |
@@ -745,11 +745,11 @@ discard block |
||
| 745 | 745 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 746 | 746 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
| 747 | 747 | $query_data = array(':ident' => $ident); |
| 748 | - } |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | 750 | $sth = $this->db->prepare($query); |
| 751 | 751 | $sth->execute($query_data); |
| 752 | - $ident_result=''; |
|
| 752 | + $ident_result=''; |
|
| 753 | 753 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 754 | 754 | { |
| 755 | 755 | $ident_result = $row['ident']; |
@@ -760,11 +760,11 @@ discard block |
||
| 760 | 760 | |
| 761 | 761 | |
| 762 | 762 | /** |
| 763 | - * Gets the aircraft data from the last 20 seconds |
|
| 764 | - * |
|
| 765 | - * @return Array the spotter data |
|
| 766 | - * |
|
| 767 | - */ |
|
| 763 | + * Gets the aircraft data from the last 20 seconds |
|
| 764 | + * |
|
| 765 | + * @return Array the spotter data |
|
| 766 | + * |
|
| 767 | + */ |
|
| 768 | 768 | public function getRealTimeData($q = '') |
| 769 | 769 | { |
| 770 | 770 | global $globalDBdriver; |
@@ -802,11 +802,11 @@ discard block |
||
| 802 | 802 | |
| 803 | 803 | |
| 804 | 804 | /** |
| 805 | - * Gets all number of flight over countries |
|
| 806 | - * |
|
| 807 | - * @return Array the airline country list |
|
| 808 | - * |
|
| 809 | - */ |
|
| 805 | + * Gets all number of flight over countries |
|
| 806 | + * |
|
| 807 | + * @return Array the airline country list |
|
| 808 | + * |
|
| 809 | + */ |
|
| 810 | 810 | |
| 811 | 811 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
| 812 | 812 | { |
@@ -879,11 +879,11 @@ discard block |
||
| 879 | 879 | |
| 880 | 880 | |
| 881 | 881 | /** |
| 882 | - * Gets all callsigns that have flown over |
|
| 883 | - * |
|
| 884 | - * @return Array the callsign list |
|
| 885 | - * |
|
| 886 | - */ |
|
| 882 | + * Gets all callsigns that have flown over |
|
| 883 | + * |
|
| 884 | + * @return Array the callsign list |
|
| 885 | + * |
|
| 886 | + */ |
|
| 887 | 887 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
| 888 | 888 | { |
| 889 | 889 | global $globalDBdriver; |
@@ -950,11 +950,11 @@ discard block |
||
| 950 | 950 | |
| 951 | 951 | |
| 952 | 952 | /** |
| 953 | - * Counts all dates |
|
| 954 | - * |
|
| 955 | - * @return Array the date list |
|
| 956 | - * |
|
| 957 | - */ |
|
| 953 | + * Counts all dates |
|
| 954 | + * |
|
| 955 | + * @return Array the date list |
|
| 956 | + * |
|
| 957 | + */ |
|
| 958 | 958 | public function countAllDates($filters = array()) |
| 959 | 959 | { |
| 960 | 960 | global $globalTimezone, $globalDBdriver; |
@@ -1000,11 +1000,11 @@ discard block |
||
| 1000 | 1000 | |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
| 1003 | - * Counts all dates during the last 7 days |
|
| 1004 | - * |
|
| 1005 | - * @return Array the date list |
|
| 1006 | - * |
|
| 1007 | - */ |
|
| 1003 | + * Counts all dates during the last 7 days |
|
| 1004 | + * |
|
| 1005 | + * @return Array the date list |
|
| 1006 | + * |
|
| 1007 | + */ |
|
| 1008 | 1008 | public function countAllDatesLast7Days($filters = array()) |
| 1009 | 1009 | { |
| 1010 | 1010 | global $globalTimezone, $globalDBdriver; |
@@ -1026,7 +1026,7 @@ discard block |
||
| 1026 | 1026 | $query .= " GROUP BY date_name |
| 1027 | 1027 | ORDER BY date_name ASC"; |
| 1028 | 1028 | $query_data = array(':offset' => $offset); |
| 1029 | - } |
|
| 1029 | + } |
|
| 1030 | 1030 | |
| 1031 | 1031 | $sth = $this->db->prepare($query); |
| 1032 | 1032 | $sth->execute($query_data); |
@@ -1046,11 +1046,11 @@ discard block |
||
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | 1048 | /** |
| 1049 | - * Counts all dates during the last month |
|
| 1050 | - * |
|
| 1051 | - * @return Array the date list |
|
| 1052 | - * |
|
| 1053 | - */ |
|
| 1049 | + * Counts all dates during the last month |
|
| 1050 | + * |
|
| 1051 | + * @return Array the date list |
|
| 1052 | + * |
|
| 1053 | + */ |
|
| 1054 | 1054 | public function countAllDatesLastMonth($filters = array()) |
| 1055 | 1055 | { |
| 1056 | 1056 | global $globalTimezone, $globalDBdriver; |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | $query .= " GROUP BY date_name |
| 1073 | 1073 | ORDER BY date_name ASC"; |
| 1074 | 1074 | $query_data = array(':offset' => $offset); |
| 1075 | - } |
|
| 1075 | + } |
|
| 1076 | 1076 | |
| 1077 | 1077 | $sth = $this->db->prepare($query); |
| 1078 | 1078 | $sth->execute($query_data); |
@@ -1094,11 +1094,11 @@ discard block |
||
| 1094 | 1094 | |
| 1095 | 1095 | |
| 1096 | 1096 | /** |
| 1097 | - * Counts all month |
|
| 1098 | - * |
|
| 1099 | - * @return Array the month list |
|
| 1100 | - * |
|
| 1101 | - */ |
|
| 1097 | + * Counts all month |
|
| 1098 | + * |
|
| 1099 | + * @return Array the month list |
|
| 1100 | + * |
|
| 1101 | + */ |
|
| 1102 | 1102 | public function countAllMonths($filters = array()) |
| 1103 | 1103 | { |
| 1104 | 1104 | global $globalTimezone, $globalDBdriver; |
@@ -1143,11 +1143,11 @@ discard block |
||
| 1143 | 1143 | |
| 1144 | 1144 | |
| 1145 | 1145 | /** |
| 1146 | - * Counts all dates during the last year |
|
| 1147 | - * |
|
| 1148 | - * @return Array the date list |
|
| 1149 | - * |
|
| 1150 | - */ |
|
| 1146 | + * Counts all dates during the last year |
|
| 1147 | + * |
|
| 1148 | + * @return Array the date list |
|
| 1149 | + * |
|
| 1150 | + */ |
|
| 1151 | 1151 | public function countAllMonthsLastYear($filters) |
| 1152 | 1152 | { |
| 1153 | 1153 | global $globalTimezone, $globalDBdriver; |
@@ -1169,7 +1169,7 @@ discard block |
||
| 1169 | 1169 | $query .= " GROUP BY year_name, month_name |
| 1170 | 1170 | ORDER BY year_name, month_name ASC"; |
| 1171 | 1171 | $query_data = array(':offset' => $offset); |
| 1172 | - } |
|
| 1172 | + } |
|
| 1173 | 1173 | |
| 1174 | 1174 | $sth = $this->db->prepare($query); |
| 1175 | 1175 | $sth->execute($query_data); |
@@ -1192,11 +1192,11 @@ discard block |
||
| 1192 | 1192 | |
| 1193 | 1193 | |
| 1194 | 1194 | /** |
| 1195 | - * Counts all hours |
|
| 1196 | - * |
|
| 1197 | - * @return Array the hour list |
|
| 1198 | - * |
|
| 1199 | - */ |
|
| 1195 | + * Counts all hours |
|
| 1196 | + * |
|
| 1197 | + * @return Array the hour list |
|
| 1198 | + * |
|
| 1199 | + */ |
|
| 1200 | 1200 | public function countAllHours($orderby,$filters = array()) |
| 1201 | 1201 | { |
| 1202 | 1202 | global $globalTimezone, $globalDBdriver; |
@@ -1259,11 +1259,11 @@ discard block |
||
| 1259 | 1259 | |
| 1260 | 1260 | |
| 1261 | 1261 | /** |
| 1262 | - * Counts all hours by date |
|
| 1263 | - * |
|
| 1264 | - * @return Array the hour list |
|
| 1265 | - * |
|
| 1266 | - */ |
|
| 1262 | + * Counts all hours by date |
|
| 1263 | + * |
|
| 1264 | + * @return Array the hour list |
|
| 1265 | + * |
|
| 1266 | + */ |
|
| 1267 | 1267 | public function countAllHoursByDate($date, $filters = array()) |
| 1268 | 1268 | { |
| 1269 | 1269 | global $globalTimezone, $globalDBdriver; |
@@ -1307,11 +1307,11 @@ discard block |
||
| 1307 | 1307 | |
| 1308 | 1308 | |
| 1309 | 1309 | /** |
| 1310 | - * Counts all hours by a ident/callsign |
|
| 1311 | - * |
|
| 1312 | - * @return Array the hour list |
|
| 1313 | - * |
|
| 1314 | - */ |
|
| 1310 | + * Counts all hours by a ident/callsign |
|
| 1311 | + * |
|
| 1312 | + * @return Array the hour list |
|
| 1313 | + * |
|
| 1314 | + */ |
|
| 1315 | 1315 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1316 | 1316 | { |
| 1317 | 1317 | global $globalTimezone, $globalDBdriver; |
@@ -1356,11 +1356,11 @@ discard block |
||
| 1356 | 1356 | |
| 1357 | 1357 | |
| 1358 | 1358 | /** |
| 1359 | - * Counts all vessels |
|
| 1360 | - * |
|
| 1361 | - * @return Integer the number of vessels |
|
| 1362 | - * |
|
| 1363 | - */ |
|
| 1359 | + * Counts all vessels |
|
| 1360 | + * |
|
| 1361 | + * @return Integer the number of vessels |
|
| 1362 | + * |
|
| 1363 | + */ |
|
| 1364 | 1364 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
| 1365 | 1365 | { |
| 1366 | 1366 | global $globalDBdriver; |
@@ -1395,11 +1395,11 @@ discard block |
||
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | /** |
| 1398 | - * Counts all vessel type |
|
| 1399 | - * |
|
| 1400 | - * @return Integer the number of vessels |
|
| 1401 | - * |
|
| 1402 | - */ |
|
| 1398 | + * Counts all vessel type |
|
| 1399 | + * |
|
| 1400 | + * @return Integer the number of vessels |
|
| 1401 | + * |
|
| 1402 | + */ |
|
| 1403 | 1403 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
| 1404 | 1404 | { |
| 1405 | 1405 | global $globalDBdriver; |
@@ -1434,11 +1434,11 @@ discard block |
||
| 1434 | 1434 | |
| 1435 | 1435 | |
| 1436 | 1436 | /** |
| 1437 | - * Counts all hours of today |
|
| 1438 | - * |
|
| 1439 | - * @return Array the hour list |
|
| 1440 | - * |
|
| 1441 | - */ |
|
| 1437 | + * Counts all hours of today |
|
| 1438 | + * |
|
| 1439 | + * @return Array the hour list |
|
| 1440 | + * |
|
| 1441 | + */ |
|
| 1442 | 1442 | public function countAllHoursFromToday($filters = array()) |
| 1443 | 1443 | { |
| 1444 | 1444 | global $globalTimezone, $globalDBdriver; |
@@ -1478,12 +1478,12 @@ discard block |
||
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | 1480 | |
| 1481 | - /** |
|
| 1482 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1483 | - * |
|
| 1484 | - * @return Integer the Barrie Spotter ID |
|
| 1481 | + /** |
|
| 1482 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
| 1483 | + * |
|
| 1484 | + * @return Integer the Barrie Spotter ID |
|
| 1485 | 1485 | q * |
| 1486 | - */ |
|
| 1486 | + */ |
|
| 1487 | 1487 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1488 | 1488 | { |
| 1489 | 1489 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1504,13 +1504,13 @@ discard block |
||
| 1504 | 1504 | |
| 1505 | 1505 | |
| 1506 | 1506 | /** |
| 1507 | - * Parses a date string |
|
| 1508 | - * |
|
| 1509 | - * @param String $dateString the date string |
|
| 1510 | - * @param String $timezone the timezone of a user |
|
| 1511 | - * @return Array the time information |
|
| 1512 | - * |
|
| 1513 | - */ |
|
| 1507 | + * Parses a date string |
|
| 1508 | + * |
|
| 1509 | + * @param String $dateString the date string |
|
| 1510 | + * @param String $timezone the timezone of a user |
|
| 1511 | + * @return Array the time information |
|
| 1512 | + * |
|
| 1513 | + */ |
|
| 1514 | 1514 | public function parseDateString($dateString, $timezone = '') |
| 1515 | 1515 | { |
| 1516 | 1516 | $time_array = array(); |
@@ -1543,12 +1543,12 @@ discard block |
||
| 1543 | 1543 | } |
| 1544 | 1544 | |
| 1545 | 1545 | /** |
| 1546 | - * Parses the direction degrees to working |
|
| 1547 | - * |
|
| 1548 | - * @param Float $direction the direction in degrees |
|
| 1549 | - * @return Array the direction information |
|
| 1550 | - * |
|
| 1551 | - */ |
|
| 1546 | + * Parses the direction degrees to working |
|
| 1547 | + * |
|
| 1548 | + * @param Float $direction the direction in degrees |
|
| 1549 | + * @return Array the direction information |
|
| 1550 | + * |
|
| 1551 | + */ |
|
| 1552 | 1552 | public function parseDirection($direction = 0) |
| 1553 | 1553 | { |
| 1554 | 1554 | if ($direction == '') $direction = 0; |
@@ -1627,12 +1627,12 @@ discard block |
||
| 1627 | 1627 | |
| 1628 | 1628 | |
| 1629 | 1629 | /** |
| 1630 | - * Gets Country from latitude/longitude |
|
| 1631 | - * |
|
| 1632 | - * @param Float $latitude latitute of the flight |
|
| 1633 | - * @param Float $longitude longitute of the flight |
|
| 1634 | - * @return String the countrie |
|
| 1635 | - */ |
|
| 1630 | + * Gets Country from latitude/longitude |
|
| 1631 | + * |
|
| 1632 | + * @param Float $latitude latitute of the flight |
|
| 1633 | + * @param Float $longitude longitute of the flight |
|
| 1634 | + * @return String the countrie |
|
| 1635 | + */ |
|
| 1636 | 1636 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
| 1637 | 1637 | { |
| 1638 | 1638 | global $globalDBdriver, $globalDebug; |
@@ -1669,11 +1669,11 @@ discard block |
||
| 1669 | 1669 | } |
| 1670 | 1670 | |
| 1671 | 1671 | /** |
| 1672 | - * Gets Country from iso2 |
|
| 1673 | - * |
|
| 1674 | - * @param String $iso2 ISO2 country code |
|
| 1675 | - * @return String the countrie |
|
| 1676 | - */ |
|
| 1672 | + * Gets Country from iso2 |
|
| 1673 | + * |
|
| 1674 | + * @param String $iso2 ISO2 country code |
|
| 1675 | + * @return String the countrie |
|
| 1676 | + */ |
|
| 1677 | 1677 | public function getCountryFromISO2($iso2) |
| 1678 | 1678 | { |
| 1679 | 1679 | global $globalDBdriver, $globalDebug; |
@@ -1702,12 +1702,12 @@ discard block |
||
| 1702 | 1702 | |
| 1703 | 1703 | |
| 1704 | 1704 | /** |
| 1705 | - * Gets the short url from bit.ly |
|
| 1706 | - * |
|
| 1707 | - * @param String $url the full url |
|
| 1708 | - * @return String the bit.ly url |
|
| 1709 | - * |
|
| 1710 | - */ |
|
| 1705 | + * Gets the short url from bit.ly |
|
| 1706 | + * |
|
| 1707 | + * @param String $url the full url |
|
| 1708 | + * @return String the bit.ly url |
|
| 1709 | + * |
|
| 1710 | + */ |
|
| 1711 | 1711 | public function getBitlyURL($url) |
| 1712 | 1712 | { |
| 1713 | 1713 | global $globalBitlyAccessToken; |
@@ -1734,11 +1734,11 @@ discard block |
||
| 1734 | 1734 | |
| 1735 | 1735 | |
| 1736 | 1736 | /** |
| 1737 | - * Gets all vessels types that have flown over |
|
| 1738 | - * |
|
| 1739 | - * @return Array the vessel type list |
|
| 1740 | - * |
|
| 1741 | - */ |
|
| 1737 | + * Gets all vessels types that have flown over |
|
| 1738 | + * |
|
| 1739 | + * @return Array the vessel type list |
|
| 1740 | + * |
|
| 1741 | + */ |
|
| 1742 | 1742 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
| 1743 | 1743 | { |
| 1744 | 1744 | global $globalDBdriver; |
@@ -29,7 +29,9 @@ discard block |
||
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | 30 | $filters = array_merge($filters,$filter); |
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 33 | 35 | $filter_query_join = ''; |
| 34 | 36 | $filter_query_where = ''; |
| 35 | 37 | foreach($filters as $flt) { |
@@ -68,8 +70,11 @@ discard block |
||
| 68 | 70 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 69 | 71 | } |
| 70 | 72 | } |
| 71 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 72 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 73 | + if ($filter_query_where == '' && $where) { |
|
| 74 | + $filter_query_where = ' WHERE'; |
|
| 75 | + } elseif ($filter_query_where != '' && $and) { |
|
| 76 | + $filter_query_where .= ' AND'; |
|
| 77 | + } |
|
| 73 | 78 | if ($filter_query_where != '') { |
| 74 | 79 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 75 | 80 | } |
@@ -123,32 +128,54 @@ discard block |
||
| 123 | 128 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
| 124 | 129 | } elseif (isset($row['spotter_archive_output_id'])) { |
| 125 | 130 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
| 126 | - */} |
|
| 127 | - elseif (isset($row['marineid'])) { |
|
| 131 | + */} elseif (isset($row['marineid'])) { |
|
| 128 | 132 | $temp_array['marine_id'] = $row['marineid']; |
| 129 | 133 | } else { |
| 130 | 134 | $temp_array['marine_id'] = ''; |
| 131 | 135 | } |
| 132 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 133 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
| 134 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
| 135 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
| 136 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
| 137 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
| 138 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
| 139 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
| 136 | + if (isset($row['fammarine_id'])) { |
|
| 137 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
| 138 | + } |
|
| 139 | + if (isset($row['mmsi'])) { |
|
| 140 | + $temp_array['mmsi'] = $row['mmsi']; |
|
| 141 | + } |
|
| 142 | + if (isset($row['type'])) { |
|
| 143 | + $temp_array['type'] = $row['type']; |
|
| 144 | + } |
|
| 145 | + if (isset($row['type_id'])) { |
|
| 146 | + $temp_array['type_id'] = $row['type_id']; |
|
| 147 | + } |
|
| 148 | + if (isset($row['ident'])) { |
|
| 149 | + $temp_array['ident'] = $row['ident']; |
|
| 150 | + } |
|
| 151 | + if (isset($row['latitude'])) { |
|
| 152 | + $temp_array['latitude'] = $row['latitude']; |
|
| 153 | + } |
|
| 154 | + if (isset($row['longitude'])) { |
|
| 155 | + $temp_array['longitude'] = $row['longitude']; |
|
| 156 | + } |
|
| 157 | + if (isset($row['format_source'])) { |
|
| 158 | + $temp_array['format_source'] = $row['format_source']; |
|
| 159 | + } |
|
| 140 | 160 | if (isset($row['heading'])) { |
| 141 | 161 | $temp_array['heading'] = $row['heading']; |
| 142 | 162 | $heading_direction = $this->parseDirection($row['heading']); |
| 143 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 163 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
| 164 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + if (isset($row['ground_speed'])) { |
|
| 168 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 144 | 169 | } |
| 145 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
| 146 | 170 | |
| 147 | 171 | if($temp_array['mmsi'] != "") |
| 148 | 172 | { |
| 149 | 173 | $Image = new Image($this->db); |
| 150 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 151 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 174 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
| 175 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 176 | + } else { |
|
| 177 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
| 178 | + } |
|
| 152 | 179 | unset($Image); |
| 153 | 180 | if (count($image_array) > 0) { |
| 154 | 181 | $temp_array['image'] = $image_array[0]['image']; |
@@ -200,13 +227,21 @@ discard block |
||
| 200 | 227 | } |
| 201 | 228 | |
| 202 | 229 | $fromsource = NULL; |
| 203 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
| 204 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
| 205 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
| 230 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
| 231 | + $temp_array['source_name'] = $row['source_name']; |
|
| 232 | + } |
|
| 233 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
| 234 | + $temp_array['over_country'] = $row['over_country']; |
|
| 235 | + } |
|
| 236 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
| 237 | + $temp_array['distance'] = $row['distance']; |
|
| 238 | + } |
|
| 206 | 239 | $temp_array['query_number_rows'] = $num_rows; |
| 207 | 240 | $spotter_array[] = $temp_array; |
| 208 | 241 | } |
| 209 | - if ($num_rows == 0) return array(); |
|
| 242 | + if ($num_rows == 0) { |
|
| 243 | + return array(); |
|
| 244 | + } |
|
| 210 | 245 | $spotter_array[0]['query_number_rows'] = $num_rows; |
| 211 | 246 | return $spotter_array; |
| 212 | 247 | } |
@@ -232,8 +267,12 @@ discard block |
||
| 232 | 267 | { |
| 233 | 268 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 234 | 269 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 235 | - } else $limit_query = ""; |
|
| 236 | - } else $limit_query = ""; |
|
| 270 | + } else { |
|
| 271 | + $limit_query = ""; |
|
| 272 | + } |
|
| 273 | + } else { |
|
| 274 | + $limit_query = ""; |
|
| 275 | + } |
|
| 237 | 276 | if ($sort != "") |
| 238 | 277 | { |
| 239 | 278 | $search_orderby_array = $this->getOrderBy(); |
@@ -257,7 +296,9 @@ discard block |
||
| 257 | 296 | global $global_query; |
| 258 | 297 | |
| 259 | 298 | date_default_timezone_set('UTC'); |
| 260 | - if ($id == '') return array(); |
|
| 299 | + if ($id == '') { |
|
| 300 | + return array(); |
|
| 301 | + } |
|
| 261 | 302 | $additional_query = "marine_output.fammarine_id = :id"; |
| 262 | 303 | $query_values = array(':id' => $id); |
| 263 | 304 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -400,8 +441,11 @@ discard block |
||
| 400 | 441 | $query .= " ORDER BY marine_output.source_name ASC"; |
| 401 | 442 | |
| 402 | 443 | $sth = $this->db->prepare($query); |
| 403 | - if (!empty($query_values)) $sth->execute($query_values); |
|
| 404 | - else $sth->execute(); |
|
| 444 | + if (!empty($query_values)) { |
|
| 445 | + $sth->execute($query_values); |
|
| 446 | + } else { |
|
| 447 | + $sth->execute(); |
|
| 448 | + } |
|
| 405 | 449 | |
| 406 | 450 | $source_array = array(); |
| 407 | 451 | $temp_array = array(); |
@@ -456,8 +500,11 @@ discard block |
||
| 456 | 500 | $sth = $this->db->prepare($query); |
| 457 | 501 | $sth->execute(array(':mmsi' => $mmsi)); |
| 458 | 502 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 459 | - if (isset($result[0])) return $result[0]; |
|
| 460 | - else return array(); |
|
| 503 | + if (isset($result[0])) { |
|
| 504 | + return $result[0]; |
|
| 505 | + } else { |
|
| 506 | + return array(); |
|
| 507 | + } |
|
| 461 | 508 | } |
| 462 | 509 | |
| 463 | 510 | /* |
@@ -473,7 +520,9 @@ discard block |
||
| 473 | 520 | date_default_timezone_set($globalTimezone); |
| 474 | 521 | $datetime = new DateTime(); |
| 475 | 522 | $offset = $datetime->format('P'); |
| 476 | - } else $offset = '+00:00'; |
|
| 523 | + } else { |
|
| 524 | + $offset = '+00:00'; |
|
| 525 | + } |
|
| 477 | 526 | |
| 478 | 527 | if ($globalDBdriver == 'mysql') { |
| 479 | 528 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -703,9 +752,15 @@ discard block |
||
| 703 | 752 | $latitude = 0; |
| 704 | 753 | $longitude = 0; |
| 705 | 754 | } |
| 706 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 707 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 708 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 755 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
| 756 | + $heading = 0; |
|
| 757 | + } |
|
| 758 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
| 759 | + $groundspeed = 0; |
|
| 760 | + } |
|
| 761 | + if ($arrival_date == '') { |
|
| 762 | + $arrival_date = NULL; |
|
| 763 | + } |
|
| 709 | 764 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
| 710 | 765 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 711 | 766 | |
@@ -813,7 +868,9 @@ discard block |
||
| 813 | 868 | global $globalDBdriver, $globalArchive; |
| 814 | 869 | //$filter_query = $this->getFilter($filters,true,true); |
| 815 | 870 | $Connection= new Connection($this->db); |
| 816 | - if (!$Connection->tableExists('countries')) return array(); |
|
| 871 | + if (!$Connection->tableExists('countries')) { |
|
| 872 | + return array(); |
|
| 873 | + } |
|
| 817 | 874 | require_once('class.SpotterLive.php'); |
| 818 | 875 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 819 | 876 | $MarineLive = new MarineLive(); |
@@ -857,7 +914,9 @@ discard block |
||
| 857 | 914 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
| 858 | 915 | } |
| 859 | 916 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
| 860 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 917 | + if ($limit) { |
|
| 918 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 919 | + } |
|
| 861 | 920 | |
| 862 | 921 | $sth = $this->db->prepare($query); |
| 863 | 922 | $sth->execute(); |
@@ -891,12 +950,18 @@ discard block |
||
| 891 | 950 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
| 892 | 951 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 893 | 952 | if ($olderthanmonths > 0) { |
| 894 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 895 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 953 | + if ($globalDBdriver == 'mysql') { |
|
| 954 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
| 955 | + } else { |
|
| 956 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
| 957 | + } |
|
| 896 | 958 | } |
| 897 | 959 | if ($sincedate != '') { |
| 898 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 899 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 960 | + if ($globalDBdriver == 'mysql') { |
|
| 961 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
| 962 | + } else { |
|
| 963 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
| 964 | + } |
|
| 900 | 965 | } |
| 901 | 966 | $query_values = array(); |
| 902 | 967 | if ($year != '') { |
@@ -927,7 +992,9 @@ discard block |
||
| 927 | 992 | } |
| 928 | 993 | } |
| 929 | 994 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
| 930 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 995 | + if ($limit) { |
|
| 996 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 997 | + } |
|
| 931 | 998 | |
| 932 | 999 | $sth = $this->db->prepare($query); |
| 933 | 1000 | $sth->execute($query_values); |
@@ -962,7 +1029,9 @@ discard block |
||
| 962 | 1029 | date_default_timezone_set($globalTimezone); |
| 963 | 1030 | $datetime = new DateTime(); |
| 964 | 1031 | $offset = $datetime->format('P'); |
| 965 | - } else $offset = '+00:00'; |
|
| 1032 | + } else { |
|
| 1033 | + $offset = '+00:00'; |
|
| 1034 | + } |
|
| 966 | 1035 | |
| 967 | 1036 | if ($globalDBdriver == 'mysql') { |
| 968 | 1037 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1012,7 +1081,9 @@ discard block |
||
| 1012 | 1081 | date_default_timezone_set($globalTimezone); |
| 1013 | 1082 | $datetime = new DateTime(); |
| 1014 | 1083 | $offset = $datetime->format('P'); |
| 1015 | - } else $offset = '+00:00'; |
|
| 1084 | + } else { |
|
| 1085 | + $offset = '+00:00'; |
|
| 1086 | + } |
|
| 1016 | 1087 | $filter_query = $this->getFilter($filters,true,true); |
| 1017 | 1088 | if ($globalDBdriver == 'mysql') { |
| 1018 | 1089 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1058,7 +1129,9 @@ discard block |
||
| 1058 | 1129 | date_default_timezone_set($globalTimezone); |
| 1059 | 1130 | $datetime = new DateTime(); |
| 1060 | 1131 | $offset = $datetime->format('P'); |
| 1061 | - } else $offset = '+00:00'; |
|
| 1132 | + } else { |
|
| 1133 | + $offset = '+00:00'; |
|
| 1134 | + } |
|
| 1062 | 1135 | $filter_query = $this->getFilter($filters,true,true); |
| 1063 | 1136 | if ($globalDBdriver == 'mysql') { |
| 1064 | 1137 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1106,7 +1179,9 @@ discard block |
||
| 1106 | 1179 | date_default_timezone_set($globalTimezone); |
| 1107 | 1180 | $datetime = new DateTime(); |
| 1108 | 1181 | $offset = $datetime->format('P'); |
| 1109 | - } else $offset = '+00:00'; |
|
| 1182 | + } else { |
|
| 1183 | + $offset = '+00:00'; |
|
| 1184 | + } |
|
| 1110 | 1185 | |
| 1111 | 1186 | if ($globalDBdriver == 'mysql') { |
| 1112 | 1187 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1155,7 +1230,9 @@ discard block |
||
| 1155 | 1230 | date_default_timezone_set($globalTimezone); |
| 1156 | 1231 | $datetime = new DateTime(); |
| 1157 | 1232 | $offset = $datetime->format('P'); |
| 1158 | - } else $offset = '+00:00'; |
|
| 1233 | + } else { |
|
| 1234 | + $offset = '+00:00'; |
|
| 1235 | + } |
|
| 1159 | 1236 | $filter_query = $this->getFilter($filters,true,true); |
| 1160 | 1237 | if ($globalDBdriver == 'mysql') { |
| 1161 | 1238 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1204,7 +1281,9 @@ discard block |
||
| 1204 | 1281 | date_default_timezone_set($globalTimezone); |
| 1205 | 1282 | $datetime = new DateTime(); |
| 1206 | 1283 | $offset = $datetime->format('P'); |
| 1207 | - } else $offset = '+00:00'; |
|
| 1284 | + } else { |
|
| 1285 | + $offset = '+00:00'; |
|
| 1286 | + } |
|
| 1208 | 1287 | |
| 1209 | 1288 | $orderby_sql = ''; |
| 1210 | 1289 | if ($orderby == "hour") |
@@ -1273,7 +1352,9 @@ discard block |
||
| 1273 | 1352 | date_default_timezone_set($globalTimezone); |
| 1274 | 1353 | $datetime = new DateTime($date); |
| 1275 | 1354 | $offset = $datetime->format('P'); |
| 1276 | - } else $offset = '+00:00'; |
|
| 1355 | + } else { |
|
| 1356 | + $offset = '+00:00'; |
|
| 1357 | + } |
|
| 1277 | 1358 | |
| 1278 | 1359 | if ($globalDBdriver == 'mysql') { |
| 1279 | 1360 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1321,7 +1402,9 @@ discard block |
||
| 1321 | 1402 | date_default_timezone_set($globalTimezone); |
| 1322 | 1403 | $datetime = new DateTime(); |
| 1323 | 1404 | $offset = $datetime->format('P'); |
| 1324 | - } else $offset = '+00:00'; |
|
| 1405 | + } else { |
|
| 1406 | + $offset = '+00:00'; |
|
| 1407 | + } |
|
| 1325 | 1408 | |
| 1326 | 1409 | if ($globalDBdriver == 'mysql') { |
| 1327 | 1410 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1386,8 +1469,11 @@ discard block |
||
| 1386 | 1469 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1387 | 1470 | } |
| 1388 | 1471 | } |
| 1389 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1390 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1472 | + if (empty($query_values)) { |
|
| 1473 | + $queryi .= $this->getFilter($filters); |
|
| 1474 | + } else { |
|
| 1475 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1476 | + } |
|
| 1391 | 1477 | |
| 1392 | 1478 | $sth = $this->db->prepare($queryi); |
| 1393 | 1479 | $sth->execute($query_values); |
@@ -1424,8 +1510,11 @@ discard block |
||
| 1424 | 1510 | $query_values = array_merge($query_values,array(':month' => $month)); |
| 1425 | 1511 | } |
| 1426 | 1512 | } |
| 1427 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
| 1428 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1513 | + if (empty($query_values)) { |
|
| 1514 | + $queryi .= $this->getFilter($filters); |
|
| 1515 | + } else { |
|
| 1516 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1517 | + } |
|
| 1429 | 1518 | |
| 1430 | 1519 | $sth = $this->db->prepare($queryi); |
| 1431 | 1520 | $sth->execute($query_values); |
@@ -1447,7 +1536,9 @@ discard block |
||
| 1447 | 1536 | date_default_timezone_set($globalTimezone); |
| 1448 | 1537 | $datetime = new DateTime(); |
| 1449 | 1538 | $offset = $datetime->format('P'); |
| 1450 | - } else $offset = '+00:00'; |
|
| 1539 | + } else { |
|
| 1540 | + $offset = '+00:00'; |
|
| 1541 | + } |
|
| 1451 | 1542 | |
| 1452 | 1543 | if ($globalDBdriver == 'mysql') { |
| 1453 | 1544 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1551,7 +1642,9 @@ discard block |
||
| 1551 | 1642 | */ |
| 1552 | 1643 | public function parseDirection($direction = 0) |
| 1553 | 1644 | { |
| 1554 | - if ($direction == '') $direction = 0; |
|
| 1645 | + if ($direction == '') { |
|
| 1646 | + $direction = 0; |
|
| 1647 | + } |
|
| 1555 | 1648 | $direction_array = array(); |
| 1556 | 1649 | $temp_array = array(); |
| 1557 | 1650 | |
@@ -1640,7 +1733,9 @@ discard block |
||
| 1640 | 1733 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 1641 | 1734 | |
| 1642 | 1735 | $Connection = new Connection($this->db); |
| 1643 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1736 | + if (!$Connection->tableExists('countries')) { |
|
| 1737 | + return ''; |
|
| 1738 | + } |
|
| 1644 | 1739 | |
| 1645 | 1740 | try { |
| 1646 | 1741 | /* |
@@ -1660,9 +1755,13 @@ discard block |
||
| 1660 | 1755 | $sth->closeCursor(); |
| 1661 | 1756 | if (count($row) > 0) { |
| 1662 | 1757 | return $row; |
| 1663 | - } else return ''; |
|
| 1758 | + } else { |
|
| 1759 | + return ''; |
|
| 1760 | + } |
|
| 1664 | 1761 | } catch (PDOException $e) { |
| 1665 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1762 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1763 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1764 | + } |
|
| 1666 | 1765 | return ''; |
| 1667 | 1766 | } |
| 1668 | 1767 | |
@@ -1680,7 +1779,9 @@ discard block |
||
| 1680 | 1779 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
| 1681 | 1780 | |
| 1682 | 1781 | $Connection = new Connection($this->db); |
| 1683 | - if (!$Connection->tableExists('countries')) return ''; |
|
| 1782 | + if (!$Connection->tableExists('countries')) { |
|
| 1783 | + return ''; |
|
| 1784 | + } |
|
| 1684 | 1785 | |
| 1685 | 1786 | try { |
| 1686 | 1787 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1692,9 +1793,13 @@ discard block |
||
| 1692 | 1793 | $sth->closeCursor(); |
| 1693 | 1794 | if (count($row) > 0) { |
| 1694 | 1795 | return $row; |
| 1695 | - } else return ''; |
|
| 1796 | + } else { |
|
| 1797 | + return ''; |
|
| 1798 | + } |
|
| 1696 | 1799 | } catch (PDOException $e) { |
| 1697 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
| 1800 | + if (isset($globalDebug) && $globalDebug) { |
|
| 1801 | + echo 'Error : '.$e->getMessage()."\n"; |
|
| 1802 | + } |
|
| 1698 | 1803 | return ''; |
| 1699 | 1804 | } |
| 1700 | 1805 | |
@@ -1712,7 +1817,9 @@ discard block |
||
| 1712 | 1817 | { |
| 1713 | 1818 | global $globalBitlyAccessToken; |
| 1714 | 1819 | |
| 1715 | - if ($globalBitlyAccessToken == '') return $url; |
|
| 1820 | + if ($globalBitlyAccessToken == '') { |
|
| 1821 | + return $url; |
|
| 1822 | + } |
|
| 1716 | 1823 | |
| 1717 | 1824 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
| 1718 | 1825 | |
@@ -1788,7 +1895,9 @@ discard block |
||
| 1788 | 1895 | } |
| 1789 | 1896 | } |
| 1790 | 1897 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
| 1791 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 1898 | + if ($limit) { |
|
| 1899 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 1900 | + } |
|
| 1792 | 1901 | $sth = $this->db->prepare($query); |
| 1793 | 1902 | $sth->execute($query_values); |
| 1794 | 1903 | $marine_array = array(); |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
| 4 | 4 | |
| 5 | -class Marine{ |
|
| 5 | +class Marine { |
|
| 6 | 6 | public $db; |
| 7 | 7 | |
| 8 | 8 | public function __construct($dbc = null) { |
@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | * @return Array the SQL part |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 37 | 37 | if (isset($flt['source'])) { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 39 | 39 | } else { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 72 | 72 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 73 | 73 | if ($filter_query_where != '') { |
| 74 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 74 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 75 | 75 | } |
| 76 | 76 | $filter_query = $filter_query_join.$filter_query_where; |
| 77 | 77 | return $filter_query; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @return Array the spotter information |
| 87 | 87 | * |
| 88 | 88 | */ |
| 89 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 89 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 90 | 90 | { |
| 91 | 91 | date_default_timezone_set('UTC'); |
| 92 | 92 | if (!is_string($query)) |
@@ -106,13 +106,13 @@ discard block |
||
| 106 | 106 | $sth = $this->db->prepare($query.$limitQuery); |
| 107 | 107 | $sth->execute($params); |
| 108 | 108 | } catch (PDOException $e) { |
| 109 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 109 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 110 | 110 | exit(); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $num_rows = 0; |
| 114 | 114 | $spotter_array = array(); |
| 115 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 115 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 116 | 116 | { |
| 117 | 117 | $num_rows++; |
| 118 | 118 | $temp_array = array(); |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
| 146 | 146 | |
| 147 | - if($temp_array['mmsi'] != "") |
|
| 147 | + if ($temp_array['mmsi'] != "") |
|
| 148 | 148 | { |
| 149 | 149 | $Image = new Image($this->db); |
| 150 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
| 150 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
| 151 | 151 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
| 152 | 152 | unset($Image); |
| 153 | 153 | if (count($image_array) > 0) { |
@@ -183,17 +183,17 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 185 | 185 | } else { |
| 186 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 186 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 187 | 187 | } |
| 188 | 188 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 189 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 190 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 189 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 190 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 191 | 191 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 192 | 192 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 193 | 193 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 194 | 194 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 195 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 196 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 195 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 196 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 197 | 197 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 198 | 198 | } |
| 199 | 199 | } |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | if ($limit != "") |
| 227 | 227 | { |
| 228 | 228 | $limit_array = explode(",", $limit); |
| 229 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 230 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 229 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 230 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 231 | 231 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 232 | 232 | { |
| 233 | 233 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -241,8 +241,8 @@ discard block |
||
| 241 | 241 | } else { |
| 242 | 242 | $orderby_query = " ORDER BY marine_output.date DESC"; |
| 243 | 243 | } |
| 244 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
| 245 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 244 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
| 245 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 246 | 246 | return $spotter_array; |
| 247 | 247 | } |
| 248 | 248 | |
@@ -260,8 +260,8 @@ discard block |
||
| 260 | 260 | if ($id == '') return array(); |
| 261 | 261 | $additional_query = "marine_output.fammarine_id = :id"; |
| 262 | 262 | $query_values = array(':id' => $id); |
| 263 | - $query = $global_query." WHERE ".$additional_query." "; |
|
| 264 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 263 | + $query = $global_query." WHERE ".$additional_query." "; |
|
| 264 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 265 | 265 | return $spotter_array; |
| 266 | 266 | } |
| 267 | 267 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | $query_values = array(); |
| 281 | 281 | $limit_query = ''; |
| 282 | 282 | $additional_query = ''; |
| 283 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 283 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 284 | 284 | if ($ident != "") |
| 285 | 285 | { |
| 286 | 286 | if (!is_string($ident)) |
@@ -296,8 +296,8 @@ discard block |
||
| 296 | 296 | { |
| 297 | 297 | $limit_array = explode(",", $limit); |
| 298 | 298 | |
| 299 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 300 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 299 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 300 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 301 | 301 | |
| 302 | 302 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 303 | 303 | { |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | return $spotter_array; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
| 324 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 325 | 325 | { |
| 326 | 326 | global $global_query, $globalTimezone, $globalDBdriver; |
| 327 | 327 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | $limit_query = ''; |
| 330 | 330 | $additional_query = ''; |
| 331 | 331 | |
| 332 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 332 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 333 | 333 | |
| 334 | 334 | if ($date != "") |
| 335 | 335 | { |
@@ -355,8 +355,8 @@ discard block |
||
| 355 | 355 | { |
| 356 | 356 | $limit_array = explode(",", $limit); |
| 357 | 357 | |
| 358 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 359 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 358 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 359 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 360 | 360 | |
| 361 | 361 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 362 | 362 | { |
@@ -387,11 +387,11 @@ discard block |
||
| 387 | 387 | * @return Array list of source name |
| 388 | 388 | * |
| 389 | 389 | */ |
| 390 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 390 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 391 | 391 | { |
| 392 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 392 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 393 | 393 | $query_values = array(); |
| 394 | - $query = "SELECT DISTINCT marine_output.source_name |
|
| 394 | + $query = "SELECT DISTINCT marine_output.source_name |
|
| 395 | 395 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
| 396 | 396 | if ($type != '') { |
| 397 | 397 | $query_values = array(':type' => $type); |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | $source_array = array(); |
| 407 | 407 | $temp_array = array(); |
| 408 | 408 | |
| 409 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 409 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 410 | 410 | { |
| 411 | 411 | $temp_array['source_name'] = $row['source_name']; |
| 412 | 412 | $source_array[] = $temp_array; |
@@ -423,8 +423,8 @@ discard block |
||
| 423 | 423 | */ |
| 424 | 424 | public function getAllIdents($filters = array()) |
| 425 | 425 | { |
| 426 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 427 | - $query = "SELECT DISTINCT marine_output.ident |
|
| 426 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 427 | + $query = "SELECT DISTINCT marine_output.ident |
|
| 428 | 428 | FROM marine_output".$filter_query." marine_output.ident <> '' |
| 429 | 429 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
| 430 | 430 | |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | $ident_array = array(); |
| 435 | 435 | $temp_array = array(); |
| 436 | 436 | |
| 437 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 437 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 438 | 438 | { |
| 439 | 439 | $temp_array['ident'] = $row['ident']; |
| 440 | 440 | $ident_array[] = $temp_array; |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | */ |
| 452 | 452 | public function getIdentity($mmsi) |
| 453 | 453 | { |
| 454 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 454 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 455 | 455 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
| 456 | 456 | $sth = $this->db->prepare($query); |
| 457 | 457 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -476,12 +476,12 @@ discard block |
||
| 476 | 476 | } else $offset = '+00:00'; |
| 477 | 477 | |
| 478 | 478 | if ($globalDBdriver == 'mysql') { |
| 479 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 479 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
| 480 | 480 | FROM marine_output |
| 481 | 481 | WHERE marine_output.date <> '' |
| 482 | 482 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
| 483 | 483 | } else { |
| 484 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 484 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 485 | 485 | FROM marine_output |
| 486 | 486 | WHERE marine_output.date <> '' |
| 487 | 487 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | $date_array = array(); |
| 494 | 494 | $temp_array = array(); |
| 495 | 495 | |
| 496 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 496 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 497 | 497 | { |
| 498 | 498 | $temp_array['date'] = $row['date']; |
| 499 | 499 | |
@@ -512,11 +512,11 @@ discard block |
||
| 512 | 512 | * @return String success or false |
| 513 | 513 | * |
| 514 | 514 | */ |
| 515 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
| 515 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
| 516 | 516 | { |
| 517 | 517 | |
| 518 | 518 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
| 519 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
| 519 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
| 520 | 520 | |
| 521 | 521 | try { |
| 522 | 522 | $sth = $this->db->prepare($query); |
@@ -538,11 +538,11 @@ discard block |
||
| 538 | 538 | * @return String success or false |
| 539 | 539 | * |
| 540 | 540 | */ |
| 541 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
| 541 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
| 542 | 542 | { |
| 543 | 543 | |
| 544 | 544 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
| 545 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
| 545 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
| 546 | 546 | |
| 547 | 547 | try { |
| 548 | 548 | $sth = $this->db->prepare($query); |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
| 566 | 566 | { |
| 567 | 567 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
| 568 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
| 568 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
| 569 | 569 | |
| 570 | 570 | try { |
| 571 | 571 | $sth = $this->db->prepare($query); |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | * @param String $verticalrate vertival rate of flight |
| 604 | 604 | * @return String success or false |
| 605 | 605 | */ |
| 606 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
|
| 606 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '') |
|
| 607 | 607 | { |
| 608 | 608 | global $globalURL, $globalMarineImageFetch; |
| 609 | 609 | |
@@ -670,31 +670,31 @@ discard block |
||
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | |
| 673 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
| 673 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
| 674 | 674 | { |
| 675 | 675 | $date = date("Y-m-d H:i:s", time()); |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 679 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 680 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 681 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 682 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 683 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 684 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 685 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
| 686 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 687 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 688 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 689 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 690 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 691 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 678 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 679 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 680 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 681 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 682 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 683 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 684 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 685 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
| 686 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 687 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 688 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 689 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 690 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 691 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 692 | 692 | |
| 693 | 693 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
| 694 | 694 | $Image = new Image($this->db); |
| 695 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
| 695 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
| 696 | 696 | if (!isset($image_array[0]['mmsi'])) { |
| 697 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
| 697 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
| 698 | 698 | } |
| 699 | 699 | unset($Image); |
| 700 | 700 | } |
@@ -706,10 +706,10 @@ discard block |
||
| 706 | 706 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 707 | 707 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 708 | 708 | if ($arrival_date == '') $arrival_date = NULL; |
| 709 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
| 709 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
| 710 | 710 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
| 711 | 711 | |
| 712 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
| 712 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
| 713 | 713 | try { |
| 714 | 714 | |
| 715 | 715 | $sth = $this->db->prepare($query); |
@@ -734,13 +734,13 @@ discard block |
||
| 734 | 734 | { |
| 735 | 735 | global $globalDBdriver, $globalTimezone; |
| 736 | 736 | if ($globalDBdriver == 'mysql') { |
| 737 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 737 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 738 | 738 | WHERE marine_output.ident = :ident |
| 739 | 739 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 740 | 740 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 741 | 741 | $query_data = array(':ident' => $ident); |
| 742 | 742 | } else { |
| 743 | - $query = "SELECT marine_output.ident FROM marine_output |
|
| 743 | + $query = "SELECT marine_output.ident FROM marine_output |
|
| 744 | 744 | WHERE marine_output.ident = :ident |
| 745 | 745 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 746 | 746 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -749,8 +749,8 @@ discard block |
||
| 749 | 749 | |
| 750 | 750 | $sth = $this->db->prepare($query); |
| 751 | 751 | $sth->execute($query_data); |
| 752 | - $ident_result=''; |
|
| 753 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 752 | + $ident_result = ''; |
|
| 753 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 754 | 754 | { |
| 755 | 755 | $ident_result = $row['ident']; |
| 756 | 756 | } |
@@ -776,8 +776,8 @@ discard block |
||
| 776 | 776 | return false; |
| 777 | 777 | } else { |
| 778 | 778 | $q_array = explode(" ", $q); |
| 779 | - foreach ($q_array as $q_item){ |
|
| 780 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 779 | + foreach ($q_array as $q_item) { |
|
| 780 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 781 | 781 | $additional_query .= " AND ("; |
| 782 | 782 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
| 783 | 783 | $additional_query .= ")"; |
@@ -785,11 +785,11 @@ discard block |
||
| 785 | 785 | } |
| 786 | 786 | } |
| 787 | 787 | if ($globalDBdriver == 'mysql') { |
| 788 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 788 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 789 | 789 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 790 | 790 | AND marine_output.date < UTC_TIMESTAMP()"; |
| 791 | 791 | } else { |
| 792 | - $query = "SELECT marine_output.* FROM marine_output |
|
| 792 | + $query = "SELECT marine_output.* FROM marine_output |
|
| 793 | 793 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 794 | 794 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 795 | 795 | } |
@@ -808,16 +808,16 @@ discard block |
||
| 808 | 808 | * |
| 809 | 809 | */ |
| 810 | 810 | |
| 811 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 811 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 812 | 812 | { |
| 813 | 813 | global $globalDBdriver, $globalArchive; |
| 814 | 814 | //$filter_query = $this->getFilter($filters,true,true); |
| 815 | - $Connection= new Connection($this->db); |
|
| 815 | + $Connection = new Connection($this->db); |
|
| 816 | 816 | if (!$Connection->tableExists('countries')) return array(); |
| 817 | 817 | require_once('class.SpotterLive.php'); |
| 818 | 818 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
| 819 | 819 | $MarineLive = new MarineLive(); |
| 820 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
| 820 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
| 821 | 821 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
| 822 | 822 | if ($olderthanmonths > 0) { |
| 823 | 823 | if ($globalDBdriver == 'mysql') { |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | } else { |
| 838 | 838 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
| 839 | 839 | $MarineArchive = new MarineArchive(); |
| 840 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
| 840 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
| 841 | 841 | $filter_query .= " over_country <> ''"; |
| 842 | 842 | if ($olderthanmonths > 0) { |
| 843 | 843 | if ($globalDBdriver == 'mysql') { |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | $flight_array = array(); |
| 866 | 866 | $temp_array = array(); |
| 867 | 867 | |
| 868 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 868 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 869 | 869 | { |
| 870 | 870 | $temp_array['marine_count'] = $row['nb']; |
| 871 | 871 | $temp_array['marine_country'] = $row['name']; |
@@ -884,11 +884,11 @@ discard block |
||
| 884 | 884 | * @return Array the callsign list |
| 885 | 885 | * |
| 886 | 886 | */ |
| 887 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 887 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 888 | 888 | { |
| 889 | 889 | global $globalDBdriver; |
| 890 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 891 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 890 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 891 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
| 892 | 892 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
| 893 | 893 | if ($olderthanmonths > 0) { |
| 894 | 894 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -902,28 +902,28 @@ discard block |
||
| 902 | 902 | if ($year != '') { |
| 903 | 903 | if ($globalDBdriver == 'mysql') { |
| 904 | 904 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 905 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 905 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 906 | 906 | } else { |
| 907 | 907 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 908 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 908 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 909 | 909 | } |
| 910 | 910 | } |
| 911 | 911 | if ($month != '') { |
| 912 | 912 | if ($globalDBdriver == 'mysql') { |
| 913 | 913 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 914 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 914 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 915 | 915 | } else { |
| 916 | 916 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 917 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 917 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 918 | 918 | } |
| 919 | 919 | } |
| 920 | 920 | if ($day != '') { |
| 921 | 921 | if ($globalDBdriver == 'mysql') { |
| 922 | 922 | $query .= " AND DAY(marine_output.date) = :day"; |
| 923 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 923 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 924 | 924 | } else { |
| 925 | 925 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 926 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 926 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 927 | 927 | } |
| 928 | 928 | } |
| 929 | 929 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | $callsign_array = array(); |
| 936 | 936 | $temp_array = array(); |
| 937 | 937 | |
| 938 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 938 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 939 | 939 | { |
| 940 | 940 | $temp_array['callsign_icao'] = $row['ident']; |
| 941 | 941 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -987,7 +987,7 @@ discard block |
||
| 987 | 987 | $date_array = array(); |
| 988 | 988 | $temp_array = array(); |
| 989 | 989 | |
| 990 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 990 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 991 | 991 | { |
| 992 | 992 | $temp_array['date_name'] = $row['date_name']; |
| 993 | 993 | $temp_array['date_count'] = $row['date_count']; |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | $datetime = new DateTime(); |
| 1014 | 1014 | $offset = $datetime->format('P'); |
| 1015 | 1015 | } else $offset = '+00:00'; |
| 1016 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1016 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1017 | 1017 | if ($globalDBdriver == 'mysql') { |
| 1018 | 1018 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1019 | 1019 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1034,7 +1034,7 @@ discard block |
||
| 1034 | 1034 | $date_array = array(); |
| 1035 | 1035 | $temp_array = array(); |
| 1036 | 1036 | |
| 1037 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1037 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1038 | 1038 | { |
| 1039 | 1039 | $temp_array['date_name'] = $row['date_name']; |
| 1040 | 1040 | $temp_array['date_count'] = $row['date_count']; |
@@ -1059,7 +1059,7 @@ discard block |
||
| 1059 | 1059 | $datetime = new DateTime(); |
| 1060 | 1060 | $offset = $datetime->format('P'); |
| 1061 | 1061 | } else $offset = '+00:00'; |
| 1062 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1062 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1063 | 1063 | if ($globalDBdriver == 'mysql') { |
| 1064 | 1064 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 1065 | 1065 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1080,7 +1080,7 @@ discard block |
||
| 1080 | 1080 | $date_array = array(); |
| 1081 | 1081 | $temp_array = array(); |
| 1082 | 1082 | |
| 1083 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1083 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1084 | 1084 | { |
| 1085 | 1085 | $temp_array['date_name'] = $row['date_name']; |
| 1086 | 1086 | $temp_array['date_count'] = $row['date_count']; |
@@ -1127,7 +1127,7 @@ discard block |
||
| 1127 | 1127 | $date_array = array(); |
| 1128 | 1128 | $temp_array = array(); |
| 1129 | 1129 | |
| 1130 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1130 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1131 | 1131 | { |
| 1132 | 1132 | $temp_array['month_name'] = $row['month_name']; |
| 1133 | 1133 | $temp_array['year_name'] = $row['year_name']; |
@@ -1156,7 +1156,7 @@ discard block |
||
| 1156 | 1156 | $datetime = new DateTime(); |
| 1157 | 1157 | $offset = $datetime->format('P'); |
| 1158 | 1158 | } else $offset = '+00:00'; |
| 1159 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1159 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1160 | 1160 | if ($globalDBdriver == 'mysql') { |
| 1161 | 1161 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 1162 | 1162 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | $date_array = array(); |
| 1178 | 1178 | $temp_array = array(); |
| 1179 | 1179 | |
| 1180 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1180 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1181 | 1181 | { |
| 1182 | 1182 | $temp_array['year_name'] = $row['year_name']; |
| 1183 | 1183 | $temp_array['month_name'] = $row['month_name']; |
@@ -1197,7 +1197,7 @@ discard block |
||
| 1197 | 1197 | * @return Array the hour list |
| 1198 | 1198 | * |
| 1199 | 1199 | */ |
| 1200 | - public function countAllHours($orderby,$filters = array()) |
|
| 1200 | + public function countAllHours($orderby, $filters = array()) |
|
| 1201 | 1201 | { |
| 1202 | 1202 | global $globalTimezone, $globalDBdriver; |
| 1203 | 1203 | if ($globalTimezone != '') { |
@@ -1245,7 +1245,7 @@ discard block |
||
| 1245 | 1245 | $hour_array = array(); |
| 1246 | 1246 | $temp_array = array(); |
| 1247 | 1247 | |
| 1248 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1248 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1249 | 1249 | { |
| 1250 | 1250 | $temp_array['hour_name'] = $row['hour_name']; |
| 1251 | 1251 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1267,8 +1267,8 @@ discard block |
||
| 1267 | 1267 | public function countAllHoursByDate($date, $filters = array()) |
| 1268 | 1268 | { |
| 1269 | 1269 | global $globalTimezone, $globalDBdriver; |
| 1270 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1271 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 1270 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1271 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 1272 | 1272 | if ($globalTimezone != '') { |
| 1273 | 1273 | date_default_timezone_set($globalTimezone); |
| 1274 | 1274 | $datetime = new DateTime($date); |
@@ -1276,12 +1276,12 @@ discard block |
||
| 1276 | 1276 | } else $offset = '+00:00'; |
| 1277 | 1277 | |
| 1278 | 1278 | if ($globalDBdriver == 'mysql') { |
| 1279 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1279 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1280 | 1280 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
| 1281 | 1281 | GROUP BY hour_name |
| 1282 | 1282 | ORDER BY hour_name ASC"; |
| 1283 | 1283 | } else { |
| 1284 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1284 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1285 | 1285 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 1286 | 1286 | GROUP BY hour_name |
| 1287 | 1287 | ORDER BY hour_name ASC"; |
@@ -1293,7 +1293,7 @@ discard block |
||
| 1293 | 1293 | $hour_array = array(); |
| 1294 | 1294 | $temp_array = array(); |
| 1295 | 1295 | |
| 1296 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1296 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1297 | 1297 | { |
| 1298 | 1298 | $temp_array['hour_name'] = $row['hour_name']; |
| 1299 | 1299 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1315,8 +1315,8 @@ discard block |
||
| 1315 | 1315 | public function countAllHoursByIdent($ident, $filters = array()) |
| 1316 | 1316 | { |
| 1317 | 1317 | global $globalTimezone, $globalDBdriver; |
| 1318 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1319 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1318 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1319 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1320 | 1320 | if ($globalTimezone != '') { |
| 1321 | 1321 | date_default_timezone_set($globalTimezone); |
| 1322 | 1322 | $datetime = new DateTime(); |
@@ -1324,12 +1324,12 @@ discard block |
||
| 1324 | 1324 | } else $offset = '+00:00'; |
| 1325 | 1325 | |
| 1326 | 1326 | if ($globalDBdriver == 'mysql') { |
| 1327 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1327 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1328 | 1328 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1329 | 1329 | GROUP BY hour_name |
| 1330 | 1330 | ORDER BY hour_name ASC"; |
| 1331 | 1331 | } else { |
| 1332 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1332 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1333 | 1333 | FROM marine_output".$filter_query." marine_output.ident = :ident |
| 1334 | 1334 | GROUP BY hour_name |
| 1335 | 1335 | ORDER BY hour_name ASC"; |
@@ -1337,12 +1337,12 @@ discard block |
||
| 1337 | 1337 | |
| 1338 | 1338 | |
| 1339 | 1339 | $sth = $this->db->prepare($query); |
| 1340 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 1340 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 1341 | 1341 | |
| 1342 | 1342 | $hour_array = array(); |
| 1343 | 1343 | $temp_array = array(); |
| 1344 | 1344 | |
| 1345 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1345 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1346 | 1346 | { |
| 1347 | 1347 | $temp_array['hour_name'] = $row['hour_name']; |
| 1348 | 1348 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1361,33 +1361,33 @@ discard block |
||
| 1361 | 1361 | * @return Integer the number of vessels |
| 1362 | 1362 | * |
| 1363 | 1363 | */ |
| 1364 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
| 1364 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
| 1365 | 1365 | { |
| 1366 | 1366 | global $globalDBdriver; |
| 1367 | 1367 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
| 1368 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1368 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
| 1369 | 1369 | $query_values = array(); |
| 1370 | 1370 | $query = ''; |
| 1371 | 1371 | if ($year != '') { |
| 1372 | 1372 | if ($globalDBdriver == 'mysql') { |
| 1373 | 1373 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1374 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1374 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1375 | 1375 | } else { |
| 1376 | 1376 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1377 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1377 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1378 | 1378 | } |
| 1379 | 1379 | } |
| 1380 | 1380 | if ($month != '') { |
| 1381 | 1381 | if ($globalDBdriver == 'mysql') { |
| 1382 | 1382 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1383 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1383 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1384 | 1384 | } else { |
| 1385 | 1385 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1386 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1386 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1387 | 1387 | } |
| 1388 | 1388 | } |
| 1389 | 1389 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1390 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1390 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1391 | 1391 | |
| 1392 | 1392 | $sth = $this->db->prepare($queryi); |
| 1393 | 1393 | $sth->execute($query_values); |
@@ -1400,32 +1400,32 @@ discard block |
||
| 1400 | 1400 | * @return Integer the number of vessels |
| 1401 | 1401 | * |
| 1402 | 1402 | */ |
| 1403 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
| 1403 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
| 1404 | 1404 | { |
| 1405 | 1405 | global $globalDBdriver; |
| 1406 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1406 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
| 1407 | 1407 | $query_values = array(); |
| 1408 | 1408 | $query = ''; |
| 1409 | 1409 | if ($year != '') { |
| 1410 | 1410 | if ($globalDBdriver == 'mysql') { |
| 1411 | 1411 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1412 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1412 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1413 | 1413 | } else { |
| 1414 | 1414 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1415 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1415 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1416 | 1416 | } |
| 1417 | 1417 | } |
| 1418 | 1418 | if ($month != '') { |
| 1419 | 1419 | if ($globalDBdriver == 'mysql') { |
| 1420 | 1420 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1421 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1421 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1422 | 1422 | } else { |
| 1423 | 1423 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1424 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1424 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1425 | 1425 | } |
| 1426 | 1426 | } |
| 1427 | 1427 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 1428 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 1428 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 1429 | 1429 | |
| 1430 | 1430 | $sth = $this->db->prepare($queryi); |
| 1431 | 1431 | $sth->execute($query_values); |
@@ -1442,7 +1442,7 @@ discard block |
||
| 1442 | 1442 | public function countAllHoursFromToday($filters = array()) |
| 1443 | 1443 | { |
| 1444 | 1444 | global $globalTimezone, $globalDBdriver; |
| 1445 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1445 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1446 | 1446 | if ($globalTimezone != '') { |
| 1447 | 1447 | date_default_timezone_set($globalTimezone); |
| 1448 | 1448 | $datetime = new DateTime(); |
@@ -1450,12 +1450,12 @@ discard block |
||
| 1450 | 1450 | } else $offset = '+00:00'; |
| 1451 | 1451 | |
| 1452 | 1452 | if ($globalDBdriver == 'mysql') { |
| 1453 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1453 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 1454 | 1454 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
| 1455 | 1455 | GROUP BY hour_name |
| 1456 | 1456 | ORDER BY hour_name ASC"; |
| 1457 | 1457 | } else { |
| 1458 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1458 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 1459 | 1459 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 1460 | 1460 | GROUP BY hour_name |
| 1461 | 1461 | ORDER BY hour_name ASC"; |
@@ -1467,7 +1467,7 @@ discard block |
||
| 1467 | 1467 | $hour_array = array(); |
| 1468 | 1468 | $temp_array = array(); |
| 1469 | 1469 | |
| 1470 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1470 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1471 | 1471 | { |
| 1472 | 1472 | $temp_array['hour_name'] = $row['hour_name']; |
| 1473 | 1473 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1486,9 +1486,9 @@ discard block |
||
| 1486 | 1486 | */ |
| 1487 | 1487 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
| 1488 | 1488 | { |
| 1489 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 1489 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 1490 | 1490 | |
| 1491 | - $query = "SELECT marine_output.marine_id |
|
| 1491 | + $query = "SELECT marine_output.marine_id |
|
| 1492 | 1492 | FROM marine_output |
| 1493 | 1493 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
| 1494 | 1494 | |
@@ -1496,7 +1496,7 @@ discard block |
||
| 1496 | 1496 | $sth = $this->db->prepare($query); |
| 1497 | 1497 | $sth->execute(); |
| 1498 | 1498 | |
| 1499 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1499 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1500 | 1500 | { |
| 1501 | 1501 | return $row['marine_id']; |
| 1502 | 1502 | } |
@@ -1521,23 +1521,23 @@ discard block |
||
| 1521 | 1521 | } |
| 1522 | 1522 | |
| 1523 | 1523 | $current_date = date("Y-m-d H:i:s"); |
| 1524 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 1524 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 1525 | 1525 | |
| 1526 | 1526 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 1527 | 1527 | |
| 1528 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 1528 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 1529 | 1529 | $years = $time_array['years']; |
| 1530 | 1530 | |
| 1531 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 1531 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 1532 | 1532 | $months = $time_array['months']; |
| 1533 | 1533 | |
| 1534 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 1534 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 1535 | 1535 | $days = $time_array['days']; |
| 1536 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 1536 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 1537 | 1537 | $hours = $time_array['hours']; |
| 1538 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 1538 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 1539 | 1539 | $minutes = $time_array['minutes']; |
| 1540 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1540 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 1541 | 1541 | |
| 1542 | 1542 | return $time_array; |
| 1543 | 1543 | } |
@@ -1560,63 +1560,63 @@ discard block |
||
| 1560 | 1560 | $temp_array['direction_degree'] = $direction; |
| 1561 | 1561 | $temp_array['direction_shortname'] = "N"; |
| 1562 | 1562 | $temp_array['direction_fullname'] = "North"; |
| 1563 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 1563 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 1564 | 1564 | $temp_array['direction_degree'] = $direction; |
| 1565 | 1565 | $temp_array['direction_shortname'] = "NNE"; |
| 1566 | 1566 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 1567 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 1567 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 1568 | 1568 | $temp_array['direction_degree'] = $direction; |
| 1569 | 1569 | $temp_array['direction_shortname'] = "NE"; |
| 1570 | 1570 | $temp_array['direction_fullname'] = "Northeast"; |
| 1571 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 1571 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 1572 | 1572 | $temp_array['direction_degree'] = $direction; |
| 1573 | 1573 | $temp_array['direction_shortname'] = "ENE"; |
| 1574 | 1574 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 1575 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 1575 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 1576 | 1576 | $temp_array['direction_degree'] = $direction; |
| 1577 | 1577 | $temp_array['direction_shortname'] = "E"; |
| 1578 | 1578 | $temp_array['direction_fullname'] = "East"; |
| 1579 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 1579 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 1580 | 1580 | $temp_array['direction_degree'] = $direction; |
| 1581 | 1581 | $temp_array['direction_shortname'] = "ESE"; |
| 1582 | 1582 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 1583 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 1583 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 1584 | 1584 | $temp_array['direction_degree'] = $direction; |
| 1585 | 1585 | $temp_array['direction_shortname'] = "SE"; |
| 1586 | 1586 | $temp_array['direction_fullname'] = "Southeast"; |
| 1587 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 1587 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 1588 | 1588 | $temp_array['direction_degree'] = $direction; |
| 1589 | 1589 | $temp_array['direction_shortname'] = "SSE"; |
| 1590 | 1590 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 1591 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 1591 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 1592 | 1592 | $temp_array['direction_degree'] = $direction; |
| 1593 | 1593 | $temp_array['direction_shortname'] = "S"; |
| 1594 | 1594 | $temp_array['direction_fullname'] = "South"; |
| 1595 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 1595 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 1596 | 1596 | $temp_array['direction_degree'] = $direction; |
| 1597 | 1597 | $temp_array['direction_shortname'] = "SSW"; |
| 1598 | 1598 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 1599 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 1599 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 1600 | 1600 | $temp_array['direction_degree'] = $direction; |
| 1601 | 1601 | $temp_array['direction_shortname'] = "SW"; |
| 1602 | 1602 | $temp_array['direction_fullname'] = "Southwest"; |
| 1603 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 1603 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 1604 | 1604 | $temp_array['direction_degree'] = $direction; |
| 1605 | 1605 | $temp_array['direction_shortname'] = "WSW"; |
| 1606 | 1606 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 1607 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 1607 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 1608 | 1608 | $temp_array['direction_degree'] = $direction; |
| 1609 | 1609 | $temp_array['direction_shortname'] = "W"; |
| 1610 | 1610 | $temp_array['direction_fullname'] = "West"; |
| 1611 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 1611 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 1612 | 1612 | $temp_array['direction_degree'] = $direction; |
| 1613 | 1613 | $temp_array['direction_shortname'] = "WNW"; |
| 1614 | 1614 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 1615 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 1615 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 1616 | 1616 | $temp_array['direction_degree'] = $direction; |
| 1617 | 1617 | $temp_array['direction_shortname'] = "NW"; |
| 1618 | 1618 | $temp_array['direction_fullname'] = "Northwest"; |
| 1619 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 1619 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 1620 | 1620 | $temp_array['direction_degree'] = $direction; |
| 1621 | 1621 | $temp_array['direction_shortname'] = "NNW"; |
| 1622 | 1622 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1633,11 +1633,11 @@ discard block |
||
| 1633 | 1633 | * @param Float $longitude longitute of the flight |
| 1634 | 1634 | * @return String the countrie |
| 1635 | 1635 | */ |
| 1636 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 1636 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 1637 | 1637 | { |
| 1638 | 1638 | global $globalDBdriver, $globalDebug; |
| 1639 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1640 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1639 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1640 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1641 | 1641 | |
| 1642 | 1642 | $Connection = new Connection($this->db); |
| 1643 | 1643 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1677,7 +1677,7 @@ discard block |
||
| 1677 | 1677 | public function getCountryFromISO2($iso2) |
| 1678 | 1678 | { |
| 1679 | 1679 | global $globalDBdriver, $globalDebug; |
| 1680 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 1680 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 1681 | 1681 | |
| 1682 | 1682 | $Connection = new Connection($this->db); |
| 1683 | 1683 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1725,7 +1725,7 @@ discard block |
||
| 1725 | 1725 | |
| 1726 | 1726 | $bitly_data = json_decode($bitly_data); |
| 1727 | 1727 | $bitly_url = ''; |
| 1728 | - if ($bitly_data->status_txt = "OK"){ |
|
| 1728 | + if ($bitly_data->status_txt = "OK") { |
|
| 1729 | 1729 | $bitly_url = $bitly_data->data->url; |
| 1730 | 1730 | } |
| 1731 | 1731 | |
@@ -1739,11 +1739,11 @@ discard block |
||
| 1739 | 1739 | * @return Array the vessel type list |
| 1740 | 1740 | * |
| 1741 | 1741 | */ |
| 1742 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 1742 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 1743 | 1743 | { |
| 1744 | 1744 | global $globalDBdriver; |
| 1745 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1746 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
| 1745 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1746 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
| 1747 | 1747 | FROM marine_output ".$filter_query." marine_output.type <> ''"; |
| 1748 | 1748 | if ($olderthanmonths > 0) { |
| 1749 | 1749 | if ($globalDBdriver == 'mysql') { |
@@ -1763,28 +1763,28 @@ discard block |
||
| 1763 | 1763 | if ($year != '') { |
| 1764 | 1764 | if ($globalDBdriver == 'mysql') { |
| 1765 | 1765 | $query .= " AND YEAR(marine_output.date) = :year"; |
| 1766 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1766 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1767 | 1767 | } else { |
| 1768 | 1768 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
| 1769 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 1769 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 1770 | 1770 | } |
| 1771 | 1771 | } |
| 1772 | 1772 | if ($month != '') { |
| 1773 | 1773 | if ($globalDBdriver == 'mysql') { |
| 1774 | 1774 | $query .= " AND MONTH(marine_output.date) = :month"; |
| 1775 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1775 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1776 | 1776 | } else { |
| 1777 | 1777 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
| 1778 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 1778 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 1779 | 1779 | } |
| 1780 | 1780 | } |
| 1781 | 1781 | if ($day != '') { |
| 1782 | 1782 | if ($globalDBdriver == 'mysql') { |
| 1783 | 1783 | $query .= " AND DAY(marine_output.date) = :day"; |
| 1784 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1784 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1785 | 1785 | } else { |
| 1786 | 1786 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
| 1787 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 1787 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 1788 | 1788 | } |
| 1789 | 1789 | } |
| 1790 | 1790 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
@@ -1793,7 +1793,7 @@ discard block |
||
| 1793 | 1793 | $sth->execute($query_values); |
| 1794 | 1794 | $marine_array = array(); |
| 1795 | 1795 | $temp_array = array(); |
| 1796 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1796 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1797 | 1797 | { |
| 1798 | 1798 | $temp_array['marine_type'] = $row['marine_type']; |
| 1799 | 1799 | $temp_array['marine_type_count'] = $row['marine_type_count']; |
@@ -1804,7 +1804,7 @@ discard block |
||
| 1804 | 1804 | |
| 1805 | 1805 | public function getOrderBy() |
| 1806 | 1806 | { |
| 1807 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
| 1807 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
| 1808 | 1808 | |
| 1809 | 1809 | return $orderby; |
| 1810 | 1810 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * Get SQL query part for filter used |
| 16 | 16 | * @param Array $filter the filter |
| 17 | - * @return Array the SQL part |
|
| 17 | + * @return string the SQL part |
|
| 18 | 18 | */ |
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -794,10 +794,6 @@ discard block |
||
| 794 | 794 | * |
| 795 | 795 | * @param String $fammarine_id the ID from flightaware |
| 796 | 796 | * @param String $ident the flight ident |
| 797 | - * @param String $aircraft_icao the aircraft type |
|
| 798 | - * @param String $departure_airport_icao the departure airport |
|
| 799 | - * @param String $arrival_airport_icao the arrival airport |
|
| 800 | - * @return String success or false |
|
| 801 | 797 | * |
| 802 | 798 | */ |
| 803 | 799 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Get SQL query part for filter used |
|
| 16 | - * @param Array $filter the filter |
|
| 17 | - * @return Array the SQL part |
|
| 18 | - */ |
|
| 15 | + * Get SQL query part for filter used |
|
| 16 | + * @param Array $filter the filter |
|
| 17 | + * @return Array the SQL part |
|
| 18 | + */ |
|
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | - * Gets all the spotter information based on the latest data entry |
|
| 90 | - * |
|
| 91 | - * @return Array the spotter information |
|
| 92 | - * |
|
| 93 | - */ |
|
| 89 | + * Gets all the spotter information based on the latest data entry |
|
| 90 | + * |
|
| 91 | + * @return Array the spotter information |
|
| 92 | + * |
|
| 93 | + */ |
|
| 94 | 94 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
| 95 | 95 | { |
| 96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | - * Gets Minimal Live Spotter data |
|
| 136 | - * |
|
| 137 | - * @return Array the spotter information |
|
| 138 | - * |
|
| 139 | - */ |
|
| 135 | + * Gets Minimal Live Spotter data |
|
| 136 | + * |
|
| 137 | + * @return Array the spotter information |
|
| 138 | + * |
|
| 139 | + */ |
|
| 140 | 140 | public function getMinLiveMarineData($filter = array()) |
| 141 | 141 | { |
| 142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -166,11 +166,11 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
| 169 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 170 | - * |
|
| 171 | - * @return Array the spotter information |
|
| 172 | - * |
|
| 173 | - */ |
|
| 169 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 170 | + * |
|
| 171 | + * @return Array the spotter information |
|
| 172 | + * |
|
| 173 | + */ |
|
| 174 | 174 | public function getMinLastLiveMarineData($filter = array()) |
| 175 | 175 | { |
| 176 | 176 | global $globalDBdriver, $globalLiveInterval; |
@@ -183,13 +183,13 @@ discard block |
||
| 183 | 183 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 186 | - } else { |
|
| 186 | + } else { |
|
| 187 | 187 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - try { |
|
| 192 | + try { |
|
| 193 | 193 | $sth = $this->db->prepare($query); |
| 194 | 194 | $sth->execute(); |
| 195 | 195 | } catch(PDOException $e) { |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | - * Gets number of latest data entry |
|
| 205 | - * |
|
| 206 | - * @return String number of entry |
|
| 207 | - * |
|
| 208 | - */ |
|
| 204 | + * Gets number of latest data entry |
|
| 205 | + * |
|
| 206 | + * @return String number of entry |
|
| 207 | + * |
|
| 208 | + */ |
|
| 209 | 209 | public function getLiveMarineCount($filter = array()) |
| 210 | 210 | { |
| 211 | 211 | global $globalDBdriver, $globalLiveInterval; |
@@ -230,11 +230,11 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
| 233 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 234 | - * |
|
| 235 | - * @return Array the spotter information |
|
| 236 | - * |
|
| 237 | - */ |
|
| 233 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 234 | + * |
|
| 235 | + * @return Array the spotter information |
|
| 236 | + * |
|
| 237 | + */ |
|
| 238 | 238 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
| 239 | 239 | { |
| 240 | 240 | global $globalDBdriver, $globalLiveInterval; |
@@ -258,11 +258,11 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
| 261 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 262 | - * |
|
| 263 | - * @return Array the spotter information |
|
| 264 | - * |
|
| 265 | - */ |
|
| 261 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 262 | + * |
|
| 263 | + * @return Array the spotter information |
|
| 264 | + * |
|
| 265 | + */ |
|
| 266 | 266 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
| 267 | 267 | { |
| 268 | 268 | global $globalDBdriver, $globalLiveInterval; |
@@ -290,11 +290,11 @@ discard block |
||
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
| 293 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 294 | - * |
|
| 295 | - * @return Array the spotter information |
|
| 296 | - * |
|
| 297 | - */ |
|
| 293 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 294 | + * |
|
| 295 | + * @return Array the spotter information |
|
| 296 | + * |
|
| 297 | + */ |
|
| 298 | 298 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
| 299 | 299 | { |
| 300 | 300 | $Marine = new Marine($this->db); |
@@ -307,134 +307,134 @@ discard block |
||
| 307 | 307 | if ($lng != '') |
| 308 | 308 | { |
| 309 | 309 | if (!is_numeric($lng)) |
| 310 | - { |
|
| 311 | - return false; |
|
| 312 | - } |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - if ($radius != '') |
|
| 316 | - { |
|
| 317 | - if (!is_numeric($radius)) |
|
| 318 | - { |
|
| 319 | - return false; |
|
| 320 | - } |
|
| 321 | - } |
|
| 310 | + { |
|
| 311 | + return false; |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + if ($radius != '') |
|
| 316 | + { |
|
| 317 | + if (!is_numeric($radius)) |
|
| 318 | + { |
|
| 319 | + return false; |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | 322 | $additional_query = ''; |
| 323 | 323 | if ($interval != '') |
| 324 | - { |
|
| 325 | - if (!is_string($interval)) |
|
| 326 | - { |
|
| 327 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 328 | - return false; |
|
| 329 | - } else { |
|
| 330 | - if ($interval == '1m') |
|
| 331 | - { |
|
| 332 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 333 | - } else if ($interval == '15m'){ |
|
| 334 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
| 335 | - } |
|
| 336 | - } |
|
| 337 | - } else { |
|
| 338 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 324 | + { |
|
| 325 | + if (!is_string($interval)) |
|
| 326 | + { |
|
| 327 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 328 | + return false; |
|
| 329 | + } else { |
|
| 330 | + if ($interval == '1m') |
|
| 331 | + { |
|
| 332 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 333 | + } else if ($interval == '15m'){ |
|
| 334 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | + } else { |
|
| 338 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 342 | 342 | WHERE marine_live.latitude <> '' |
| 343 | 343 | AND marine_live.longitude <> '' |
| 344 | 344 | ".$additional_query." |
| 345 | 345 | HAVING distance < :radius |
| 346 | 346 | ORDER BY distance"; |
| 347 | 347 | |
| 348 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 348 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 349 | 349 | |
| 350 | - return $spotter_array; |
|
| 351 | - } |
|
| 350 | + return $spotter_array; |
|
| 351 | + } |
|
| 352 | 352 | |
| 353 | 353 | |
| 354 | - /** |
|
| 355 | - * Gets all the spotter information based on a particular callsign |
|
| 356 | - * |
|
| 357 | - * @return Array the spotter information |
|
| 358 | - * |
|
| 359 | - */ |
|
| 354 | + /** |
|
| 355 | + * Gets all the spotter information based on a particular callsign |
|
| 356 | + * |
|
| 357 | + * @return Array the spotter information |
|
| 358 | + * |
|
| 359 | + */ |
|
| 360 | 360 | public function getLastLiveMarineDataByIdent($ident) |
| 361 | 361 | { |
| 362 | 362 | $Marine = new Marine($this->db); |
| 363 | 363 | date_default_timezone_set('UTC'); |
| 364 | 364 | |
| 365 | 365 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 366 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 366 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 367 | 367 | |
| 368 | 368 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 369 | 369 | |
| 370 | 370 | return $spotter_array; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - /** |
|
| 374 | - * Gets all the spotter information based on a particular callsign |
|
| 375 | - * |
|
| 376 | - * @return Array the spotter information |
|
| 377 | - * |
|
| 378 | - */ |
|
| 373 | + /** |
|
| 374 | + * Gets all the spotter information based on a particular callsign |
|
| 375 | + * |
|
| 376 | + * @return Array the spotter information |
|
| 377 | + * |
|
| 378 | + */ |
|
| 379 | 379 | public function getDateLiveMarineDataByIdent($ident,$date) |
| 380 | 380 | { |
| 381 | 381 | $Marine = new Marine($this->db); |
| 382 | 382 | date_default_timezone_set('UTC'); |
| 383 | 383 | |
| 384 | 384 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 385 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 385 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 386 | 386 | |
| 387 | - $date = date('c',$date); |
|
| 387 | + $date = date('c',$date); |
|
| 388 | 388 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 389 | 389 | |
| 390 | 390 | return $spotter_array; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - /** |
|
| 394 | - * Gets last spotter information based on a particular callsign |
|
| 395 | - * |
|
| 396 | - * @return Array the spotter information |
|
| 397 | - * |
|
| 398 | - */ |
|
| 393 | + /** |
|
| 394 | + * Gets last spotter information based on a particular callsign |
|
| 395 | + * |
|
| 396 | + * @return Array the spotter information |
|
| 397 | + * |
|
| 398 | + */ |
|
| 399 | 399 | public function getLastLiveMarineDataById($id) |
| 400 | 400 | { |
| 401 | 401 | $Marine = new Marine($this->db); |
| 402 | 402 | date_default_timezone_set('UTC'); |
| 403 | 403 | |
| 404 | 404 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 405 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 405 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 406 | 406 | |
| 407 | 407 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
| 408 | 408 | |
| 409 | 409 | return $spotter_array; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - /** |
|
| 413 | - * Gets last spotter information based on a particular callsign |
|
| 414 | - * |
|
| 415 | - * @return Array the spotter information |
|
| 416 | - * |
|
| 417 | - */ |
|
| 412 | + /** |
|
| 413 | + * Gets last spotter information based on a particular callsign |
|
| 414 | + * |
|
| 415 | + * @return Array the spotter information |
|
| 416 | + * |
|
| 417 | + */ |
|
| 418 | 418 | public function getDateLiveMarineDataById($id,$date) |
| 419 | 419 | { |
| 420 | 420 | $Marine = new Marine($this->db); |
| 421 | 421 | date_default_timezone_set('UTC'); |
| 422 | 422 | |
| 423 | 423 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 424 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 425 | - $date = date('c',$date); |
|
| 424 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 425 | + $date = date('c',$date); |
|
| 426 | 426 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
| 427 | 427 | |
| 428 | 428 | return $spotter_array; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | |
| 432 | - /** |
|
| 433 | - * Gets all the spotter information based on a particular id |
|
| 434 | - * |
|
| 435 | - * @return Array the spotter information |
|
| 436 | - * |
|
| 437 | - */ |
|
| 432 | + /** |
|
| 433 | + * Gets all the spotter information based on a particular id |
|
| 434 | + * |
|
| 435 | + * @return Array the spotter information |
|
| 436 | + * |
|
| 437 | + */ |
|
| 438 | 438 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
| 439 | 439 | { |
| 440 | 440 | global $globalDBdriver, $globalLiveInterval; |
@@ -462,18 +462,18 @@ discard block |
||
| 462 | 462 | return $spotter_array; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - /** |
|
| 466 | - * Gets all the spotter information based on a particular ident |
|
| 467 | - * |
|
| 468 | - * @return Array the spotter information |
|
| 469 | - * |
|
| 470 | - */ |
|
| 465 | + /** |
|
| 466 | + * Gets all the spotter information based on a particular ident |
|
| 467 | + * |
|
| 468 | + * @return Array the spotter information |
|
| 469 | + * |
|
| 470 | + */ |
|
| 471 | 471 | public function getAllLiveMarineDataByIdent($ident) |
| 472 | 472 | { |
| 473 | 473 | date_default_timezone_set('UTC'); |
| 474 | 474 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 475 | 475 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
| 476 | - try { |
|
| 476 | + try { |
|
| 477 | 477 | |
| 478 | 478 | $sth = $this->db->prepare($query); |
| 479 | 479 | $sth->execute(array(':ident' => $ident)); |
@@ -487,23 +487,23 @@ discard block |
||
| 487 | 487 | |
| 488 | 488 | |
| 489 | 489 | /** |
| 490 | - * Deletes all info in the table |
|
| 491 | - * |
|
| 492 | - * @return String success or false |
|
| 493 | - * |
|
| 494 | - */ |
|
| 490 | + * Deletes all info in the table |
|
| 491 | + * |
|
| 492 | + * @return String success or false |
|
| 493 | + * |
|
| 494 | + */ |
|
| 495 | 495 | public function deleteLiveMarineData() |
| 496 | 496 | { |
| 497 | 497 | global $globalDBdriver; |
| 498 | 498 | if ($globalDBdriver == 'mysql') { |
| 499 | 499 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
| 500 | 500 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
| 501 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
| 501 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
| 502 | 502 | } else { |
| 503 | 503 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - try { |
|
| 506 | + try { |
|
| 507 | 507 | |
| 508 | 508 | $sth = $this->db->prepare($query); |
| 509 | 509 | $sth->execute(); |
@@ -515,18 +515,18 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | /** |
| 518 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 519 | - * |
|
| 520 | - * @return String success or false |
|
| 521 | - * |
|
| 522 | - */ |
|
| 518 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 519 | + * |
|
| 520 | + * @return String success or false |
|
| 521 | + * |
|
| 522 | + */ |
|
| 523 | 523 | public function deleteLiveMarineDataNotUpdated() |
| 524 | 524 | { |
| 525 | 525 | global $globalDBdriver, $globalDebug; |
| 526 | 526 | if ($globalDBdriver == 'mysql') { |
| 527 | 527 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
| 528 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 529 | - try { |
|
| 528 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
| 529 | + try { |
|
| 530 | 530 | |
| 531 | 531 | $sth = $this->db->prepare($query); |
| 532 | 532 | $sth->execute(); |
@@ -534,8 +534,8 @@ discard block |
||
| 534 | 534 | return "error"; |
| 535 | 535 | } |
| 536 | 536 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
| 537 | - $i = 0; |
|
| 538 | - $j =0; |
|
| 537 | + $i = 0; |
|
| 538 | + $j =0; |
|
| 539 | 539 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 540 | 540 | foreach($all as $row) |
| 541 | 541 | { |
@@ -543,20 +543,20 @@ discard block |
||
| 543 | 543 | $j++; |
| 544 | 544 | if ($j == 30) { |
| 545 | 545 | if ($globalDebug) echo "."; |
| 546 | - try { |
|
| 546 | + try { |
|
| 547 | 547 | |
| 548 | 548 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 549 | 549 | $sth->execute(); |
| 550 | 550 | } catch(PDOException $e) { |
| 551 | 551 | return "error"; |
| 552 | 552 | } |
| 553 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
| 554 | - $j = 0; |
|
| 553 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
| 554 | + $j = 0; |
|
| 555 | 555 | } |
| 556 | 556 | $query_delete .= "'".$row['fammarine_id']."',"; |
| 557 | 557 | } |
| 558 | 558 | if ($i > 0) { |
| 559 | - try { |
|
| 559 | + try { |
|
| 560 | 560 | |
| 561 | 561 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 562 | 562 | $sth->execute(); |
@@ -567,9 +567,9 @@ discard block |
||
| 567 | 567 | return "success"; |
| 568 | 568 | } elseif ($globalDBdriver == 'pgsql') { |
| 569 | 569 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
| 570 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 571 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 572 | - try { |
|
| 570 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 571 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
| 572 | + try { |
|
| 573 | 573 | |
| 574 | 574 | $sth = $this->db->prepare($query); |
| 575 | 575 | $sth->execute(); |
@@ -613,17 +613,17 @@ discard block |
||
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
| 616 | - * Deletes all info in the table for an ident |
|
| 617 | - * |
|
| 618 | - * @return String success or false |
|
| 619 | - * |
|
| 620 | - */ |
|
| 616 | + * Deletes all info in the table for an ident |
|
| 617 | + * |
|
| 618 | + * @return String success or false |
|
| 619 | + * |
|
| 620 | + */ |
|
| 621 | 621 | public function deleteLiveMarineDataByIdent($ident) |
| 622 | 622 | { |
| 623 | 623 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 624 | 624 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
| 625 | 625 | |
| 626 | - try { |
|
| 626 | + try { |
|
| 627 | 627 | |
| 628 | 628 | $sth = $this->db->prepare($query); |
| 629 | 629 | $sth->execute(array(':ident' => $ident)); |
@@ -635,17 +635,17 @@ discard block |
||
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | /** |
| 638 | - * Deletes all info in the table for an id |
|
| 639 | - * |
|
| 640 | - * @return String success or false |
|
| 641 | - * |
|
| 642 | - */ |
|
| 638 | + * Deletes all info in the table for an id |
|
| 639 | + * |
|
| 640 | + * @return String success or false |
|
| 641 | + * |
|
| 642 | + */ |
|
| 643 | 643 | public function deleteLiveMarineDataById($id) |
| 644 | 644 | { |
| 645 | 645 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 646 | 646 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
| 647 | 647 | |
| 648 | - try { |
|
| 648 | + try { |
|
| 649 | 649 | |
| 650 | 650 | $sth = $this->db->prepare($query); |
| 651 | 651 | $sth->execute(array(':id' => $id)); |
@@ -658,11 +658,11 @@ discard block |
||
| 658 | 658 | |
| 659 | 659 | |
| 660 | 660 | /** |
| 661 | - * Gets the aircraft ident within the last hour |
|
| 662 | - * |
|
| 663 | - * @return String the ident |
|
| 664 | - * |
|
| 665 | - */ |
|
| 661 | + * Gets the aircraft ident within the last hour |
|
| 662 | + * |
|
| 663 | + * @return String the ident |
|
| 664 | + * |
|
| 665 | + */ |
|
| 666 | 666 | public function getIdentFromLastHour($ident) |
| 667 | 667 | { |
| 668 | 668 | global $globalDBdriver, $globalTimezone; |
@@ -688,14 +688,14 @@ discard block |
||
| 688 | 688 | $ident_result = $row['ident']; |
| 689 | 689 | } |
| 690 | 690 | return $ident_result; |
| 691 | - } |
|
| 691 | + } |
|
| 692 | 692 | |
| 693 | 693 | /** |
| 694 | - * Check recent aircraft |
|
| 695 | - * |
|
| 696 | - * @return String the ident |
|
| 697 | - * |
|
| 698 | - */ |
|
| 694 | + * Check recent aircraft |
|
| 695 | + * |
|
| 696 | + * @return String the ident |
|
| 697 | + * |
|
| 698 | + */ |
|
| 699 | 699 | public function checkIdentRecent($ident) |
| 700 | 700 | { |
| 701 | 701 | global $globalDBdriver, $globalTimezone; |
@@ -721,14 +721,14 @@ discard block |
||
| 721 | 721 | $ident_result = $row['fammarine_id']; |
| 722 | 722 | } |
| 723 | 723 | return $ident_result; |
| 724 | - } |
|
| 724 | + } |
|
| 725 | 725 | |
| 726 | 726 | /** |
| 727 | - * Check recent aircraft by id |
|
| 728 | - * |
|
| 729 | - * @return String the ident |
|
| 730 | - * |
|
| 731 | - */ |
|
| 727 | + * Check recent aircraft by id |
|
| 728 | + * |
|
| 729 | + * @return String the ident |
|
| 730 | + * |
|
| 731 | + */ |
|
| 732 | 732 | public function checkIdRecent($id) |
| 733 | 733 | { |
| 734 | 734 | global $globalDBdriver, $globalTimezone; |
@@ -754,14 +754,14 @@ discard block |
||
| 754 | 754 | $ident_result = $row['fammarine_id']; |
| 755 | 755 | } |
| 756 | 756 | return $ident_result; |
| 757 | - } |
|
| 757 | + } |
|
| 758 | 758 | |
| 759 | 759 | /** |
| 760 | - * Check recent aircraft by mmsi |
|
| 761 | - * |
|
| 762 | - * @return String the ident |
|
| 763 | - * |
|
| 764 | - */ |
|
| 760 | + * Check recent aircraft by mmsi |
|
| 761 | + * |
|
| 762 | + * @return String the ident |
|
| 763 | + * |
|
| 764 | + */ |
|
| 765 | 765 | public function checkMMSIRecent($mmsi) |
| 766 | 766 | { |
| 767 | 767 | global $globalDBdriver, $globalTimezone; |
@@ -787,19 +787,19 @@ discard block |
||
| 787 | 787 | $ident_result = $row['fammarine_id']; |
| 788 | 788 | } |
| 789 | 789 | return $ident_result; |
| 790 | - } |
|
| 790 | + } |
|
| 791 | 791 | |
| 792 | 792 | /** |
| 793 | - * Adds a new spotter data |
|
| 794 | - * |
|
| 795 | - * @param String $fammarine_id the ID from flightaware |
|
| 796 | - * @param String $ident the flight ident |
|
| 797 | - * @param String $aircraft_icao the aircraft type |
|
| 798 | - * @param String $departure_airport_icao the departure airport |
|
| 799 | - * @param String $arrival_airport_icao the arrival airport |
|
| 800 | - * @return String success or false |
|
| 801 | - * |
|
| 802 | - */ |
|
| 793 | + * Adds a new spotter data |
|
| 794 | + * |
|
| 795 | + * @param String $fammarine_id the ID from flightaware |
|
| 796 | + * @param String $ident the flight ident |
|
| 797 | + * @param String $aircraft_icao the aircraft type |
|
| 798 | + * @param String $departure_airport_icao the departure airport |
|
| 799 | + * @param String $arrival_airport_icao the arrival airport |
|
| 800 | + * @return String success or false |
|
| 801 | + * |
|
| 802 | + */ |
|
| 803 | 803 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
| 804 | 804 | { |
| 805 | 805 | global $globalURL, $globalArchive, $globalDebug; |
@@ -870,10 +870,10 @@ discard block |
||
| 870 | 870 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
| 871 | 871 | |
| 872 | 872 | |
| 873 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 874 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 875 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 876 | - $query = ''; |
|
| 873 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 874 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 875 | + if ($arrival_date == '') $arrival_date = NULL; |
|
| 876 | + $query = ''; |
|
| 877 | 877 | if ($globalArchive) { |
| 878 | 878 | if ($globalDebug) echo '-- Delete previous data -- '; |
| 879 | 879 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | * @param Array $filter the filter |
| 17 | 17 | * @return Array the SQL part |
| 18 | 18 | */ |
| 19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 21 | 21 | $filters = array(); |
| 22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
| 25 | 25 | } else { |
| 26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | - $filters = array_merge($filters,$filter); |
|
| 30 | + $filters = array_merge($filters, $filter); |
|
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 33 | 33 | $filter_query_join = ''; |
| 34 | 34 | $filter_query_where = ''; |
| 35 | - foreach($filters as $flt) { |
|
| 35 | + foreach ($filters as $flt) { |
|
| 36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 37 | 37 | if (isset($flt['source'])) { |
| 38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 39 | 39 | } else { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
| 74 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
| 75 | 75 | } |
| 76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 78 | 78 | } |
| 79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 81 | 81 | if ($filter_query_where != '') { |
| 82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 83 | 83 | } |
| 84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
| 85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | if ($limit != '') |
| 103 | 103 | { |
| 104 | 104 | $limit_array = explode(',', $limit); |
| 105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 108 | 108 | { |
| 109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
| 121 | + if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
| 122 | 122 | |
| 123 | 123 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 124 | 124 | if ($globalDBdriver == 'mysql') { |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } else { |
| 128 | 128 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
| 129 | 129 | } |
| 130 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 130 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 131 | 131 | |
| 132 | 132 | return $spotter_array; |
| 133 | 133 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | global $globalDBdriver, $globalLiveInterval; |
| 144 | 144 | date_default_timezone_set('UTC'); |
| 145 | 145 | |
| 146 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 146 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 147 | 147 | |
| 148 | 148 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 149 | 149 | if ($globalDBdriver == 'mysql') { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | try { |
| 158 | 158 | $sth = $this->db->prepare($query); |
| 159 | 159 | $sth->execute(); |
| 160 | - } catch(PDOException $e) { |
|
| 160 | + } catch (PDOException $e) { |
|
| 161 | 161 | echo $e->getMessage(); |
| 162 | 162 | die; |
| 163 | 163 | } |
@@ -177,15 +177,15 @@ discard block |
||
| 177 | 177 | global $globalDBdriver, $globalLiveInterval; |
| 178 | 178 | date_default_timezone_set('UTC'); |
| 179 | 179 | |
| 180 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 180 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 181 | 181 | |
| 182 | 182 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 183 | 183 | if ($globalDBdriver == 'mysql') { |
| 184 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 184 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 185 | 185 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 186 | 186 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 187 | 187 | } else { |
| 188 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 188 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 189 | 189 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
| 190 | 190 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 191 | 191 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | try { |
| 194 | 194 | $sth = $this->db->prepare($query); |
| 195 | 195 | $sth->execute(); |
| 196 | - } catch(PDOException $e) { |
|
| 196 | + } catch (PDOException $e) { |
|
| 197 | 197 | echo $e->getMessage(); |
| 198 | 198 | die; |
| 199 | 199 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | public function getLiveMarineCount($filter = array()) |
| 211 | 211 | { |
| 212 | 212 | global $globalDBdriver, $globalLiveInterval; |
| 213 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 213 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 214 | 214 | |
| 215 | 215 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 216 | 216 | if ($globalDBdriver == 'mysql') { |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | try { |
| 222 | 222 | $sth = $this->db->prepare($query); |
| 223 | 223 | $sth->execute(); |
| 224 | - } catch(PDOException $e) { |
|
| 224 | + } catch (PDOException $e) { |
|
| 225 | 225 | echo $e->getMessage(); |
| 226 | 226 | die; |
| 227 | 227 | } |
@@ -244,10 +244,10 @@ discard block |
||
| 244 | 244 | $filter_query = $this->getFilter($filter); |
| 245 | 245 | |
| 246 | 246 | if (is_array($coord)) { |
| 247 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 248 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 249 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 250 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 247 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 248 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 249 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 250 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 251 | 251 | } else return array(); |
| 252 | 252 | if ($globalDBdriver == 'mysql') { |
| 253 | 253 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
@@ -272,17 +272,17 @@ discard block |
||
| 272 | 272 | $filter_query = $this->getFilter($filter); |
| 273 | 273 | |
| 274 | 274 | if (is_array($coord)) { |
| 275 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 276 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 277 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 278 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 275 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 276 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 277 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 278 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 279 | 279 | } else return array(); |
| 280 | 280 | if ($globalDBdriver == 'mysql') { |
| 281 | 281 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 282 | 282 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
| 283 | 283 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 284 | 284 | } else { |
| 285 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 285 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
| 286 | 286 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 287 | 287 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
| 288 | 288 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | if ($interval == '1m') |
| 332 | 332 | { |
| 333 | 333 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
| 334 | - } else if ($interval == '15m'){ |
|
| 334 | + } else if ($interval == '15m') { |
|
| 335 | 335 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
| 336 | 336 | } |
| 337 | 337 | } |
@@ -339,14 +339,14 @@ discard block |
||
| 339 | 339 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 342 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
| 343 | 343 | WHERE marine_live.latitude <> '' |
| 344 | 344 | AND marine_live.longitude <> '' |
| 345 | 345 | ".$additional_query." |
| 346 | 346 | HAVING distance < :radius |
| 347 | 347 | ORDER BY distance"; |
| 348 | 348 | |
| 349 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 349 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 350 | 350 | |
| 351 | 351 | return $spotter_array; |
| 352 | 352 | } |
@@ -364,9 +364,9 @@ discard block |
||
| 364 | 364 | date_default_timezone_set('UTC'); |
| 365 | 365 | |
| 366 | 366 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 367 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 367 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 368 | 368 | |
| 369 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 369 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 370 | 370 | |
| 371 | 371 | return $spotter_array; |
| 372 | 372 | } |
@@ -377,16 +377,16 @@ discard block |
||
| 377 | 377 | * @return Array the spotter information |
| 378 | 378 | * |
| 379 | 379 | */ |
| 380 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
| 380 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
| 381 | 381 | { |
| 382 | 382 | $Marine = new Marine($this->db); |
| 383 | 383 | date_default_timezone_set('UTC'); |
| 384 | 384 | |
| 385 | 385 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 386 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 386 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 387 | 387 | |
| 388 | - $date = date('c',$date); |
|
| 389 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 388 | + $date = date('c', $date); |
|
| 389 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 390 | 390 | |
| 391 | 391 | return $spotter_array; |
| 392 | 392 | } |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | date_default_timezone_set('UTC'); |
| 404 | 404 | |
| 405 | 405 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 406 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 406 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 407 | 407 | |
| 408 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 408 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 409 | 409 | |
| 410 | 410 | return $spotter_array; |
| 411 | 411 | } |
@@ -416,15 +416,15 @@ discard block |
||
| 416 | 416 | * @return Array the spotter information |
| 417 | 417 | * |
| 418 | 418 | */ |
| 419 | - public function getDateLiveMarineDataById($id,$date) |
|
| 419 | + public function getDateLiveMarineDataById($id, $date) |
|
| 420 | 420 | { |
| 421 | 421 | $Marine = new Marine($this->db); |
| 422 | 422 | date_default_timezone_set('UTC'); |
| 423 | 423 | |
| 424 | 424 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 425 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 426 | - $date = date('c',$date); |
|
| 427 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 425 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
| 426 | + $date = date('c', $date); |
|
| 427 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 428 | 428 | |
| 429 | 429 | return $spotter_array; |
| 430 | 430 | } |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | * @return Array the spotter information |
| 437 | 437 | * |
| 438 | 438 | */ |
| 439 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
| 439 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
| 440 | 440 | { |
| 441 | 441 | global $globalDBdriver, $globalLiveInterval; |
| 442 | 442 | date_default_timezone_set('UTC'); |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | try { |
| 456 | 456 | $sth = $this->db->prepare($query); |
| 457 | 457 | $sth->execute(array(':id' => $id)); |
| 458 | - } catch(PDOException $e) { |
|
| 458 | + } catch (PDOException $e) { |
|
| 459 | 459 | echo $e->getMessage(); |
| 460 | 460 | die; |
| 461 | 461 | } |
@@ -473,12 +473,12 @@ discard block |
||
| 473 | 473 | { |
| 474 | 474 | date_default_timezone_set('UTC'); |
| 475 | 475 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 476 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
| 476 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
| 477 | 477 | try { |
| 478 | 478 | |
| 479 | 479 | $sth = $this->db->prepare($query); |
| 480 | 480 | $sth->execute(array(':ident' => $ident)); |
| 481 | - } catch(PDOException $e) { |
|
| 481 | + } catch (PDOException $e) { |
|
| 482 | 482 | echo $e->getMessage(); |
| 483 | 483 | die; |
| 484 | 484 | } |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | $sth = $this->db->prepare($query); |
| 510 | 510 | $sth->execute(); |
| 511 | - } catch(PDOException $e) { |
|
| 511 | + } catch (PDOException $e) { |
|
| 512 | 512 | return "error"; |
| 513 | 513 | } |
| 514 | 514 | |
@@ -531,14 +531,14 @@ discard block |
||
| 531 | 531 | |
| 532 | 532 | $sth = $this->db->prepare($query); |
| 533 | 533 | $sth->execute(); |
| 534 | - } catch(PDOException $e) { |
|
| 534 | + } catch (PDOException $e) { |
|
| 535 | 535 | return "error"; |
| 536 | 536 | } |
| 537 | 537 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
| 538 | 538 | $i = 0; |
| 539 | - $j =0; |
|
| 539 | + $j = 0; |
|
| 540 | 540 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 541 | - foreach($all as $row) |
|
| 541 | + foreach ($all as $row) |
|
| 542 | 542 | { |
| 543 | 543 | $i++; |
| 544 | 544 | $j++; |
@@ -546,9 +546,9 @@ discard block |
||
| 546 | 546 | if ($globalDebug) echo "."; |
| 547 | 547 | try { |
| 548 | 548 | |
| 549 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 549 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 550 | 550 | $sth->execute(); |
| 551 | - } catch(PDOException $e) { |
|
| 551 | + } catch (PDOException $e) { |
|
| 552 | 552 | return "error"; |
| 553 | 553 | } |
| 554 | 554 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -559,9 +559,9 @@ discard block |
||
| 559 | 559 | if ($i > 0) { |
| 560 | 560 | try { |
| 561 | 561 | |
| 562 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 562 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 563 | 563 | $sth->execute(); |
| 564 | - } catch(PDOException $e) { |
|
| 564 | + } catch (PDOException $e) { |
|
| 565 | 565 | return "error"; |
| 566 | 566 | } |
| 567 | 567 | } |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | |
| 575 | 575 | $sth = $this->db->prepare($query); |
| 576 | 576 | $sth->execute(); |
| 577 | - } catch(PDOException $e) { |
|
| 577 | + } catch (PDOException $e) { |
|
| 578 | 578 | return "error"; |
| 579 | 579 | } |
| 580 | 580 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -622,13 +622,13 @@ discard block |
||
| 622 | 622 | public function deleteLiveMarineDataByIdent($ident) |
| 623 | 623 | { |
| 624 | 624 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 625 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
| 625 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
| 626 | 626 | |
| 627 | 627 | try { |
| 628 | 628 | |
| 629 | 629 | $sth = $this->db->prepare($query); |
| 630 | 630 | $sth->execute(array(':ident' => $ident)); |
| 631 | - } catch(PDOException $e) { |
|
| 631 | + } catch (PDOException $e) { |
|
| 632 | 632 | return "error"; |
| 633 | 633 | } |
| 634 | 634 | |
@@ -644,13 +644,13 @@ discard block |
||
| 644 | 644 | public function deleteLiveMarineDataById($id) |
| 645 | 645 | { |
| 646 | 646 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 647 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
| 647 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
| 648 | 648 | |
| 649 | 649 | try { |
| 650 | 650 | |
| 651 | 651 | $sth = $this->db->prepare($query); |
| 652 | 652 | $sth->execute(array(':id' => $id)); |
| 653 | - } catch(PDOException $e) { |
|
| 653 | + } catch (PDOException $e) { |
|
| 654 | 654 | return "error"; |
| 655 | 655 | } |
| 656 | 656 | |
@@ -668,13 +668,13 @@ discard block |
||
| 668 | 668 | { |
| 669 | 669 | global $globalDBdriver, $globalTimezone; |
| 670 | 670 | if ($globalDBdriver == 'mysql') { |
| 671 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
| 671 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
| 672 | 672 | WHERE marine_live.ident = :ident |
| 673 | 673 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 674 | 674 | AND marine_live.date < UTC_TIMESTAMP()'; |
| 675 | 675 | $query_data = array(':ident' => $ident); |
| 676 | 676 | } else { |
| 677 | - $query = "SELECT marine_live.ident FROM marine_live |
|
| 677 | + $query = "SELECT marine_live.ident FROM marine_live |
|
| 678 | 678 | WHERE marine_live.ident = :ident |
| 679 | 679 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 680 | 680 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -683,8 +683,8 @@ discard block |
||
| 683 | 683 | |
| 684 | 684 | $sth = $this->db->prepare($query); |
| 685 | 685 | $sth->execute($query_data); |
| 686 | - $ident_result=''; |
|
| 687 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 686 | + $ident_result = ''; |
|
| 687 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 688 | 688 | { |
| 689 | 689 | $ident_result = $row['ident']; |
| 690 | 690 | } |
@@ -701,13 +701,13 @@ discard block |
||
| 701 | 701 | { |
| 702 | 702 | global $globalDBdriver, $globalTimezone; |
| 703 | 703 | if ($globalDBdriver == 'mysql') { |
| 704 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 704 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 705 | 705 | WHERE marine_live.ident = :ident |
| 706 | 706 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 707 | 707 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 708 | 708 | $query_data = array(':ident' => $ident); |
| 709 | 709 | } else { |
| 710 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 710 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 711 | 711 | WHERE marine_live.ident = :ident |
| 712 | 712 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 713 | 713 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -716,8 +716,8 @@ discard block |
||
| 716 | 716 | |
| 717 | 717 | $sth = $this->db->prepare($query); |
| 718 | 718 | $sth->execute($query_data); |
| 719 | - $ident_result=''; |
|
| 720 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 719 | + $ident_result = ''; |
|
| 720 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 721 | 721 | { |
| 722 | 722 | $ident_result = $row['fammarine_id']; |
| 723 | 723 | } |
@@ -734,13 +734,13 @@ discard block |
||
| 734 | 734 | { |
| 735 | 735 | global $globalDBdriver, $globalTimezone; |
| 736 | 736 | if ($globalDBdriver == 'mysql') { |
| 737 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 737 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 738 | 738 | WHERE marine_live.fammarine_id = :id |
| 739 | 739 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 740 | 740 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 741 | 741 | $query_data = array(':id' => $id); |
| 742 | 742 | } else { |
| 743 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 743 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
| 744 | 744 | WHERE marine_live.fammarine_id = :id |
| 745 | 745 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 746 | 746 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -749,8 +749,8 @@ discard block |
||
| 749 | 749 | |
| 750 | 750 | $sth = $this->db->prepare($query); |
| 751 | 751 | $sth->execute($query_data); |
| 752 | - $ident_result=''; |
|
| 753 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 752 | + $ident_result = ''; |
|
| 753 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 754 | 754 | { |
| 755 | 755 | $ident_result = $row['fammarine_id']; |
| 756 | 756 | } |
@@ -767,13 +767,13 @@ discard block |
||
| 767 | 767 | { |
| 768 | 768 | global $globalDBdriver, $globalTimezone; |
| 769 | 769 | if ($globalDBdriver == 'mysql') { |
| 770 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
| 770 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
| 771 | 771 | WHERE marine_live.mmsi = :mmsi |
| 772 | 772 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 773 | 773 | // AND marine_live.date < UTC_TIMESTAMP()"; |
| 774 | 774 | $query_data = array(':mmsi' => $mmsi); |
| 775 | 775 | } else { |
| 776 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
| 776 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
| 777 | 777 | WHERE marine_live.mmsi = :mmsi |
| 778 | 778 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 779 | 779 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -782,8 +782,8 @@ discard block |
||
| 782 | 782 | |
| 783 | 783 | $sth = $this->db->prepare($query); |
| 784 | 784 | $sth->execute($query_data); |
| 785 | - $ident_result=''; |
|
| 786 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 785 | + $ident_result = ''; |
|
| 786 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 787 | 787 | { |
| 788 | 788 | $ident_result = $row['fammarine_id']; |
| 789 | 789 | } |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | * @return String success or false |
| 802 | 802 | * |
| 803 | 803 | */ |
| 804 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 804 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 805 | 805 | { |
| 806 | 806 | global $globalURL, $globalArchive, $globalDebug; |
| 807 | 807 | $Common = new Common(); |
@@ -853,26 +853,26 @@ discard block |
||
| 853 | 853 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 854 | 854 | |
| 855 | 855 | |
| 856 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
| 857 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 858 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 859 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 860 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 861 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 862 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 863 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 864 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 865 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
| 866 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
| 867 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
| 868 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
| 869 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 870 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
| 871 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
| 856 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
| 857 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 858 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 859 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 860 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 861 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 862 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 863 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 864 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 865 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
| 866 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
| 867 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
| 868 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
| 869 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 870 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
| 871 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
| 872 | 872 | |
| 873 | 873 | |
| 874 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 875 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 874 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 875 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 876 | 876 | if ($arrival_date == '') $arrival_date = NULL; |
| 877 | 877 | $query = ''; |
| 878 | 878 | if ($globalArchive) { |
@@ -882,18 +882,18 @@ discard block |
||
| 882 | 882 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
| 883 | 883 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
| 884 | 884 | |
| 885 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
| 885 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
| 886 | 886 | try { |
| 887 | 887 | $sth = $this->db->prepare($query); |
| 888 | 888 | $sth->execute($query_values); |
| 889 | - } catch(PDOException $e) { |
|
| 889 | + } catch (PDOException $e) { |
|
| 890 | 890 | return "error : ".$e->getMessage(); |
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 894 | 894 | if ($globalDebug) echo '(Add to Marine archive : '; |
| 895 | 895 | $MarineArchive = new MarineArchive($this->db); |
| 896 | - $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
|
| 896 | + $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country); |
|
| 897 | 897 | if ($globalDebug) echo $result.')'; |
| 898 | 898 | } |
| 899 | 899 | return "success"; |
@@ -901,7 +901,7 @@ discard block |
||
| 901 | 901 | |
| 902 | 902 | public function getOrderBy() |
| 903 | 903 | { |
| 904 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
| 904 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
| 905 | 905 | return $orderby; |
| 906 | 906 | } |
| 907 | 907 | |
@@ -29,7 +29,9 @@ discard block |
||
| 29 | 29 | if (isset($filter[0]['source'])) { |
| 30 | 30 | $filters = array_merge($filters,$filter); |
| 31 | 31 | } |
| 32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 33 | 35 | $filter_query_join = ''; |
| 34 | 36 | $filter_query_where = ''; |
| 35 | 37 | foreach($filters as $flt) { |
@@ -76,8 +78,11 @@ discard block |
||
| 76 | 78 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 77 | 79 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 78 | 80 | } |
| 79 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 80 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 81 | + if ($filter_query_where == '' && $where) { |
|
| 82 | + $filter_query_where = ' WHERE'; |
|
| 83 | + } elseif ($filter_query_where != '' && $and) { |
|
| 84 | + $filter_query_where .= ' AND'; |
|
| 85 | + } |
|
| 81 | 86 | if ($filter_query_where != '') { |
| 82 | 87 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 83 | 88 | } |
@@ -118,9 +123,13 @@ discard block |
||
| 118 | 123 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 119 | 124 | } |
| 120 | 125 | } |
| 121 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
| 126 | + if ($orderby_query == '') { |
|
| 127 | + $orderby_query= ' ORDER BY date DESC'; |
|
| 128 | + } |
|
| 122 | 129 | |
| 123 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 130 | + if (!isset($globalLiveInterval)) { |
|
| 131 | + $globalLiveInterval = '200'; |
|
| 132 | + } |
|
| 124 | 133 | if ($globalDBdriver == 'mysql') { |
| 125 | 134 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate"; |
| 126 | 135 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -145,7 +154,9 @@ discard block |
||
| 145 | 154 | |
| 146 | 155 | $filter_query = $this->getFilter($filter,true,true); |
| 147 | 156 | |
| 148 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 157 | + if (!isset($globalLiveInterval)) { |
|
| 158 | + $globalLiveInterval = '200'; |
|
| 159 | + } |
|
| 149 | 160 | if ($globalDBdriver == 'mysql') { |
| 150 | 161 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 151 | 162 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0"; |
@@ -179,7 +190,9 @@ discard block |
||
| 179 | 190 | |
| 180 | 191 | $filter_query = $this->getFilter($filter,true,true); |
| 181 | 192 | |
| 182 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 193 | + if (!isset($globalLiveInterval)) { |
|
| 194 | + $globalLiveInterval = '200'; |
|
| 195 | + } |
|
| 183 | 196 | if ($globalDBdriver == 'mysql') { |
| 184 | 197 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 185 | 198 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
@@ -212,7 +225,9 @@ discard block |
||
| 212 | 225 | global $globalDBdriver, $globalLiveInterval; |
| 213 | 226 | $filter_query = $this->getFilter($filter,true,true); |
| 214 | 227 | |
| 215 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 228 | + if (!isset($globalLiveInterval)) { |
|
| 229 | + $globalLiveInterval = '200'; |
|
| 230 | + } |
|
| 216 | 231 | if ($globalDBdriver == 'mysql') { |
| 217 | 232 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
| 218 | 233 | } else { |
@@ -240,7 +255,9 @@ discard block |
||
| 240 | 255 | { |
| 241 | 256 | global $globalDBdriver, $globalLiveInterval; |
| 242 | 257 | $Spotter = new Spotter($this->db); |
| 243 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 258 | + if (!isset($globalLiveInterval)) { |
|
| 259 | + $globalLiveInterval = '200'; |
|
| 260 | + } |
|
| 244 | 261 | $filter_query = $this->getFilter($filter); |
| 245 | 262 | |
| 246 | 263 | if (is_array($coord)) { |
@@ -248,7 +265,9 @@ discard block |
||
| 248 | 265 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 249 | 266 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 250 | 267 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 251 | - } else return array(); |
|
| 268 | + } else { |
|
| 269 | + return array(); |
|
| 270 | + } |
|
| 252 | 271 | if ($globalDBdriver == 'mysql') { |
| 253 | 272 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
| 254 | 273 | } else { |
@@ -268,7 +287,9 @@ discard block |
||
| 268 | 287 | { |
| 269 | 288 | global $globalDBdriver, $globalLiveInterval; |
| 270 | 289 | $Spotter = new Spotter($this->db); |
| 271 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 290 | + if (!isset($globalLiveInterval)) { |
|
| 291 | + $globalLiveInterval = '200'; |
|
| 292 | + } |
|
| 272 | 293 | $filter_query = $this->getFilter($filter); |
| 273 | 294 | |
| 274 | 295 | if (is_array($coord)) { |
@@ -276,7 +297,9 @@ discard block |
||
| 276 | 297 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 277 | 298 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 278 | 299 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 279 | - } else return array(); |
|
| 300 | + } else { |
|
| 301 | + return array(); |
|
| 302 | + } |
|
| 280 | 303 | if ($globalDBdriver == 'mysql') { |
| 281 | 304 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
| 282 | 305 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
@@ -444,11 +467,15 @@ discard block |
||
| 444 | 467 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
| 445 | 468 | if ($globalDBdriver == 'mysql') { |
| 446 | 469 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
| 447 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 470 | + if ($liveinterval) { |
|
| 471 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 472 | + } |
|
| 448 | 473 | $query .= ' ORDER BY date'; |
| 449 | 474 | } else { |
| 450 | 475 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
| 451 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 476 | + if ($liveinterval) { |
|
| 477 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 478 | + } |
|
| 452 | 479 | $query .= ' ORDER BY date'; |
| 453 | 480 | } |
| 454 | 481 | |
@@ -543,7 +570,9 @@ discard block |
||
| 543 | 570 | $i++; |
| 544 | 571 | $j++; |
| 545 | 572 | if ($j == 30) { |
| 546 | - if ($globalDebug) echo "."; |
|
| 573 | + if ($globalDebug) { |
|
| 574 | + echo "."; |
|
| 575 | + } |
|
| 547 | 576 | try { |
| 548 | 577 | |
| 549 | 578 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -823,7 +852,9 @@ discard block |
||
| 823 | 852 | { |
| 824 | 853 | return false; |
| 825 | 854 | } |
| 826 | - } else return ''; |
|
| 855 | + } else { |
|
| 856 | + return ''; |
|
| 857 | + } |
|
| 827 | 858 | |
| 828 | 859 | if ($longitude != '') |
| 829 | 860 | { |
@@ -831,7 +862,9 @@ discard block |
||
| 831 | 862 | { |
| 832 | 863 | return false; |
| 833 | 864 | } |
| 834 | - } else return ''; |
|
| 865 | + } else { |
|
| 866 | + return ''; |
|
| 867 | + } |
|
| 835 | 868 | |
| 836 | 869 | |
| 837 | 870 | if ($heading != '') |
@@ -840,7 +873,9 @@ discard block |
||
| 840 | 873 | { |
| 841 | 874 | return false; |
| 842 | 875 | } |
| 843 | - } else $heading = 0; |
|
| 876 | + } else { |
|
| 877 | + $heading = 0; |
|
| 878 | + } |
|
| 844 | 879 | |
| 845 | 880 | if ($groundspeed != '') |
| 846 | 881 | { |
@@ -848,9 +883,13 @@ discard block |
||
| 848 | 883 | { |
| 849 | 884 | return false; |
| 850 | 885 | } |
| 851 | - } else $groundspeed = 0; |
|
| 886 | + } else { |
|
| 887 | + $groundspeed = 0; |
|
| 888 | + } |
|
| 852 | 889 | date_default_timezone_set('UTC'); |
| 853 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 890 | + if ($date == '') { |
|
| 891 | + $date = date("Y-m-d H:i:s", time()); |
|
| 892 | + } |
|
| 854 | 893 | |
| 855 | 894 | |
| 856 | 895 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -871,12 +910,20 @@ discard block |
||
| 871 | 910 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
| 872 | 911 | |
| 873 | 912 | |
| 874 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 875 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 876 | - if ($arrival_date == '') $arrival_date = NULL; |
|
| 913 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 914 | + $groundspeed = 0; |
|
| 915 | + } |
|
| 916 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 917 | + $heading = 0; |
|
| 918 | + } |
|
| 919 | + if ($arrival_date == '') { |
|
| 920 | + $arrival_date = NULL; |
|
| 921 | + } |
|
| 877 | 922 | $query = ''; |
| 878 | 923 | if ($globalArchive) { |
| 879 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 924 | + if ($globalDebug) { |
|
| 925 | + echo '-- Delete previous data -- '; |
|
| 926 | + } |
|
| 880 | 927 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
| 881 | 928 | } |
| 882 | 929 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
@@ -891,10 +938,14 @@ discard block |
||
| 891 | 938 | } |
| 892 | 939 | |
| 893 | 940 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 894 | - if ($globalDebug) echo '(Add to Marine archive : '; |
|
| 941 | + if ($globalDebug) { |
|
| 942 | + echo '(Add to Marine archive : '; |
|
| 943 | + } |
|
| 895 | 944 | $MarineArchive = new MarineArchive($this->db); |
| 896 | 945 | $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
| 897 | - if ($globalDebug) echo $result.')'; |
|
| 946 | + if ($globalDebug) { |
|
| 947 | + echo $result.')'; |
|
| 948 | + } |
|
| 898 | 949 | } |
| 899 | 950 | return "success"; |
| 900 | 951 | } |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
| 3 | 3 | $ident = ''; |
| 4 | -if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
| 5 | -if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
| 4 | +if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST, 'ident', FILTER_SANITIZE_STRING); |
|
| 5 | +if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
| 6 | 6 | if ($ident != '') |
| 7 | 7 | { |
| 8 | 8 | if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident); |
@@ -1,13 +1,20 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
| 3 | 3 | $ident = ''; |
| 4 | -if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
| 5 | -if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
| 4 | +if (isset($_POST['ident'])) { |
|
| 5 | + $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
| 6 | +} |
|
| 7 | +if (isset($_GET['ident'])) { |
|
| 8 | + $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
| 9 | +} |
|
| 6 | 10 | if ($ident != '') |
| 7 | 11 | { |
| 8 | - if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident); |
|
| 9 | - else header('Location: '.$globalURL.'/ident/'.$ident); |
|
| 10 | -} else { |
|
| 12 | + if (isset($_GET['marine'])) { |
|
| 13 | + header('Location: '.$globalURL.'/marine/ident/'.$ident); |
|
| 14 | + } else { |
|
| 15 | + header('Location: '.$globalURL.'/ident/'.$ident); |
|
| 16 | + } |
|
| 17 | + } else { |
|
| 11 | 18 | header('Location: '.$globalURL); |
| 12 | 19 | } |
| 13 | 20 | ?> |
| 14 | 21 | \ No newline at end of file |
@@ -4,21 +4,21 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | $type = ''; |
| 6 | 6 | if (isset($_GET['marine'])) { |
| 7 | - require_once('require/class.Marine.php');; |
|
| 7 | + require_once('require/class.Marine.php'); ; |
|
| 8 | 8 | require_once('require/class.MarineLive.php'); |
| 9 | - $MarineLive=new MarineLive(); |
|
| 9 | + $MarineLive = new MarineLive(); |
|
| 10 | 10 | $type = 'marine'; |
| 11 | 11 | $page_url = $globalURL.'/marine/currently'; |
| 12 | 12 | } elseif (isset($_GET['tracker'])) { |
| 13 | - require_once('require/class.Tracker.php');; |
|
| 13 | + require_once('require/class.Tracker.php'); ; |
|
| 14 | 14 | require_once('require/class.TrackerLive.php'); |
| 15 | - $TrackerLive=new TrackerLive(); |
|
| 15 | + $TrackerLive = new TrackerLive(); |
|
| 16 | 16 | $type = 'tracker'; |
| 17 | 17 | $page_url = $globalURL.'/tracker/currently'; |
| 18 | 18 | } else { |
| 19 | - require_once('require/class.Spotter.php');; |
|
| 19 | + require_once('require/class.Spotter.php'); ; |
|
| 20 | 20 | require_once('require/class.SpotterLive.php'); |
| 21 | - $SpotterLive=new SpotterLive(); |
|
| 21 | + $SpotterLive = new SpotterLive(); |
|
| 22 | 22 | $type = 'aircraft'; |
| 23 | 23 | $page_url = $globalURL.'/currently'; |
| 24 | 24 | } |
@@ -26,12 +26,12 @@ discard block |
||
| 26 | 26 | $title = "Current Activity"; |
| 27 | 27 | require_once('header.php'); |
| 28 | 28 | //calculuation for the pagination |
| 29 | -if(!isset($_GET['limit'])) |
|
| 29 | +if (!isset($_GET['limit'])) |
|
| 30 | 30 | { |
| 31 | 31 | $limit_start = 0; |
| 32 | 32 | $limit_end = 25; |
| 33 | 33 | $absolute_difference = 25; |
| 34 | -} else { |
|
| 34 | +} else { |
|
| 35 | 35 | $limit_explode = explode(",", $_GET['limit']); |
| 36 | 36 | $limit_start = $limit_explode[0]; |
| 37 | 37 | $limit_end = $limit_explode[1]; |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>'; |
| 55 | 55 | elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>'; |
| 56 | 56 | |
| 57 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 57 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 58 | 58 | if ($sort != '') { |
| 59 | 59 | if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort); |
| 60 | 60 | elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $limit_start = 0; |
| 32 | 32 | $limit_end = 25; |
| 33 | 33 | $absolute_difference = 25; |
| 34 | -} else { |
|
| 34 | +} else { |
|
| 35 | 35 | $limit_explode = explode(",", $_GET['limit']); |
| 36 | 36 | $limit_start = $limit_explode[0]; |
| 37 | 37 | $limit_end = $limit_explode[1]; |
@@ -50,20 +50,32 @@ discard block |
||
| 50 | 50 | print '</div>'; |
| 51 | 51 | |
| 52 | 52 | print '<div class="table column">'; |
| 53 | -if ($type == 'aircraft') print '<p>'._("The table below shows the detailed information of all current flights.").'</p>'; |
|
| 54 | -elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>'; |
|
| 55 | -elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>'; |
|
| 53 | +if ($type == 'aircraft') { |
|
| 54 | + print '<p>'._("The table below shows the detailed information of all current flights.").'</p>'; |
|
| 55 | +} elseif ($type == 'marine') { |
|
| 56 | + print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>'; |
|
| 57 | +} elseif ($type == 'tracker') { |
|
| 58 | + print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>'; |
|
| 59 | +} |
|
| 56 | 60 | |
| 57 | 61 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
| 58 | 62 | if ($sort != '') { |
| 59 | - if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort); |
|
| 60 | - elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort); |
|
| 61 | - elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort); |
|
| 62 | -} else { |
|
| 63 | - if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference); |
|
| 64 | - elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference); |
|
| 65 | - elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference); |
|
| 66 | -} |
|
| 63 | + if ($type == 'aircraft') { |
|
| 64 | + $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort); |
|
| 65 | + } elseif ($type == 'marine') { |
|
| 66 | + $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort); |
|
| 67 | + } elseif ($type == 'tracker') { |
|
| 68 | + $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort); |
|
| 69 | + } |
|
| 70 | + } else { |
|
| 71 | + if ($type == 'aircraft') { |
|
| 72 | + $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference); |
|
| 73 | + } elseif ($type == 'marine') { |
|
| 74 | + $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference); |
|
| 75 | + } elseif ($type == 'tracker') { |
|
| 76 | + $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference); |
|
| 77 | + } |
|
| 78 | + } |
|
| 67 | 79 | |
| 68 | 80 | if (!empty($spotter_array)) |
| 69 | 81 | { |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | $type = 'aircraft'; |
| 4 | 4 | if (isset($_GET['marine'])) $type = 'marine'; |
| 5 | 5 | elseif (isset($_GET['tracker'])) $type = 'tracker'; |
| 6 | -$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
|
| 6 | +$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING); |
|
| 7 | 7 | if ($date == '') $date = date('Y-m-d'); |
| 8 | 8 | if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date); |
| 9 | 9 | elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date); |
@@ -1,11 +1,20 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
| 3 | 3 | $type = 'aircraft'; |
| 4 | -if (isset($_GET['marine'])) $type = 'marine'; |
|
| 5 | -elseif (isset($_GET['tracker'])) $type = 'tracker'; |
|
| 4 | +if (isset($_GET['marine'])) { |
|
| 5 | + $type = 'marine'; |
|
| 6 | +} elseif (isset($_GET['tracker'])) { |
|
| 7 | + $type = 'tracker'; |
|
| 8 | +} |
|
| 6 | 9 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
| 7 | -if ($date == '') $date = date('Y-m-d'); |
|
| 8 | -if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date); |
|
| 9 | -elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date); |
|
| 10 | -else header('Location: '.$globalURL.'/date/'.$date); |
|
| 10 | +if ($date == '') { |
|
| 11 | + $date = date('Y-m-d'); |
|
| 12 | +} |
|
| 13 | +if ($type == 'marine') { |
|
| 14 | + header('Location: '.$globalURL.'/marine/date/'.$date); |
|
| 15 | +} elseif ($type == 'tracker') { |
|
| 16 | + header('Location: '.$globalURL.'/tracker/date/'.$date); |
|
| 17 | +} else { |
|
| 18 | + header('Location: '.$globalURL.'/date/'.$date); |
|
| 19 | +} |
|
| 11 | 20 | ?> |
| 12 | 21 | \ No newline at end of file |
@@ -2,34 +2,34 @@ discard block |
||
| 2 | 2 | require_once('require/class.Connection.php'); |
| 3 | 3 | require_once('require/class.Language.php'); |
| 4 | 4 | $type = ''; |
| 5 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
| 5 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
| 6 | 6 | if (isset($_GET['marine'])) { |
| 7 | - require_once('require/class.Marine.php');; |
|
| 7 | + require_once('require/class.Marine.php'); ; |
|
| 8 | 8 | $Marine = new Marine(); |
| 9 | 9 | $type = 'marine'; |
| 10 | 10 | $page_url = $globalURL.'/marine/date/'.$date; |
| 11 | 11 | } elseif (isset($_GET['tracker'])) { |
| 12 | - require_once('require/class.Tracker.php');; |
|
| 12 | + require_once('require/class.Tracker.php'); ; |
|
| 13 | 13 | $Tracker = new Tracker(); |
| 14 | 14 | $type = 'tracker'; |
| 15 | 15 | $page_url = $globalURL.'/tracker/date/'.$date; |
| 16 | 16 | } else { |
| 17 | - require_once('require/class.Spotter.php');; |
|
| 17 | + require_once('require/class.Spotter.php'); ; |
|
| 18 | 18 | $Spotter = new Spotter(); |
| 19 | 19 | $type = 'aircraft'; |
| 20 | 20 | $page_url = $globalURL.'/date/'.$date; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -if (!isset($_GET['date'])){ |
|
| 23 | +if (!isset($_GET['date'])) { |
|
| 24 | 24 | header('Location: '.$globalURL.''); |
| 25 | 25 | } else { |
| 26 | 26 | //calculuation for the pagination |
| 27 | - if(!isset($_GET['limit'])) |
|
| 27 | + if (!isset($_GET['limit'])) |
|
| 28 | 28 | { |
| 29 | 29 | $limit_start = 0; |
| 30 | 30 | $limit_end = 25; |
| 31 | 31 | $absolute_difference = 25; |
| 32 | - } else { |
|
| 32 | + } else { |
|
| 33 | 33 | $limit_explode = explode(",", $_GET['limit']); |
| 34 | 34 | $limit_start = $limit_explode[0]; |
| 35 | 35 | $limit_end = $limit_explode[1]; |
@@ -43,24 +43,24 @@ discard block |
||
| 43 | 43 | $limit_previous_1 = $limit_start - $absolute_difference; |
| 44 | 44 | $limit_previous_2 = $limit_end - $absolute_difference; |
| 45 | 45 | |
| 46 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 46 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 47 | 47 | if ($sort != '') |
| 48 | 48 | { |
| 49 | - if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
| 50 | - elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
| 51 | - else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
| 49 | + if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date, $limit_start.",".$absolute_difference, $sort); |
|
| 50 | + elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date, $limit_start.",".$absolute_difference, $sort); |
|
| 51 | + else $spotter_array = $Spotter->getSpotterDataByDate($date, $limit_start.",".$absolute_difference, $sort); |
|
| 52 | 52 | } else { |
| 53 | - if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference); |
|
| 54 | - elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference); |
|
| 55 | - else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference); |
|
| 53 | + if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date, $limit_start.",".$absolute_difference); |
|
| 54 | + elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date, $limit_start.",".$absolute_difference); |
|
| 55 | + else $spotter_array = $Spotter->getSpotterDataByDate($date, $limit_start.",".$absolute_difference); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | if (!empty($spotter_array)) |
| 59 | 59 | { |
| 60 | 60 | date_default_timezone_set($globalTimezone); |
| 61 | - if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 62 | - elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 63 | - else $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 61 | + if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 62 | + elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 63 | + else $title = sprintf(_("Detailed View for flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 64 | 64 | |
| 65 | 65 | require_once('header.php'); |
| 66 | 66 | print '<div class="select-item">'; |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
| 79 | 79 | print '<br />'; |
| 80 | 80 | print '<div class="info column">'; |
| 81 | - if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
| 82 | - else print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
| 81 | + if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
| 82 | + else print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
| 83 | 83 | print '</div>'; |
| 84 | 84 | |
| 85 | 85 | if ($type == 'aircraft') include('date-sub-menu.php'); |
| 86 | 86 | print '<div class="table column">'; |
| 87 | - if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 88 | - elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 89 | - else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 87 | + if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 88 | + elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 89 | + else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 90 | 90 | |
| 91 | 91 | include('table-output.php'); |
| 92 | 92 | print '<div class="pagination">'; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $limit_start = 0; |
| 30 | 30 | $limit_end = 25; |
| 31 | 31 | $absolute_difference = 25; |
| 32 | - } else { |
|
| 32 | + } else { |
|
| 33 | 33 | $limit_explode = explode(",", $_GET['limit']); |
| 34 | 34 | $limit_start = $limit_explode[0]; |
| 35 | 35 | $limit_end = $limit_explode[1]; |
@@ -46,21 +46,33 @@ discard block |
||
| 46 | 46 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
| 47 | 47 | if ($sort != '') |
| 48 | 48 | { |
| 49 | - if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
| 50 | - elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
| 51 | - else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
| 49 | + if ($type == 'marine') { |
|
| 50 | + $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
| 51 | + } elseif ($type == 'tracker') { |
|
| 52 | + $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
| 53 | + } else { |
|
| 54 | + $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
| 55 | + } |
|
| 52 | 56 | } else { |
| 53 | - if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference); |
|
| 54 | - elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference); |
|
| 55 | - else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference); |
|
| 57 | + if ($type == 'marine') { |
|
| 58 | + $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference); |
|
| 59 | + } elseif ($type == 'tracker') { |
|
| 60 | + $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference); |
|
| 61 | + } else { |
|
| 62 | + $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference); |
|
| 63 | + } |
|
| 56 | 64 | } |
| 57 | 65 | |
| 58 | 66 | if (!empty($spotter_array)) |
| 59 | 67 | { |
| 60 | 68 | date_default_timezone_set($globalTimezone); |
| 61 | - if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 62 | - elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 63 | - else $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 69 | + if ($type == 'marine') { |
|
| 70 | + $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 71 | + } elseif ($type == 'tracker') { |
|
| 72 | + $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 73 | + } else { |
|
| 74 | + $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
| 75 | + } |
|
| 64 | 76 | |
| 65 | 77 | require_once('header.php'); |
| 66 | 78 | print '<div class="select-item">'; |
@@ -78,15 +90,24 @@ discard block |
||
| 78 | 90 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
| 79 | 91 | print '<br />'; |
| 80 | 92 | print '<div class="info column">'; |
| 81 | - if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
| 82 | - else print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
| 93 | + if ($type == 'marine') { |
|
| 94 | + print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
| 95 | + } else { |
|
| 96 | + print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
| 97 | + } |
|
| 83 | 98 | print '</div>'; |
| 84 | 99 | |
| 85 | - if ($type == 'aircraft') include('date-sub-menu.php'); |
|
| 100 | + if ($type == 'aircraft') { |
|
| 101 | + include('date-sub-menu.php'); |
|
| 102 | + } |
|
| 86 | 103 | print '<div class="table column">'; |
| 87 | - if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 88 | - elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 89 | - else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 104 | + if ($type == 'marine') { |
|
| 105 | + print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 106 | + } elseif ($type == 'tracker') { |
|
| 107 | + print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 108 | + } else { |
|
| 109 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
| 110 | + } |
|
| 90 | 111 | |
| 91 | 112 | include('table-output.php'); |
| 92 | 113 | print '<div class="pagination">'; |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | require_once('header.php'); |
| 24 | 24 | |
| 25 | 25 | //calculuation for the pagination |
| 26 | -if(!isset($_GET['limit'])) |
|
| 26 | +if (!isset($_GET['limit'])) |
|
| 27 | 27 | { |
| 28 | 28 | $limit_start = 0; |
| 29 | 29 | $limit_end = 25; |
| 30 | 30 | $absolute_difference = 25; |
| 31 | -} else { |
|
| 31 | +} else { |
|
| 32 | 32 | $limit_explode = explode(",", $_GET['limit']); |
| 33 | 33 | $limit_start = $limit_explode[0]; |
| 34 | 34 | $limit_end = $limit_explode[1]; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>'; |
| 52 | 52 | else print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>'; |
| 53 | 53 | |
| 54 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 54 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 55 | 55 | $sql_begin = microtime(true); |
| 56 | 56 | if ($type == 'marine') { |
| 57 | 57 | $spotter_array = $Marine->getLatestMarineData($limit_start.",".$absolute_difference, $sort); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } else { |
| 61 | 61 | $spotter_array = $Spotter->getLatestSpotterData($limit_start.",".$absolute_difference, $sort); |
| 62 | 62 | } |
| 63 | -$sql_time = microtime(true)-$sql_begin; |
|
| 63 | +$sql_time = microtime(true) - $sql_begin; |
|
| 64 | 64 | $page_begin = microtime(true); |
| 65 | 65 | if (!empty($spotter_array)) |
| 66 | 66 | { |
@@ -77,6 +77,6 @@ discard block |
||
| 77 | 77 | print '</div>'; |
| 78 | 78 | print '</div>'; |
| 79 | 79 | } |
| 80 | -$page_time = microtime(true)-$page_begin; |
|
| 80 | +$page_time = microtime(true) - $page_begin; |
|
| 81 | 81 | require_once('footer.php'); |
| 82 | 82 | ?> |
| 83 | 83 | \ No newline at end of file |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $limit_start = 0; |
| 29 | 29 | $limit_end = 25; |
| 30 | 30 | $absolute_difference = 25; |
| 31 | -} else { |
|
| 31 | +} else { |
|
| 32 | 32 | $limit_explode = explode(",", $_GET['limit']); |
| 33 | 33 | $limit_start = $limit_explode[0]; |
| 34 | 34 | $limit_end = $limit_explode[1]; |
@@ -47,9 +47,13 @@ discard block |
||
| 47 | 47 | print '<h1>'._("Latest Activity").'</h1>'; |
| 48 | 48 | print '</div>'; |
| 49 | 49 | print '<div class="table column">'; |
| 50 | -if ($type == 'marine') print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>'; |
|
| 51 | -elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>'; |
|
| 52 | -else print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>'; |
|
| 50 | +if ($type == 'marine') { |
|
| 51 | + print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>'; |
|
| 52 | +} elseif ($type == 'tracker') { |
|
| 53 | + print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>'; |
|
| 54 | +} else { |
|
| 55 | + print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>'; |
|
| 56 | +} |
|
| 53 | 57 | |
| 54 | 58 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
| 55 | 59 | $sql_begin = microtime(true); |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | /** |
| 15 | 15 | * Get SQL query part for filter used |
| 16 | 16 | * @param Array $filter the filter |
| 17 | - * @return Array the SQL part |
|
| 17 | + * @return string the SQL part |
|
| 18 | 18 | */ |
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -9,10 +9,10 @@ discard block |
||
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | - * Get SQL query part for filter used |
|
| 13 | - * @param Array $filter the filter |
|
| 14 | - * @return Array the SQL part |
|
| 15 | - */ |
|
| 12 | + * Get SQL query part for filter used |
|
| 13 | + * @param Array $filter the filter |
|
| 14 | + * @return Array the SQL part |
|
| 15 | + */ |
|
| 16 | 16 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 18 | 18 | $filters = array(); |
@@ -108,44 +108,44 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * Gets all the spotter information based on a particular callsign |
|
| 113 | - * |
|
| 114 | - * @return Array the spotter information |
|
| 115 | - * |
|
| 116 | - */ |
|
| 117 | - public function getLastArchiveTrackerDataByIdent($ident) |
|
| 118 | - { |
|
| 111 | + /** |
|
| 112 | + * Gets all the spotter information based on a particular callsign |
|
| 113 | + * |
|
| 114 | + * @return Array the spotter information |
|
| 115 | + * |
|
| 116 | + */ |
|
| 117 | + public function getLastArchiveTrackerDataByIdent($ident) |
|
| 118 | + { |
|
| 119 | 119 | $Tracker = new Tracker($this->db); |
| 120 | - date_default_timezone_set('UTC'); |
|
| 120 | + date_default_timezone_set('UTC'); |
|
| 121 | 121 | |
| 122 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 123 | - //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 124 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 122 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 123 | + //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 124 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 125 | 125 | |
| 126 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
| 126 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
| 127 | 127 | |
| 128 | - return $spotter_array; |
|
| 129 | - } |
|
| 128 | + return $spotter_array; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * Gets last the spotter information based on a particular id |
|
| 134 | - * |
|
| 135 | - * @return Array the spotter information |
|
| 136 | - * |
|
| 137 | - */ |
|
| 138 | - public function getLastArchiveTrackerDataById($id) |
|
| 139 | - { |
|
| 140 | - $Tracker = new Tracker($this->db); |
|
| 141 | - date_default_timezone_set('UTC'); |
|
| 142 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 143 | - //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
| 144 | - //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 145 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 132 | + /** |
|
| 133 | + * Gets last the spotter information based on a particular id |
|
| 134 | + * |
|
| 135 | + * @return Array the spotter information |
|
| 136 | + * |
|
| 137 | + */ |
|
| 138 | + public function getLastArchiveTrackerDataById($id) |
|
| 139 | + { |
|
| 140 | + $Tracker = new Tracker($this->db); |
|
| 141 | + date_default_timezone_set('UTC'); |
|
| 142 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 143 | + //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
| 144 | + //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 145 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 146 | 146 | |
| 147 | 147 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 148 | - /* |
|
| 148 | + /* |
|
| 149 | 149 | try { |
| 150 | 150 | $Connection = new Connection(); |
| 151 | 151 | $sth = Connection->$db->prepare($query); |
@@ -155,232 +155,232 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 157 | 157 | */ |
| 158 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
| 159 | - |
|
| 160 | - return $spotter_array; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Gets all the spotter information based on a particular id |
|
| 165 | - * |
|
| 166 | - * @return Array the spotter information |
|
| 167 | - * |
|
| 168 | - */ |
|
| 169 | - public function getAllArchiveTrackerDataById($id) |
|
| 158 | + $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
| 159 | + |
|
| 160 | + return $spotter_array; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Gets all the spotter information based on a particular id |
|
| 165 | + * |
|
| 166 | + * @return Array the spotter information |
|
| 167 | + * |
|
| 168 | + */ |
|
| 169 | + public function getAllArchiveTrackerDataById($id) |
|
| 170 | 170 | { |
| 171 | - date_default_timezone_set('UTC'); |
|
| 172 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 173 | - $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 171 | + date_default_timezone_set('UTC'); |
|
| 172 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 173 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 174 | 174 | |
| 175 | 175 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 176 | 176 | |
| 177 | - try { |
|
| 178 | - $sth = $this->db->prepare($query); |
|
| 179 | - $sth->execute(array(':id' => $id)); |
|
| 180 | - } catch(PDOException $e) { |
|
| 181 | - echo $e->getMessage(); |
|
| 182 | - die; |
|
| 183 | - } |
|
| 184 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 185 | - |
|
| 186 | - return $spotter_array; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Gets coordinate & time spotter information based on a particular id |
|
| 191 | - * |
|
| 192 | - * @return Array the spotter information |
|
| 193 | - * |
|
| 194 | - */ |
|
| 195 | - public function getCoordArchiveTrackerDataById($id) |
|
| 196 | - { |
|
| 197 | - date_default_timezone_set('UTC'); |
|
| 198 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 199 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 177 | + try { |
|
| 178 | + $sth = $this->db->prepare($query); |
|
| 179 | + $sth->execute(array(':id' => $id)); |
|
| 180 | + } catch(PDOException $e) { |
|
| 181 | + echo $e->getMessage(); |
|
| 182 | + die; |
|
| 183 | + } |
|
| 184 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 185 | + |
|
| 186 | + return $spotter_array; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Gets coordinate & time spotter information based on a particular id |
|
| 191 | + * |
|
| 192 | + * @return Array the spotter information |
|
| 193 | + * |
|
| 194 | + */ |
|
| 195 | + public function getCoordArchiveTrackerDataById($id) |
|
| 196 | + { |
|
| 197 | + date_default_timezone_set('UTC'); |
|
| 198 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 199 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 200 | 200 | |
| 201 | 201 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 202 | 202 | |
| 203 | - try { |
|
| 204 | - $sth = $this->db->prepare($query); |
|
| 205 | - $sth->execute(array(':id' => $id)); |
|
| 206 | - } catch(PDOException $e) { |
|
| 207 | - echo $e->getMessage(); |
|
| 208 | - die; |
|
| 209 | - } |
|
| 210 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 203 | + try { |
|
| 204 | + $sth = $this->db->prepare($query); |
|
| 205 | + $sth->execute(array(':id' => $id)); |
|
| 206 | + } catch(PDOException $e) { |
|
| 207 | + echo $e->getMessage(); |
|
| 208 | + die; |
|
| 209 | + } |
|
| 210 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 211 | 211 | |
| 212 | - return $spotter_array; |
|
| 213 | - } |
|
| 212 | + return $spotter_array; |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | 215 | |
| 216 | - /** |
|
| 217 | - * Gets altitude information based on a particular callsign |
|
| 218 | - * |
|
| 219 | - * @return Array the spotter information |
|
| 220 | - * |
|
| 221 | - */ |
|
| 222 | - public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
| 223 | - { |
|
| 216 | + /** |
|
| 217 | + * Gets altitude information based on a particular callsign |
|
| 218 | + * |
|
| 219 | + * @return Array the spotter information |
|
| 220 | + * |
|
| 221 | + */ |
|
| 222 | + public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
| 223 | + { |
|
| 224 | 224 | |
| 225 | - date_default_timezone_set('UTC'); |
|
| 225 | + date_default_timezone_set('UTC'); |
|
| 226 | 226 | |
| 227 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 228 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 227 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 228 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 229 | 229 | |
| 230 | - try { |
|
| 231 | - $sth = $this->db->prepare($query); |
|
| 232 | - $sth->execute(array(':ident' => $ident)); |
|
| 233 | - } catch(PDOException $e) { |
|
| 234 | - echo $e->getMessage(); |
|
| 235 | - die; |
|
| 236 | - } |
|
| 237 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 230 | + try { |
|
| 231 | + $sth = $this->db->prepare($query); |
|
| 232 | + $sth->execute(array(':ident' => $ident)); |
|
| 233 | + } catch(PDOException $e) { |
|
| 234 | + echo $e->getMessage(); |
|
| 235 | + die; |
|
| 236 | + } |
|
| 237 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 238 | 238 | |
| 239 | - return $spotter_array; |
|
| 240 | - } |
|
| 239 | + return $spotter_array; |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - /** |
|
| 243 | - * Gets altitude information based on a particular id |
|
| 244 | - * |
|
| 245 | - * @return Array the spotter information |
|
| 246 | - * |
|
| 247 | - */ |
|
| 248 | - public function getAltitudeArchiveTrackerDataById($id) |
|
| 249 | - { |
|
| 242 | + /** |
|
| 243 | + * Gets altitude information based on a particular id |
|
| 244 | + * |
|
| 245 | + * @return Array the spotter information |
|
| 246 | + * |
|
| 247 | + */ |
|
| 248 | + public function getAltitudeArchiveTrackerDataById($id) |
|
| 249 | + { |
|
| 250 | 250 | |
| 251 | - date_default_timezone_set('UTC'); |
|
| 251 | + date_default_timezone_set('UTC'); |
|
| 252 | 252 | |
| 253 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 254 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 253 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 254 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 255 | 255 | |
| 256 | - try { |
|
| 257 | - $sth = $this->db->prepare($query); |
|
| 258 | - $sth->execute(array(':id' => $id)); |
|
| 259 | - } catch(PDOException $e) { |
|
| 260 | - echo $e->getMessage(); |
|
| 261 | - die; |
|
| 262 | - } |
|
| 263 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 256 | + try { |
|
| 257 | + $sth = $this->db->prepare($query); |
|
| 258 | + $sth->execute(array(':id' => $id)); |
|
| 259 | + } catch(PDOException $e) { |
|
| 260 | + echo $e->getMessage(); |
|
| 261 | + die; |
|
| 262 | + } |
|
| 263 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 264 | 264 | |
| 265 | - return $spotter_array; |
|
| 266 | - } |
|
| 265 | + return $spotter_array; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * Gets altitude & speed information based on a particular id |
|
| 270 | - * |
|
| 271 | - * @return Array the spotter information |
|
| 272 | - * |
|
| 273 | - */ |
|
| 274 | - public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
| 275 | - { |
|
| 268 | + /** |
|
| 269 | + * Gets altitude & speed information based on a particular id |
|
| 270 | + * |
|
| 271 | + * @return Array the spotter information |
|
| 272 | + * |
|
| 273 | + */ |
|
| 274 | + public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
| 275 | + { |
|
| 276 | 276 | |
| 277 | - date_default_timezone_set('UTC'); |
|
| 277 | + date_default_timezone_set('UTC'); |
|
| 278 | 278 | |
| 279 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 280 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 279 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
| 280 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 281 | 281 | |
| 282 | - try { |
|
| 283 | - $sth = $this->db->prepare($query); |
|
| 284 | - $sth->execute(array(':id' => $id)); |
|
| 285 | - } catch(PDOException $e) { |
|
| 286 | - echo $e->getMessage(); |
|
| 287 | - die; |
|
| 288 | - } |
|
| 289 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 282 | + try { |
|
| 283 | + $sth = $this->db->prepare($query); |
|
| 284 | + $sth->execute(array(':id' => $id)); |
|
| 285 | + } catch(PDOException $e) { |
|
| 286 | + echo $e->getMessage(); |
|
| 287 | + die; |
|
| 288 | + } |
|
| 289 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 290 | 290 | |
| 291 | - return $spotter_array; |
|
| 292 | - } |
|
| 291 | + return $spotter_array; |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | 294 | |
| 295 | - /** |
|
| 296 | - * Gets altitude information based on a particular callsign |
|
| 297 | - * |
|
| 298 | - * @return Array the spotter information |
|
| 299 | - * |
|
| 300 | - */ |
|
| 301 | - public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
| 302 | - { |
|
| 295 | + /** |
|
| 296 | + * Gets altitude information based on a particular callsign |
|
| 297 | + * |
|
| 298 | + * @return Array the spotter information |
|
| 299 | + * |
|
| 300 | + */ |
|
| 301 | + public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
| 302 | + { |
|
| 303 | 303 | |
| 304 | - date_default_timezone_set('UTC'); |
|
| 304 | + date_default_timezone_set('UTC'); |
|
| 305 | 305 | |
| 306 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 307 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 306 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 307 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 308 | 308 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
| 309 | 309 | |
| 310 | - try { |
|
| 311 | - $sth = $this->db->prepare($query); |
|
| 312 | - $sth->execute(array(':ident' => $ident)); |
|
| 313 | - } catch(PDOException $e) { |
|
| 314 | - echo $e->getMessage(); |
|
| 315 | - die; |
|
| 316 | - } |
|
| 317 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 310 | + try { |
|
| 311 | + $sth = $this->db->prepare($query); |
|
| 312 | + $sth->execute(array(':ident' => $ident)); |
|
| 313 | + } catch(PDOException $e) { |
|
| 314 | + echo $e->getMessage(); |
|
| 315 | + die; |
|
| 316 | + } |
|
| 317 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 318 | 318 | |
| 319 | - return $spotter_array; |
|
| 320 | - } |
|
| 319 | + return $spotter_array; |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | 322 | |
| 323 | 323 | |
| 324 | - /** |
|
| 325 | - * Gets all the archive spotter information |
|
| 326 | - * |
|
| 327 | - * @return Array the spotter information |
|
| 328 | - * |
|
| 329 | - */ |
|
| 330 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
| 331 | - { |
|
| 332 | - $Tracker = new Tracker($this->db); |
|
| 333 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 334 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 324 | + /** |
|
| 325 | + * Gets all the archive spotter information |
|
| 326 | + * |
|
| 327 | + * @return Array the spotter information |
|
| 328 | + * |
|
| 329 | + */ |
|
| 330 | + public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
| 331 | + { |
|
| 332 | + $Tracker = new Tracker($this->db); |
|
| 333 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 334 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 335 | 335 | |
| 336 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
| 336 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
| 337 | 337 | |
| 338 | - return $spotter_array; |
|
| 339 | - } |
|
| 338 | + return $spotter_array; |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | - public function deleteTrackerArchiveTrackData() |
|
| 342 | - { |
|
| 341 | + public function deleteTrackerArchiveTrackData() |
|
| 342 | + { |
|
| 343 | 343 | global $globalArchiveKeepTrackMonths; |
| 344 | - date_default_timezone_set('UTC'); |
|
| 344 | + date_default_timezone_set('UTC'); |
|
| 345 | 345 | $query = 'DELETE FROM tracker_archive WHERE tracker_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
| 346 | - try { |
|
| 347 | - $sth = $this->db->prepare($query); |
|
| 348 | - $sth->execute(); |
|
| 349 | - } catch(PDOException $e) { |
|
| 350 | - echo $e->getMessage(); |
|
| 351 | - die; |
|
| 352 | - } |
|
| 346 | + try { |
|
| 347 | + $sth = $this->db->prepare($query); |
|
| 348 | + $sth->execute(); |
|
| 349 | + } catch(PDOException $e) { |
|
| 350 | + echo $e->getMessage(); |
|
| 351 | + die; |
|
| 352 | + } |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | /** |
| 356 | - * Gets Minimal Live Tracker data |
|
| 357 | - * |
|
| 358 | - * @return Array the spotter information |
|
| 359 | - * |
|
| 360 | - */ |
|
| 361 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
| 362 | - { |
|
| 363 | - global $globalDBdriver, $globalLiveInterval; |
|
| 364 | - date_default_timezone_set('UTC'); |
|
| 365 | - |
|
| 366 | - $filter_query = ''; |
|
| 367 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 368 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 369 | - } |
|
| 370 | - // Use spotter_output also ? |
|
| 371 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 372 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 373 | - } |
|
| 374 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 375 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 376 | - } |
|
| 377 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 378 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 379 | - } |
|
| 356 | + * Gets Minimal Live Tracker data |
|
| 357 | + * |
|
| 358 | + * @return Array the spotter information |
|
| 359 | + * |
|
| 360 | + */ |
|
| 361 | + public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
| 362 | + { |
|
| 363 | + global $globalDBdriver, $globalLiveInterval; |
|
| 364 | + date_default_timezone_set('UTC'); |
|
| 365 | + |
|
| 366 | + $filter_query = ''; |
|
| 367 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 368 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 369 | + } |
|
| 370 | + // Use spotter_output also ? |
|
| 371 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 372 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 373 | + } |
|
| 374 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 375 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 376 | + } |
|
| 377 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 378 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 382 | - if ($globalDBdriver == 'mysql') { |
|
| 383 | - /* |
|
| 381 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 382 | + if ($globalDBdriver == 'mysql') { |
|
| 383 | + /* |
|
| 384 | 384 | $query = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk |
| 385 | 385 | FROM tracker_archive |
| 386 | 386 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
@@ -399,56 +399,56 @@ discard block |
||
| 399 | 399 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 400 | 400 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 401 | 401 | '.$filter_query.' ORDER BY famtrackid'; |
| 402 | - } else { |
|
| 403 | - //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
|
| 404 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 402 | + } else { |
|
| 403 | + //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
|
| 404 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 405 | 405 | FROM tracker_archive |
| 406 | 406 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 407 | 407 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
| 408 | 408 | '.$filter_query.' ORDER BY famtrackid'; |
| 409 | - } |
|
| 410 | - //echo $query; |
|
| 411 | - try { |
|
| 412 | - $sth = $this->db->prepare($query); |
|
| 413 | - $sth->execute(); |
|
| 414 | - } catch(PDOException $e) { |
|
| 415 | - echo $e->getMessage(); |
|
| 416 | - die; |
|
| 417 | - } |
|
| 418 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 409 | + } |
|
| 410 | + //echo $query; |
|
| 411 | + try { |
|
| 412 | + $sth = $this->db->prepare($query); |
|
| 413 | + $sth->execute(); |
|
| 414 | + } catch(PDOException $e) { |
|
| 415 | + echo $e->getMessage(); |
|
| 416 | + die; |
|
| 417 | + } |
|
| 418 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 419 | 419 | |
| 420 | - return $spotter_array; |
|
| 421 | - } |
|
| 420 | + return $spotter_array; |
|
| 421 | + } |
|
| 422 | 422 | |
| 423 | 423 | /** |
| 424 | - * Gets Minimal Live Tracker data |
|
| 425 | - * |
|
| 426 | - * @return Array the spotter information |
|
| 427 | - * |
|
| 428 | - */ |
|
| 429 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
| 430 | - { |
|
| 431 | - global $globalDBdriver, $globalLiveInterval; |
|
| 432 | - date_default_timezone_set('UTC'); |
|
| 433 | - |
|
| 434 | - $filter_query = ''; |
|
| 435 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 436 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 437 | - } |
|
| 438 | - // Should use spotter_output also ? |
|
| 439 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 440 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 441 | - } |
|
| 442 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 443 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 444 | - } |
|
| 445 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 446 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 447 | - } |
|
| 424 | + * Gets Minimal Live Tracker data |
|
| 425 | + * |
|
| 426 | + * @return Array the spotter information |
|
| 427 | + * |
|
| 428 | + */ |
|
| 429 | + public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
| 430 | + { |
|
| 431 | + global $globalDBdriver, $globalLiveInterval; |
|
| 432 | + date_default_timezone_set('UTC'); |
|
| 433 | + |
|
| 434 | + $filter_query = ''; |
|
| 435 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 436 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 437 | + } |
|
| 438 | + // Should use spotter_output also ? |
|
| 439 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 440 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 441 | + } |
|
| 442 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 443 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 444 | + } |
|
| 445 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 446 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 447 | + } |
|
| 448 | 448 | |
| 449 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 450 | - if ($globalDBdriver == 'mysql') { |
|
| 451 | - /* |
|
| 449 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 450 | + if ($globalDBdriver == 'mysql') { |
|
| 451 | + /* |
|
| 452 | 452 | $query = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk |
| 453 | 453 | FROM tracker_archive |
| 454 | 454 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
@@ -459,95 +459,95 @@ discard block |
||
| 459 | 459 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
| 460 | 460 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
| 461 | 461 | |
| 462 | - } else { |
|
| 463 | - //$query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao'; |
|
| 464 | - /* |
|
| 462 | + } else { |
|
| 463 | + //$query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao'; |
|
| 464 | + /* |
|
| 465 | 465 | $query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
| 466 | 466 | FROM tracker_archive_output |
| 467 | 467 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
| 468 | 468 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
| 469 | 469 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
| 470 | 470 | */ |
| 471 | - $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 471 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 472 | 472 | FROM tracker_archive_output |
| 473 | 473 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
| 474 | 474 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
| 475 | 475 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
| 476 | 476 | // .' GROUP BY spotter_output.famtrackid, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
| 477 | 477 | |
| 478 | - } |
|
| 479 | - //echo $query; |
|
| 480 | - try { |
|
| 481 | - $sth = $this->db->prepare($query); |
|
| 482 | - $sth->execute(); |
|
| 483 | - } catch(PDOException $e) { |
|
| 484 | - echo $e->getMessage(); |
|
| 485 | - die; |
|
| 486 | - } |
|
| 487 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 478 | + } |
|
| 479 | + //echo $query; |
|
| 480 | + try { |
|
| 481 | + $sth = $this->db->prepare($query); |
|
| 482 | + $sth->execute(); |
|
| 483 | + } catch(PDOException $e) { |
|
| 484 | + echo $e->getMessage(); |
|
| 485 | + die; |
|
| 486 | + } |
|
| 487 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
| 488 | 488 | |
| 489 | - return $spotter_array; |
|
| 490 | - } |
|
| 489 | + return $spotter_array; |
|
| 490 | + } |
|
| 491 | 491 | |
| 492 | 492 | /** |
| 493 | - * Gets count Live Tracker data |
|
| 494 | - * |
|
| 495 | - * @return Array the spotter information |
|
| 496 | - * |
|
| 497 | - */ |
|
| 498 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
| 499 | - { |
|
| 500 | - global $globalDBdriver, $globalLiveInterval; |
|
| 501 | - date_default_timezone_set('UTC'); |
|
| 502 | - |
|
| 503 | - $filter_query = ''; |
|
| 504 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 505 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 506 | - } |
|
| 507 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 508 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 509 | - } |
|
| 510 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 511 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 512 | - } |
|
| 513 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 514 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 515 | - } |
|
| 493 | + * Gets count Live Tracker data |
|
| 494 | + * |
|
| 495 | + * @return Array the spotter information |
|
| 496 | + * |
|
| 497 | + */ |
|
| 498 | + public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
| 499 | + { |
|
| 500 | + global $globalDBdriver, $globalLiveInterval; |
|
| 501 | + date_default_timezone_set('UTC'); |
|
| 516 | 502 | |
| 517 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 518 | - if ($globalDBdriver == 'mysql') { |
|
| 503 | + $filter_query = ''; |
|
| 504 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
| 505 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 506 | + } |
|
| 507 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
| 508 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 509 | + } |
|
| 510 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
| 511 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
| 512 | + } |
|
| 513 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
| 514 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 515 | + } |
|
| 516 | + |
|
| 517 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 518 | + if ($globalDBdriver == 'mysql') { |
|
| 519 | 519 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb |
| 520 | 520 | FROM tracker_archive l |
| 521 | 521 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
| 522 | - } else { |
|
| 522 | + } else { |
|
| 523 | 523 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
| 524 | - } |
|
| 525 | - //echo $query; |
|
| 526 | - try { |
|
| 527 | - $sth = $this->db->prepare($query); |
|
| 528 | - $sth->execute(); |
|
| 529 | - } catch(PDOException $e) { |
|
| 530 | - echo $e->getMessage(); |
|
| 531 | - die; |
|
| 532 | - } |
|
| 524 | + } |
|
| 525 | + //echo $query; |
|
| 526 | + try { |
|
| 527 | + $sth = $this->db->prepare($query); |
|
| 528 | + $sth->execute(); |
|
| 529 | + } catch(PDOException $e) { |
|
| 530 | + echo $e->getMessage(); |
|
| 531 | + die; |
|
| 532 | + } |
|
| 533 | 533 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 534 | 534 | $sth->closeCursor(); |
| 535 | - return $result['nb']; |
|
| 535 | + return $result['nb']; |
|
| 536 | 536 | |
| 537 | - } |
|
| 537 | + } |
|
| 538 | 538 | |
| 539 | 539 | |
| 540 | 540 | |
| 541 | 541 | // tracker_archive_output |
| 542 | 542 | |
| 543 | - /** |
|
| 544 | - * Gets all the spotter information |
|
| 545 | - * |
|
| 546 | - * @return Array the spotter information |
|
| 547 | - * |
|
| 548 | - */ |
|
| 549 | - public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 550 | - { |
|
| 543 | + /** |
|
| 544 | + * Gets all the spotter information |
|
| 545 | + * |
|
| 546 | + * @return Array the spotter information |
|
| 547 | + * |
|
| 548 | + */ |
|
| 549 | + public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 550 | + { |
|
| 551 | 551 | global $globalTimezone, $globalDBdriver; |
| 552 | 552 | require_once(dirname(__FILE__).'/class.Translation.php'); |
| 553 | 553 | $Translation = new Translation(); |
@@ -561,159 +561,159 @@ discard block |
||
| 561 | 561 | $filter_query = $this->getFilter($filters); |
| 562 | 562 | if ($q != "") |
| 563 | 563 | { |
| 564 | - if (!is_string($q)) |
|
| 565 | - { |
|
| 564 | + if (!is_string($q)) |
|
| 565 | + { |
|
| 566 | 566 | return false; |
| 567 | - } else { |
|
| 567 | + } else { |
|
| 568 | 568 | |
| 569 | 569 | $q_array = explode(" ", $q); |
| 570 | 570 | |
| 571 | 571 | foreach ($q_array as $q_item){ |
| 572 | - $additional_query .= " AND ("; |
|
| 573 | - $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 574 | - $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 575 | - $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 576 | - $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 577 | - $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 578 | - $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 579 | - $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 580 | - $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 581 | - $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 582 | - $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 583 | - $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 584 | - $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 585 | - $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 586 | - $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 587 | - $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 588 | - $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
| 589 | - $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 590 | - $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 591 | - $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 592 | - $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
| 593 | - $translate = $Translation->ident2icao($q_item); |
|
| 594 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 595 | - $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
| 596 | - $additional_query .= ")"; |
|
| 572 | + $additional_query .= " AND ("; |
|
| 573 | + $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
| 574 | + $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
| 575 | + $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
| 576 | + $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
| 577 | + $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
| 578 | + $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
| 579 | + $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
| 580 | + $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
| 581 | + $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
| 582 | + $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
| 583 | + $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
| 584 | + $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
| 585 | + $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
| 586 | + $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
| 587 | + $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
| 588 | + $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
| 589 | + $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
| 590 | + $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
| 591 | + $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
| 592 | + $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
| 593 | + $translate = $Translation->ident2icao($q_item); |
|
| 594 | + if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 595 | + $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
| 596 | + $additional_query .= ")"; |
|
| 597 | + } |
|
| 597 | 598 | } |
| 598 | - } |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | if ($registration != "") |
| 602 | 602 | { |
| 603 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 604 | - if (!is_string($registration)) |
|
| 605 | - { |
|
| 603 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 604 | + if (!is_string($registration)) |
|
| 605 | + { |
|
| 606 | 606 | return false; |
| 607 | - } else { |
|
| 607 | + } else { |
|
| 608 | 608 | $additional_query .= " AND (tracker_archive_output.registration = '".$registration."')"; |
| 609 | - } |
|
| 609 | + } |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | if ($aircraft_icao != "") |
| 613 | 613 | { |
| 614 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 615 | - if (!is_string($aircraft_icao)) |
|
| 616 | - { |
|
| 614 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 615 | + if (!is_string($aircraft_icao)) |
|
| 616 | + { |
|
| 617 | 617 | return false; |
| 618 | - } else { |
|
| 618 | + } else { |
|
| 619 | 619 | $additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
| 620 | - } |
|
| 620 | + } |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | if ($aircraft_manufacturer != "") |
| 624 | 624 | { |
| 625 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 626 | - if (!is_string($aircraft_manufacturer)) |
|
| 627 | - { |
|
| 625 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 626 | + if (!is_string($aircraft_manufacturer)) |
|
| 627 | + { |
|
| 628 | 628 | return false; |
| 629 | - } else { |
|
| 629 | + } else { |
|
| 630 | 630 | $additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
| 631 | - } |
|
| 631 | + } |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | if ($highlights == "true") |
| 635 | 635 | { |
| 636 | - if (!is_string($highlights)) |
|
| 637 | - { |
|
| 636 | + if (!is_string($highlights)) |
|
| 637 | + { |
|
| 638 | 638 | return false; |
| 639 | - } else { |
|
| 639 | + } else { |
|
| 640 | 640 | $additional_query .= " AND (tracker_archive_output.highlight <> '')"; |
| 641 | - } |
|
| 641 | + } |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | if ($airline_icao != "") |
| 645 | 645 | { |
| 646 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 647 | - if (!is_string($airline_icao)) |
|
| 648 | - { |
|
| 646 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 647 | + if (!is_string($airline_icao)) |
|
| 648 | + { |
|
| 649 | 649 | return false; |
| 650 | - } else { |
|
| 650 | + } else { |
|
| 651 | 651 | $additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')"; |
| 652 | - } |
|
| 652 | + } |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | if ($airline_country != "") |
| 656 | 656 | { |
| 657 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 658 | - if (!is_string($airline_country)) |
|
| 659 | - { |
|
| 657 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 658 | + if (!is_string($airline_country)) |
|
| 659 | + { |
|
| 660 | 660 | return false; |
| 661 | - } else { |
|
| 661 | + } else { |
|
| 662 | 662 | $additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')"; |
| 663 | - } |
|
| 663 | + } |
|
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | if ($airline_type != "") |
| 667 | 667 | { |
| 668 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 669 | - if (!is_string($airline_type)) |
|
| 670 | - { |
|
| 668 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 669 | + if (!is_string($airline_type)) |
|
| 670 | + { |
|
| 671 | 671 | return false; |
| 672 | - } else { |
|
| 672 | + } else { |
|
| 673 | 673 | if ($airline_type == "passenger") |
| 674 | 674 | { |
| 675 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
| 675 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
| 676 | 676 | } |
| 677 | 677 | if ($airline_type == "cargo") |
| 678 | 678 | { |
| 679 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
| 679 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
| 680 | 680 | } |
| 681 | 681 | if ($airline_type == "military") |
| 682 | 682 | { |
| 683 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
| 683 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
| 684 | + } |
|
| 684 | 685 | } |
| 685 | - } |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | if ($airport != "") |
| 689 | 689 | { |
| 690 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 691 | - if (!is_string($airport)) |
|
| 692 | - { |
|
| 690 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 691 | + if (!is_string($airport)) |
|
| 692 | + { |
|
| 693 | 693 | return false; |
| 694 | - } else { |
|
| 694 | + } else { |
|
| 695 | 695 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))"; |
| 696 | - } |
|
| 696 | + } |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | if ($airport_country != "") |
| 700 | 700 | { |
| 701 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 702 | - if (!is_string($airport_country)) |
|
| 703 | - { |
|
| 701 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 702 | + if (!is_string($airport_country)) |
|
| 703 | + { |
|
| 704 | 704 | return false; |
| 705 | - } else { |
|
| 705 | + } else { |
|
| 706 | 706 | $additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))"; |
| 707 | - } |
|
| 707 | + } |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | if ($callsign != "") |
| 711 | 711 | { |
| 712 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 713 | - if (!is_string($callsign)) |
|
| 714 | - { |
|
| 712 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 713 | + if (!is_string($callsign)) |
|
| 714 | + { |
|
| 715 | 715 | return false; |
| 716 | - } else { |
|
| 716 | + } else { |
|
| 717 | 717 | $translate = $Translation->ident2icao($callsign); |
| 718 | 718 | if ($translate != $callsign) { |
| 719 | 719 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
@@ -721,99 +721,99 @@ discard block |
||
| 721 | 721 | } else { |
| 722 | 722 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
| 723 | 723 | } |
| 724 | - } |
|
| 724 | + } |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | if ($owner != "") |
| 728 | 728 | { |
| 729 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 730 | - if (!is_string($owner)) |
|
| 731 | - { |
|
| 729 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 730 | + if (!is_string($owner)) |
|
| 731 | + { |
|
| 732 | 732 | return false; |
| 733 | - } else { |
|
| 733 | + } else { |
|
| 734 | 734 | $additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')"; |
| 735 | - } |
|
| 735 | + } |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | if ($pilot_name != "") |
| 739 | 739 | { |
| 740 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 741 | - if (!is_string($pilot_name)) |
|
| 742 | - { |
|
| 740 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 741 | + if (!is_string($pilot_name)) |
|
| 742 | + { |
|
| 743 | 743 | return false; |
| 744 | - } else { |
|
| 744 | + } else { |
|
| 745 | 745 | $additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')"; |
| 746 | - } |
|
| 746 | + } |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | if ($pilot_id != "") |
| 750 | 750 | { |
| 751 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 752 | - if (!is_string($pilot_id)) |
|
| 753 | - { |
|
| 751 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 752 | + if (!is_string($pilot_id)) |
|
| 753 | + { |
|
| 754 | 754 | return false; |
| 755 | - } else { |
|
| 755 | + } else { |
|
| 756 | 756 | $additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')"; |
| 757 | - } |
|
| 757 | + } |
|
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | if ($departure_airport_route != "") |
| 761 | 761 | { |
| 762 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 763 | - if (!is_string($departure_airport_route)) |
|
| 764 | - { |
|
| 762 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 763 | + if (!is_string($departure_airport_route)) |
|
| 764 | + { |
|
| 765 | 765 | return false; |
| 766 | - } else { |
|
| 766 | + } else { |
|
| 767 | 767 | $additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
| 768 | - } |
|
| 768 | + } |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | if ($arrival_airport_route != "") |
| 772 | 772 | { |
| 773 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 774 | - if (!is_string($arrival_airport_route)) |
|
| 775 | - { |
|
| 773 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 774 | + if (!is_string($arrival_airport_route)) |
|
| 775 | + { |
|
| 776 | 776 | return false; |
| 777 | - } else { |
|
| 777 | + } else { |
|
| 778 | 778 | $additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
| 779 | - } |
|
| 779 | + } |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | if ($altitude != "") |
| 783 | 783 | { |
| 784 | - $altitude_array = explode(",", $altitude); |
|
| 784 | + $altitude_array = explode(",", $altitude); |
|
| 785 | 785 | |
| 786 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 787 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 786 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 787 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 788 | 788 | |
| 789 | 789 | |
| 790 | - if ($altitude_array[1] != "") |
|
| 791 | - { |
|
| 790 | + if ($altitude_array[1] != "") |
|
| 791 | + { |
|
| 792 | 792 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 793 | 793 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
| 794 | 794 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
| 795 | - } else { |
|
| 795 | + } else { |
|
| 796 | 796 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
| 797 | 797 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
| 798 | - } |
|
| 798 | + } |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | if ($date_posted != "") |
| 802 | 802 | { |
| 803 | - $date_array = explode(",", $date_posted); |
|
| 803 | + $date_array = explode(",", $date_posted); |
|
| 804 | 804 | |
| 805 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 806 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 805 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 806 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 807 | 807 | |
| 808 | - if ($globalTimezone != '') { |
|
| 808 | + if ($globalTimezone != '') { |
|
| 809 | 809 | date_default_timezone_set($globalTimezone); |
| 810 | 810 | $datetime = new DateTime(); |
| 811 | 811 | $offset = $datetime->format('P'); |
| 812 | - } else $offset = '+00:00'; |
|
| 812 | + } else $offset = '+00:00'; |
|
| 813 | 813 | |
| 814 | 814 | |
| 815 | - if ($date_array[1] != "") |
|
| 816 | - { |
|
| 815 | + if ($date_array[1] != "") |
|
| 816 | + { |
|
| 817 | 817 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 818 | 818 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
| 819 | 819 | if ($globalDBdriver == 'mysql') { |
@@ -821,28 +821,28 @@ discard block |
||
| 821 | 821 | } else { |
| 822 | 822 | $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
| 823 | 823 | } |
| 824 | - } else { |
|
| 824 | + } else { |
|
| 825 | 825 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
| 826 | - if ($globalDBdriver == 'mysql') { |
|
| 826 | + if ($globalDBdriver == 'mysql') { |
|
| 827 | 827 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
| 828 | 828 | } else { |
| 829 | 829 | $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
| 830 | 830 | } |
| 831 | - } |
|
| 831 | + } |
|
| 832 | 832 | } |
| 833 | 833 | |
| 834 | 834 | if ($limit != "") |
| 835 | 835 | { |
| 836 | - $limit_array = explode(",", $limit); |
|
| 836 | + $limit_array = explode(",", $limit); |
|
| 837 | 837 | |
| 838 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 839 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 838 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 839 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 840 | 840 | |
| 841 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 842 | - { |
|
| 841 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 842 | + { |
|
| 843 | 843 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 844 | 844 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 845 | - } |
|
| 845 | + } |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | |
@@ -873,33 +873,33 @@ discard block |
||
| 873 | 873 | $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
| 874 | 874 | |
| 875 | 875 | return $spotter_array; |
| 876 | - } |
|
| 876 | + } |
|
| 877 | 877 | |
| 878 | - public function deleteTrackerArchiveData() |
|
| 879 | - { |
|
| 878 | + public function deleteTrackerArchiveData() |
|
| 879 | + { |
|
| 880 | 880 | global $globalArchiveKeepMonths, $globalDBdriver; |
| 881 | - date_default_timezone_set('UTC'); |
|
| 882 | - if ($globalDBdriver == 'mysql') { |
|
| 881 | + date_default_timezone_set('UTC'); |
|
| 882 | + if ($globalDBdriver == 'mysql') { |
|
| 883 | 883 | $query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
| 884 | 884 | } else { |
| 885 | 885 | $query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
| 886 | 886 | } |
| 887 | - try { |
|
| 888 | - $sth = $this->db->prepare($query); |
|
| 889 | - $sth->execute(); |
|
| 890 | - } catch(PDOException $e) { |
|
| 891 | - return "error"; |
|
| 892 | - } |
|
| 887 | + try { |
|
| 888 | + $sth = $this->db->prepare($query); |
|
| 889 | + $sth->execute(); |
|
| 890 | + } catch(PDOException $e) { |
|
| 891 | + return "error"; |
|
| 892 | + } |
|
| 893 | 893 | } |
| 894 | 894 | |
| 895 | - /** |
|
| 896 | - * Gets all the spotter information based on the callsign |
|
| 897 | - * |
|
| 898 | - * @return Array the spotter information |
|
| 899 | - * |
|
| 900 | - */ |
|
| 901 | - public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 902 | - { |
|
| 895 | + /** |
|
| 896 | + * Gets all the spotter information based on the callsign |
|
| 897 | + * |
|
| 898 | + * @return Array the spotter information |
|
| 899 | + * |
|
| 900 | + */ |
|
| 901 | + public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
| 902 | + { |
|
| 903 | 903 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
| 904 | 904 | |
| 905 | 905 | date_default_timezone_set('UTC'); |
@@ -911,35 +911,35 @@ discard block |
||
| 911 | 911 | |
| 912 | 912 | if ($ident != "") |
| 913 | 913 | { |
| 914 | - if (!is_string($ident)) |
|
| 915 | - { |
|
| 914 | + if (!is_string($ident)) |
|
| 915 | + { |
|
| 916 | 916 | return false; |
| 917 | - } else { |
|
| 917 | + } else { |
|
| 918 | 918 | $additional_query = " AND (tracker_archive_output.ident = :ident)"; |
| 919 | 919 | $query_values = array(':ident' => $ident); |
| 920 | - } |
|
| 920 | + } |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | if ($limit != "") |
| 924 | 924 | { |
| 925 | - $limit_array = explode(",", $limit); |
|
| 925 | + $limit_array = explode(",", $limit); |
|
| 926 | 926 | |
| 927 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 928 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 927 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 928 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 929 | 929 | |
| 930 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 931 | - { |
|
| 930 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 931 | + { |
|
| 932 | 932 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 933 | 933 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 934 | - } |
|
| 934 | + } |
|
| 935 | 935 | } |
| 936 | 936 | |
| 937 | 937 | if ($sort != "") |
| 938 | 938 | { |
| 939 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
| 940 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 939 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
| 940 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 941 | 941 | } else { |
| 942 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 942 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 943 | 943 | } |
| 944 | 944 | |
| 945 | 945 | $query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -947,17 +947,17 @@ discard block |
||
| 947 | 947 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
| 948 | 948 | |
| 949 | 949 | return $spotter_array; |
| 950 | - } |
|
| 950 | + } |
|
| 951 | 951 | |
| 952 | 952 | |
| 953 | - /** |
|
| 954 | - * Gets all the spotter information based on the owner |
|
| 955 | - * |
|
| 956 | - * @return Array the spotter information |
|
| 957 | - * |
|
| 958 | - */ |
|
| 959 | - public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 960 | - { |
|
| 953 | + /** |
|
| 954 | + * Gets all the spotter information based on the owner |
|
| 955 | + * |
|
| 956 | + * @return Array the spotter information |
|
| 957 | + * |
|
| 958 | + */ |
|
| 959 | + public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
| 960 | + { |
|
| 961 | 961 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
| 962 | 962 | |
| 963 | 963 | date_default_timezone_set('UTC'); |
@@ -970,35 +970,35 @@ discard block |
||
| 970 | 970 | |
| 971 | 971 | if ($owner != "") |
| 972 | 972 | { |
| 973 | - if (!is_string($owner)) |
|
| 974 | - { |
|
| 973 | + if (!is_string($owner)) |
|
| 974 | + { |
|
| 975 | 975 | return false; |
| 976 | - } else { |
|
| 976 | + } else { |
|
| 977 | 977 | $additional_query = " AND (tracker_archive_output.owner_name = :owner)"; |
| 978 | 978 | $query_values = array(':owner' => $owner); |
| 979 | - } |
|
| 979 | + } |
|
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | if ($limit != "") |
| 983 | 983 | { |
| 984 | - $limit_array = explode(",", $limit); |
|
| 984 | + $limit_array = explode(",", $limit); |
|
| 985 | 985 | |
| 986 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 987 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 986 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 987 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 988 | 988 | |
| 989 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 990 | - { |
|
| 989 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 990 | + { |
|
| 991 | 991 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 992 | 992 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 993 | - } |
|
| 993 | + } |
|
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | if ($sort != "") |
| 997 | 997 | { |
| 998 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
| 999 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 998 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
| 999 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1000 | 1000 | } else { |
| 1001 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1001 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | $query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1006,16 +1006,16 @@ discard block |
||
| 1006 | 1006 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
| 1007 | 1007 | |
| 1008 | 1008 | return $spotter_array; |
| 1009 | - } |
|
| 1010 | - |
|
| 1011 | - /** |
|
| 1012 | - * Gets all the spotter information based on the pilot |
|
| 1013 | - * |
|
| 1014 | - * @return Array the spotter information |
|
| 1015 | - * |
|
| 1016 | - */ |
|
| 1017 | - public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1018 | - { |
|
| 1009 | + } |
|
| 1010 | + |
|
| 1011 | + /** |
|
| 1012 | + * Gets all the spotter information based on the pilot |
|
| 1013 | + * |
|
| 1014 | + * @return Array the spotter information |
|
| 1015 | + * |
|
| 1016 | + */ |
|
| 1017 | + public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
| 1018 | + { |
|
| 1019 | 1019 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
| 1020 | 1020 | |
| 1021 | 1021 | date_default_timezone_set('UTC'); |
@@ -1034,24 +1034,24 @@ discard block |
||
| 1034 | 1034 | |
| 1035 | 1035 | if ($limit != "") |
| 1036 | 1036 | { |
| 1037 | - $limit_array = explode(",", $limit); |
|
| 1037 | + $limit_array = explode(",", $limit); |
|
| 1038 | 1038 | |
| 1039 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1040 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1039 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1040 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1041 | 1041 | |
| 1042 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1043 | - { |
|
| 1042 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1043 | + { |
|
| 1044 | 1044 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1045 | 1045 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1046 | - } |
|
| 1046 | + } |
|
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | 1049 | if ($sort != "") |
| 1050 | 1050 | { |
| 1051 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1052 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1051 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1052 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1053 | 1053 | } else { |
| 1054 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1054 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | 1057 | $query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1059,16 +1059,16 @@ discard block |
||
| 1059 | 1059 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
| 1060 | 1060 | |
| 1061 | 1061 | return $spotter_array; |
| 1062 | - } |
|
| 1063 | - |
|
| 1064 | - /** |
|
| 1065 | - * Gets all number of flight over countries |
|
| 1066 | - * |
|
| 1067 | - * @return Array the airline country list |
|
| 1068 | - * |
|
| 1069 | - */ |
|
| 1070 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1071 | - { |
|
| 1062 | + } |
|
| 1063 | + |
|
| 1064 | + /** |
|
| 1065 | + * Gets all number of flight over countries |
|
| 1066 | + * |
|
| 1067 | + * @return Array the airline country list |
|
| 1068 | + * |
|
| 1069 | + */ |
|
| 1070 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1071 | + { |
|
| 1072 | 1072 | global $globalDBdriver; |
| 1073 | 1073 | /* |
| 1074 | 1074 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1078,14 +1078,14 @@ discard block |
||
| 1078 | 1078 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1079 | 1079 | FROM countries c, tracker_archive s |
| 1080 | 1080 | WHERE c.iso2 = s.over_country "; |
| 1081 | - if ($olderthanmonths > 0) { |
|
| 1082 | - if ($globalDBdriver == 'mysql') { |
|
| 1081 | + if ($olderthanmonths > 0) { |
|
| 1082 | + if ($globalDBdriver == 'mysql') { |
|
| 1083 | 1083 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1084 | 1084 | } else { |
| 1085 | 1085 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1086 | 1086 | } |
| 1087 | 1087 | } |
| 1088 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1088 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1089 | 1089 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1090 | 1090 | if ($limit) $query .= " LIMIT 0,10"; |
| 1091 | 1091 | |
@@ -1098,23 +1098,23 @@ discard block |
||
| 1098 | 1098 | |
| 1099 | 1099 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1100 | 1100 | { |
| 1101 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1102 | - $temp_array['flight_country'] = $row['name']; |
|
| 1103 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1104 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1105 | - $flight_array[] = $temp_array; |
|
| 1101 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1102 | + $temp_array['flight_country'] = $row['name']; |
|
| 1103 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1104 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1105 | + $flight_array[] = $temp_array; |
|
| 1106 | 1106 | } |
| 1107 | 1107 | return $flight_array; |
| 1108 | - } |
|
| 1109 | - |
|
| 1110 | - /** |
|
| 1111 | - * Gets all number of flight over countries |
|
| 1112 | - * |
|
| 1113 | - * @return Array the airline country list |
|
| 1114 | - * |
|
| 1115 | - */ |
|
| 1116 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1117 | - { |
|
| 1108 | + } |
|
| 1109 | + |
|
| 1110 | + /** |
|
| 1111 | + * Gets all number of flight over countries |
|
| 1112 | + * |
|
| 1113 | + * @return Array the airline country list |
|
| 1114 | + * |
|
| 1115 | + */ |
|
| 1116 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1117 | + { |
|
| 1118 | 1118 | global $globalDBdriver; |
| 1119 | 1119 | /* |
| 1120 | 1120 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1124,14 +1124,14 @@ discard block |
||
| 1124 | 1124 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
| 1125 | 1125 | FROM countries c, tracker_archive s, spotter_output o |
| 1126 | 1126 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid "; |
| 1127 | - if ($olderthanmonths > 0) { |
|
| 1128 | - if ($globalDBdriver == 'mysql') { |
|
| 1127 | + if ($olderthanmonths > 0) { |
|
| 1128 | + if ($globalDBdriver == 'mysql') { |
|
| 1129 | 1129 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
| 1130 | 1130 | } else { |
| 1131 | 1131 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1132 | 1132 | } |
| 1133 | 1133 | } |
| 1134 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1134 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1135 | 1135 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1136 | 1136 | if ($limit) $query .= " LIMIT 0,10"; |
| 1137 | 1137 | |
@@ -1144,24 +1144,24 @@ discard block |
||
| 1144 | 1144 | |
| 1145 | 1145 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
| 1146 | 1146 | { |
| 1147 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1148 | - $temp_array['flight_count'] = $row['nb']; |
|
| 1149 | - $temp_array['flight_country'] = $row['name']; |
|
| 1150 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1151 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1152 | - $flight_array[] = $temp_array; |
|
| 1147 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
| 1148 | + $temp_array['flight_count'] = $row['nb']; |
|
| 1149 | + $temp_array['flight_country'] = $row['name']; |
|
| 1150 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
| 1151 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
| 1152 | + $flight_array[] = $temp_array; |
|
| 1153 | 1153 | } |
| 1154 | 1154 | return $flight_array; |
| 1155 | - } |
|
| 1156 | - |
|
| 1157 | - /** |
|
| 1158 | - * Gets last spotter information based on a particular callsign |
|
| 1159 | - * |
|
| 1160 | - * @return Array the spotter information |
|
| 1161 | - * |
|
| 1162 | - */ |
|
| 1163 | - public function getDateArchiveTrackerDataById($id,$date) |
|
| 1164 | - { |
|
| 1155 | + } |
|
| 1156 | + |
|
| 1157 | + /** |
|
| 1158 | + * Gets last spotter information based on a particular callsign |
|
| 1159 | + * |
|
| 1160 | + * @return Array the spotter information |
|
| 1161 | + * |
|
| 1162 | + */ |
|
| 1163 | + public function getDateArchiveTrackerDataById($id,$date) |
|
| 1164 | + { |
|
| 1165 | 1165 | $Tracker = new Tracker($this->db); |
| 1166 | 1166 | date_default_timezone_set('UTC'); |
| 1167 | 1167 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1169,16 +1169,16 @@ discard block |
||
| 1169 | 1169 | $date = date('c',$date); |
| 1170 | 1170 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
| 1171 | 1171 | return $spotter_array; |
| 1172 | - } |
|
| 1173 | - |
|
| 1174 | - /** |
|
| 1175 | - * Gets all the spotter information based on a particular callsign |
|
| 1176 | - * |
|
| 1177 | - * @return Array the spotter information |
|
| 1178 | - * |
|
| 1179 | - */ |
|
| 1180 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
| 1181 | - { |
|
| 1172 | + } |
|
| 1173 | + |
|
| 1174 | + /** |
|
| 1175 | + * Gets all the spotter information based on a particular callsign |
|
| 1176 | + * |
|
| 1177 | + * @return Array the spotter information |
|
| 1178 | + * |
|
| 1179 | + */ |
|
| 1180 | + public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
| 1181 | + { |
|
| 1182 | 1182 | $Tracker = new Tracker($this->db); |
| 1183 | 1183 | date_default_timezone_set('UTC'); |
| 1184 | 1184 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1186,16 +1186,16 @@ discard block |
||
| 1186 | 1186 | $date = date('c',$date); |
| 1187 | 1187 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 1188 | 1188 | return $spotter_array; |
| 1189 | - } |
|
| 1190 | - |
|
| 1191 | - /** |
|
| 1192 | - * Gets all the spotter information based on the airport |
|
| 1193 | - * |
|
| 1194 | - * @return Array the spotter information |
|
| 1195 | - * |
|
| 1196 | - */ |
|
| 1197 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1198 | - { |
|
| 1189 | + } |
|
| 1190 | + |
|
| 1191 | + /** |
|
| 1192 | + * Gets all the spotter information based on the airport |
|
| 1193 | + * |
|
| 1194 | + * @return Array the spotter information |
|
| 1195 | + * |
|
| 1196 | + */ |
|
| 1197 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1198 | + { |
|
| 1199 | 1199 | global $global_query; |
| 1200 | 1200 | $Tracker = new Tracker(); |
| 1201 | 1201 | date_default_timezone_set('UTC'); |
@@ -1206,35 +1206,35 @@ discard block |
||
| 1206 | 1206 | |
| 1207 | 1207 | if ($airport != "") |
| 1208 | 1208 | { |
| 1209 | - if (!is_string($airport)) |
|
| 1210 | - { |
|
| 1209 | + if (!is_string($airport)) |
|
| 1210 | + { |
|
| 1211 | 1211 | return false; |
| 1212 | - } else { |
|
| 1212 | + } else { |
|
| 1213 | 1213 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))"; |
| 1214 | 1214 | $query_values = array(':airport' => $airport); |
| 1215 | - } |
|
| 1215 | + } |
|
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | if ($limit != "") |
| 1219 | 1219 | { |
| 1220 | - $limit_array = explode(",", $limit); |
|
| 1220 | + $limit_array = explode(",", $limit); |
|
| 1221 | 1221 | |
| 1222 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1223 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1222 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1223 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1224 | 1224 | |
| 1225 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1226 | - { |
|
| 1225 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
| 1226 | + { |
|
| 1227 | 1227 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
| 1228 | 1228 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
| 1229 | - } |
|
| 1229 | + } |
|
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | 1232 | if ($sort != "") |
| 1233 | 1233 | { |
| 1234 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1235 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1234 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
| 1235 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
| 1236 | 1236 | } else { |
| 1237 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1237 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | 1240 | $query = $global_query.$filter_query." tracker_archive_output.ident <> '' ".$additional_query." AND ((tracker_archive_output.departure_airport_icao <> 'NA') AND (tracker_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1242,6 +1242,6 @@ discard block |
||
| 1242 | 1242 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
| 1243 | 1243 | |
| 1244 | 1244 | return $spotter_array; |
| 1245 | - } |
|
| 1245 | + } |
|
| 1246 | 1246 | } |
| 1247 | 1247 | ?> |
| 1248 | 1248 | \ No newline at end of file |
@@ -13,33 +13,33 @@ discard block |
||
| 13 | 13 | * @param Array $filter the filter |
| 14 | 14 | * @return Array the SQL part |
| 15 | 15 | */ |
| 16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 16 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 18 | 18 | $filters = array(); |
| 19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 20 | 20 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 21 | 21 | $filters = $globalStatsFilters[$globalFilterName]; |
| 22 | 22 | } else { |
| 23 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 23 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | if (isset($filter[0]['source'])) { |
| 27 | - $filters = array_merge($filters,$filter); |
|
| 27 | + $filters = array_merge($filters, $filter); |
|
| 28 | 28 | } |
| 29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 30 | 30 | $filter_query_join = ''; |
| 31 | 31 | $filter_query_where = ''; |
| 32 | - foreach($filters as $flt) { |
|
| 32 | + foreach ($filters as $flt) { |
|
| 33 | 33 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 34 | 34 | if (isset($flt['source'])) { |
| 35 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 35 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 36 | 36 | } else { |
| 37 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 37 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 42 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 42 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 43 | 43 | } |
| 44 | 44 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 45 | 45 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -67,38 +67,38 @@ discard block |
||
| 67 | 67 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'"; |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
| 70 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
| 71 | 71 | } |
| 72 | 72 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 73 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 73 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 74 | 74 | } |
| 75 | 75 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 76 | 76 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 77 | 77 | if ($filter_query_where != '') { |
| 78 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 78 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 79 | 79 | } |
| 80 | 80 | $filter_query = $filter_query_join.$filter_query_where; |
| 81 | 81 | return $filter_query; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // tracker_archive |
| 85 | - public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
| 85 | + public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
| 86 | 86 | require_once(dirname(__FILE__).'/class.Tracker.php'); |
| 87 | 87 | if ($over_country == '') { |
| 88 | 88 | $Tracker = new Tracker($this->db); |
| 89 | - $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
| 89 | + $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
| 90 | 90 | if (!empty($data_country)) $country = $data_country['iso2']; |
| 91 | 91 | else $country = ''; |
| 92 | 92 | } else $country = $over_country; |
| 93 | 93 | // Route is not added in tracker_archive |
| 94 | - $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
| 94 | + $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
| 95 | 95 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
| 96 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type); |
|
| 96 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type); |
|
| 97 | 97 | try { |
| 98 | 98 | $sth = $this->db->prepare($query); |
| 99 | 99 | $sth->execute($query_values); |
| 100 | 100 | $sth->closeCursor(); |
| 101 | - } catch(PDOException $e) { |
|
| 101 | + } catch (PDOException $e) { |
|
| 102 | 102 | return "error : ".$e->getMessage(); |
| 103 | 103 | } |
| 104 | 104 | return "success"; |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 120 | 120 | //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
| 121 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 121 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
| 122 | 122 | |
| 123 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
| 123 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident)); |
|
| 124 | 124 | |
| 125 | 125 | return $spotter_array; |
| 126 | 126 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 140 | 140 | //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
| 141 | 141 | //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
| 142 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 142 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
| 143 | 143 | |
| 144 | 144 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 145 | 145 | /* |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
| 154 | 154 | */ |
| 155 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
| 155 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id)); |
|
| 156 | 156 | |
| 157 | 157 | return $spotter_array; |
| 158 | 158 | } |
@@ -167,14 +167,14 @@ discard block |
||
| 167 | 167 | { |
| 168 | 168 | date_default_timezone_set('UTC'); |
| 169 | 169 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 170 | - $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 170 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 171 | 171 | |
| 172 | 172 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 173 | 173 | |
| 174 | 174 | try { |
| 175 | 175 | $sth = $this->db->prepare($query); |
| 176 | 176 | $sth->execute(array(':id' => $id)); |
| 177 | - } catch(PDOException $e) { |
|
| 177 | + } catch (PDOException $e) { |
|
| 178 | 178 | echo $e->getMessage(); |
| 179 | 179 | die; |
| 180 | 180 | } |
@@ -193,14 +193,14 @@ discard block |
||
| 193 | 193 | { |
| 194 | 194 | date_default_timezone_set('UTC'); |
| 195 | 195 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 196 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 196 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
| 197 | 197 | |
| 198 | 198 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
| 199 | 199 | |
| 200 | 200 | try { |
| 201 | 201 | $sth = $this->db->prepare($query); |
| 202 | 202 | $sth->execute(array(':id' => $id)); |
| 203 | - } catch(PDOException $e) { |
|
| 203 | + } catch (PDOException $e) { |
|
| 204 | 204 | echo $e->getMessage(); |
| 205 | 205 | die; |
| 206 | 206 | } |
@@ -222,12 +222,12 @@ discard block |
||
| 222 | 222 | date_default_timezone_set('UTC'); |
| 223 | 223 | |
| 224 | 224 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 225 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 225 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 226 | 226 | |
| 227 | 227 | try { |
| 228 | 228 | $sth = $this->db->prepare($query); |
| 229 | 229 | $sth->execute(array(':ident' => $ident)); |
| 230 | - } catch(PDOException $e) { |
|
| 230 | + } catch (PDOException $e) { |
|
| 231 | 231 | echo $e->getMessage(); |
| 232 | 232 | die; |
| 233 | 233 | } |
@@ -248,12 +248,12 @@ discard block |
||
| 248 | 248 | date_default_timezone_set('UTC'); |
| 249 | 249 | |
| 250 | 250 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 251 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 251 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
| 252 | 252 | |
| 253 | 253 | try { |
| 254 | 254 | $sth = $this->db->prepare($query); |
| 255 | 255 | $sth->execute(array(':id' => $id)); |
| 256 | - } catch(PDOException $e) { |
|
| 256 | + } catch (PDOException $e) { |
|
| 257 | 257 | echo $e->getMessage(); |
| 258 | 258 | die; |
| 259 | 259 | } |
@@ -274,12 +274,12 @@ discard block |
||
| 274 | 274 | date_default_timezone_set('UTC'); |
| 275 | 275 | |
| 276 | 276 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 277 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 277 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
| 278 | 278 | |
| 279 | 279 | try { |
| 280 | 280 | $sth = $this->db->prepare($query); |
| 281 | 281 | $sth->execute(array(':id' => $id)); |
| 282 | - } catch(PDOException $e) { |
|
| 282 | + } catch (PDOException $e) { |
|
| 283 | 283 | echo $e->getMessage(); |
| 284 | 284 | die; |
| 285 | 285 | } |
@@ -301,13 +301,13 @@ discard block |
||
| 301 | 301 | date_default_timezone_set('UTC'); |
| 302 | 302 | |
| 303 | 303 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 304 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 304 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
| 305 | 305 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
| 306 | 306 | |
| 307 | 307 | try { |
| 308 | 308 | $sth = $this->db->prepare($query); |
| 309 | 309 | $sth->execute(array(':ident' => $ident)); |
| 310 | - } catch(PDOException $e) { |
|
| 310 | + } catch (PDOException $e) { |
|
| 311 | 311 | echo $e->getMessage(); |
| 312 | 312 | die; |
| 313 | 313 | } |
@@ -324,13 +324,13 @@ discard block |
||
| 324 | 324 | * @return Array the spotter information |
| 325 | 325 | * |
| 326 | 326 | */ |
| 327 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
| 327 | + public function getTrackerArchiveData($ident, $famtrackid, $date) |
|
| 328 | 328 | { |
| 329 | 329 | $Tracker = new Tracker($this->db); |
| 330 | 330 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 331 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 331 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
| 332 | 332 | |
| 333 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
| 333 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%')); |
|
| 334 | 334 | |
| 335 | 335 | return $spotter_array; |
| 336 | 336 | } |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | try { |
| 344 | 344 | $sth = $this->db->prepare($query); |
| 345 | 345 | $sth->execute(); |
| 346 | - } catch(PDOException $e) { |
|
| 346 | + } catch (PDOException $e) { |
|
| 347 | 347 | echo $e->getMessage(); |
| 348 | 348 | die; |
| 349 | 349 | } |
@@ -355,24 +355,24 @@ discard block |
||
| 355 | 355 | * @return Array the spotter information |
| 356 | 356 | * |
| 357 | 357 | */ |
| 358 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
| 358 | + public function getMinLiveTrackerData($begindate, $enddate, $filter = array()) |
|
| 359 | 359 | { |
| 360 | 360 | global $globalDBdriver, $globalLiveInterval; |
| 361 | 361 | date_default_timezone_set('UTC'); |
| 362 | 362 | |
| 363 | 363 | $filter_query = ''; |
| 364 | 364 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 365 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 365 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 366 | 366 | } |
| 367 | 367 | // Use spotter_output also ? |
| 368 | 368 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 369 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 369 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 370 | 370 | } |
| 371 | 371 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 372 | 372 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
| 373 | 373 | } |
| 374 | 374 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 375 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 375 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -391,14 +391,14 @@ discard block |
||
| 391 | 391 | GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid |
| 392 | 392 | AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
| 393 | 393 | */ |
| 394 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 394 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 395 | 395 | FROM tracker_archive |
| 396 | 396 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 397 | 397 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
| 398 | 398 | '.$filter_query.' ORDER BY famtrackid'; |
| 399 | 399 | } else { |
| 400 | 400 | //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
| 401 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 401 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
| 402 | 402 | FROM tracker_archive |
| 403 | 403 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
| 404 | 404 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | try { |
| 409 | 409 | $sth = $this->db->prepare($query); |
| 410 | 410 | $sth->execute(); |
| 411 | - } catch(PDOException $e) { |
|
| 411 | + } catch (PDOException $e) { |
|
| 412 | 412 | echo $e->getMessage(); |
| 413 | 413 | die; |
| 414 | 414 | } |
@@ -423,24 +423,24 @@ discard block |
||
| 423 | 423 | * @return Array the spotter information |
| 424 | 424 | * |
| 425 | 425 | */ |
| 426 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
| 426 | + public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array()) |
|
| 427 | 427 | { |
| 428 | 428 | global $globalDBdriver, $globalLiveInterval; |
| 429 | 429 | date_default_timezone_set('UTC'); |
| 430 | 430 | |
| 431 | 431 | $filter_query = ''; |
| 432 | 432 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 433 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 433 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 434 | 434 | } |
| 435 | 435 | // Should use spotter_output also ? |
| 436 | 436 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 437 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 437 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 438 | 438 | } |
| 439 | 439 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 440 | 440 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
| 441 | 441 | } |
| 442 | 442 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 443 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 443 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | FROM tracker_archive |
| 451 | 451 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
| 452 | 452 | */ |
| 453 | - $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
| 453 | + $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
| 454 | 454 | FROM tracker_archive_output |
| 455 | 455 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao |
| 456 | 456 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
| 466 | 466 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
| 467 | 467 | */ |
| 468 | - $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 468 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
| 469 | 469 | FROM tracker_archive_output |
| 470 | 470 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
| 471 | 471 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | try { |
| 478 | 478 | $sth = $this->db->prepare($query); |
| 479 | 479 | $sth->execute(); |
| 480 | - } catch(PDOException $e) { |
|
| 480 | + } catch (PDOException $e) { |
|
| 481 | 481 | echo $e->getMessage(); |
| 482 | 482 | die; |
| 483 | 483 | } |
@@ -492,23 +492,23 @@ discard block |
||
| 492 | 492 | * @return Array the spotter information |
| 493 | 493 | * |
| 494 | 494 | */ |
| 495 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
| 495 | + public function getLiveTrackerCount($begindate, $enddate, $filter = array()) |
|
| 496 | 496 | { |
| 497 | 497 | global $globalDBdriver, $globalLiveInterval; |
| 498 | 498 | date_default_timezone_set('UTC'); |
| 499 | 499 | |
| 500 | 500 | $filter_query = ''; |
| 501 | 501 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 502 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
| 502 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
| 503 | 503 | } |
| 504 | 504 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 505 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 505 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
| 506 | 506 | } |
| 507 | 507 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
| 508 | 508 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
| 509 | 509 | } |
| 510 | 510 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 511 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 511 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | try { |
| 524 | 524 | $sth = $this->db->prepare($query); |
| 525 | 525 | $sth->execute(); |
| 526 | - } catch(PDOException $e) { |
|
| 526 | + } catch (PDOException $e) { |
|
| 527 | 527 | echo $e->getMessage(); |
| 528 | 528 | die; |
| 529 | 529 | } |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | * @return Array the spotter information |
| 544 | 544 | * |
| 545 | 545 | */ |
| 546 | - public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
| 546 | + public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
| 547 | 547 | { |
| 548 | 548 | global $globalTimezone, $globalDBdriver; |
| 549 | 549 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | |
| 566 | 566 | $q_array = explode(" ", $q); |
| 567 | 567 | |
| 568 | - foreach ($q_array as $q_item){ |
|
| 568 | + foreach ($q_array as $q_item) { |
|
| 569 | 569 | $additional_query .= " AND ("; |
| 570 | 570 | $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
| 571 | 571 | $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | |
| 598 | 598 | if ($registration != "") |
| 599 | 599 | { |
| 600 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 600 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 601 | 601 | if (!is_string($registration)) |
| 602 | 602 | { |
| 603 | 603 | return false; |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | |
| 609 | 609 | if ($aircraft_icao != "") |
| 610 | 610 | { |
| 611 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 611 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 612 | 612 | if (!is_string($aircraft_icao)) |
| 613 | 613 | { |
| 614 | 614 | return false; |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | |
| 620 | 620 | if ($aircraft_manufacturer != "") |
| 621 | 621 | { |
| 622 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 622 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 623 | 623 | if (!is_string($aircraft_manufacturer)) |
| 624 | 624 | { |
| 625 | 625 | return false; |
@@ -640,7 +640,7 @@ discard block |
||
| 640 | 640 | |
| 641 | 641 | if ($airline_icao != "") |
| 642 | 642 | { |
| 643 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 643 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 644 | 644 | if (!is_string($airline_icao)) |
| 645 | 645 | { |
| 646 | 646 | return false; |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | |
| 652 | 652 | if ($airline_country != "") |
| 653 | 653 | { |
| 654 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 654 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 655 | 655 | if (!is_string($airline_country)) |
| 656 | 656 | { |
| 657 | 657 | return false; |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | |
| 663 | 663 | if ($airline_type != "") |
| 664 | 664 | { |
| 665 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 665 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 666 | 666 | if (!is_string($airline_type)) |
| 667 | 667 | { |
| 668 | 668 | return false; |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | |
| 685 | 685 | if ($airport != "") |
| 686 | 686 | { |
| 687 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 687 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 688 | 688 | if (!is_string($airport)) |
| 689 | 689 | { |
| 690 | 690 | return false; |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | |
| 696 | 696 | if ($airport_country != "") |
| 697 | 697 | { |
| 698 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 698 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 699 | 699 | if (!is_string($airport_country)) |
| 700 | 700 | { |
| 701 | 701 | return false; |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | |
| 707 | 707 | if ($callsign != "") |
| 708 | 708 | { |
| 709 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 709 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 710 | 710 | if (!is_string($callsign)) |
| 711 | 711 | { |
| 712 | 712 | return false; |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | $translate = $Translation->ident2icao($callsign); |
| 715 | 715 | if ($translate != $callsign) { |
| 716 | 716 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
| 717 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 717 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 718 | 718 | } else { |
| 719 | 719 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
| 720 | 720 | } |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | |
| 724 | 724 | if ($owner != "") |
| 725 | 725 | { |
| 726 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 726 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 727 | 727 | if (!is_string($owner)) |
| 728 | 728 | { |
| 729 | 729 | return false; |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | |
| 735 | 735 | if ($pilot_name != "") |
| 736 | 736 | { |
| 737 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 737 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 738 | 738 | if (!is_string($pilot_name)) |
| 739 | 739 | { |
| 740 | 740 | return false; |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | |
| 746 | 746 | if ($pilot_id != "") |
| 747 | 747 | { |
| 748 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
| 748 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
| 749 | 749 | if (!is_string($pilot_id)) |
| 750 | 750 | { |
| 751 | 751 | return false; |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | |
| 757 | 757 | if ($departure_airport_route != "") |
| 758 | 758 | { |
| 759 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 759 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 760 | 760 | if (!is_string($departure_airport_route)) |
| 761 | 761 | { |
| 762 | 762 | return false; |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | |
| 768 | 768 | if ($arrival_airport_route != "") |
| 769 | 769 | { |
| 770 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
| 770 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
| 771 | 771 | if (!is_string($arrival_airport_route)) |
| 772 | 772 | { |
| 773 | 773 | return false; |
@@ -780,8 +780,8 @@ discard block |
||
| 780 | 780 | { |
| 781 | 781 | $altitude_array = explode(",", $altitude); |
| 782 | 782 | |
| 783 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 784 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 783 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 784 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 785 | 785 | |
| 786 | 786 | |
| 787 | 787 | if ($altitude_array[1] != "") |
@@ -799,8 +799,8 @@ discard block |
||
| 799 | 799 | { |
| 800 | 800 | $date_array = explode(",", $date_posted); |
| 801 | 801 | |
| 802 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 803 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 802 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 803 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 804 | 804 | |
| 805 | 805 | if ($globalTimezone != '') { |
| 806 | 806 | date_default_timezone_set($globalTimezone); |
@@ -832,8 +832,8 @@ discard block |
||
| 832 | 832 | { |
| 833 | 833 | $limit_array = explode(",", $limit); |
| 834 | 834 | |
| 835 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 836 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 835 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 836 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 837 | 837 | |
| 838 | 838 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 839 | 839 | { |
@@ -844,8 +844,8 @@ discard block |
||
| 844 | 844 | |
| 845 | 845 | |
| 846 | 846 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 847 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
| 848 | - $query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 847 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
| 848 | + $query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 849 | 849 | FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 850 | 850 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
| 851 | 851 | } else { |
@@ -862,12 +862,12 @@ discard block |
||
| 862 | 862 | $additional_query .= " AND (tracker_archive_output.waypoints <> '')"; |
| 863 | 863 | } |
| 864 | 864 | |
| 865 | - $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
| 865 | + $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
| 866 | 866 | WHERE tracker_archive_output.ident <> '' |
| 867 | 867 | ".$additional_query." |
| 868 | 868 | ".$filter_query.$orderby_query; |
| 869 | 869 | } |
| 870 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
|
| 870 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
| 871 | 871 | |
| 872 | 872 | return $spotter_array; |
| 873 | 873 | } |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | try { |
| 885 | 885 | $sth = $this->db->prepare($query); |
| 886 | 886 | $sth->execute(); |
| 887 | - } catch(PDOException $e) { |
|
| 887 | + } catch (PDOException $e) { |
|
| 888 | 888 | return "error"; |
| 889 | 889 | } |
| 890 | 890 | } |
@@ -921,8 +921,8 @@ discard block |
||
| 921 | 921 | { |
| 922 | 922 | $limit_array = explode(",", $limit); |
| 923 | 923 | |
| 924 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 925 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 924 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 925 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 926 | 926 | |
| 927 | 927 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 928 | 928 | { |
@@ -963,7 +963,7 @@ discard block |
||
| 963 | 963 | $query_values = array(); |
| 964 | 964 | $limit_query = ''; |
| 965 | 965 | $additional_query = ''; |
| 966 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 966 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 967 | 967 | |
| 968 | 968 | if ($owner != "") |
| 969 | 969 | { |
@@ -980,8 +980,8 @@ discard block |
||
| 980 | 980 | { |
| 981 | 981 | $limit_array = explode(",", $limit); |
| 982 | 982 | |
| 983 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 984 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 983 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 984 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 985 | 985 | |
| 986 | 986 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 987 | 987 | { |
@@ -1021,7 +1021,7 @@ discard block |
||
| 1021 | 1021 | $query_values = array(); |
| 1022 | 1022 | $limit_query = ''; |
| 1023 | 1023 | $additional_query = ''; |
| 1024 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1024 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1025 | 1025 | |
| 1026 | 1026 | if ($pilot != "") |
| 1027 | 1027 | { |
@@ -1033,8 +1033,8 @@ discard block |
||
| 1033 | 1033 | { |
| 1034 | 1034 | $limit_array = explode(",", $limit); |
| 1035 | 1035 | |
| 1036 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1037 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1036 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1037 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1038 | 1038 | |
| 1039 | 1039 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1040 | 1040 | { |
@@ -1064,7 +1064,7 @@ discard block |
||
| 1064 | 1064 | * @return Array the airline country list |
| 1065 | 1065 | * |
| 1066 | 1066 | */ |
| 1067 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1067 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1068 | 1068 | { |
| 1069 | 1069 | global $globalDBdriver; |
| 1070 | 1070 | /* |
@@ -1093,7 +1093,7 @@ discard block |
||
| 1093 | 1093 | $flight_array = array(); |
| 1094 | 1094 | $temp_array = array(); |
| 1095 | 1095 | |
| 1096 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1096 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1097 | 1097 | { |
| 1098 | 1098 | $temp_array['flight_count'] = $row['nb']; |
| 1099 | 1099 | $temp_array['flight_country'] = $row['name']; |
@@ -1110,7 +1110,7 @@ discard block |
||
| 1110 | 1110 | * @return Array the airline country list |
| 1111 | 1111 | * |
| 1112 | 1112 | */ |
| 1113 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
| 1113 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
| 1114 | 1114 | { |
| 1115 | 1115 | global $globalDBdriver; |
| 1116 | 1116 | /* |
@@ -1139,7 +1139,7 @@ discard block |
||
| 1139 | 1139 | $flight_array = array(); |
| 1140 | 1140 | $temp_array = array(); |
| 1141 | 1141 | |
| 1142 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1142 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1143 | 1143 | { |
| 1144 | 1144 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 1145 | 1145 | $temp_array['flight_count'] = $row['nb']; |
@@ -1157,14 +1157,14 @@ discard block |
||
| 1157 | 1157 | * @return Array the spotter information |
| 1158 | 1158 | * |
| 1159 | 1159 | */ |
| 1160 | - public function getDateArchiveTrackerDataById($id,$date) |
|
| 1160 | + public function getDateArchiveTrackerDataById($id, $date) |
|
| 1161 | 1161 | { |
| 1162 | 1162 | $Tracker = new Tracker($this->db); |
| 1163 | 1163 | date_default_timezone_set('UTC'); |
| 1164 | 1164 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 1165 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1166 | - $date = date('c',$date); |
|
| 1167 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
| 1165 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1166 | + $date = date('c', $date); |
|
| 1167 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
| 1168 | 1168 | return $spotter_array; |
| 1169 | 1169 | } |
| 1170 | 1170 | |
@@ -1174,14 +1174,14 @@ discard block |
||
| 1174 | 1174 | * @return Array the spotter information |
| 1175 | 1175 | * |
| 1176 | 1176 | */ |
| 1177 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
| 1177 | + public function getDateArchiveTrackerDataByIdent($ident, $date) |
|
| 1178 | 1178 | { |
| 1179 | 1179 | $Tracker = new Tracker($this->db); |
| 1180 | 1180 | date_default_timezone_set('UTC'); |
| 1181 | 1181 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 1182 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1183 | - $date = date('c',$date); |
|
| 1184 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 1182 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
| 1183 | + $date = date('c', $date); |
|
| 1184 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 1185 | 1185 | return $spotter_array; |
| 1186 | 1186 | } |
| 1187 | 1187 | |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | * @return Array the spotter information |
| 1192 | 1192 | * |
| 1193 | 1193 | */ |
| 1194 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1194 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1195 | 1195 | { |
| 1196 | 1196 | global $global_query; |
| 1197 | 1197 | $Tracker = new Tracker(); |
@@ -1199,7 +1199,7 @@ discard block |
||
| 1199 | 1199 | $query_values = array(); |
| 1200 | 1200 | $limit_query = ''; |
| 1201 | 1201 | $additional_query = ''; |
| 1202 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1202 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1203 | 1203 | |
| 1204 | 1204 | if ($airport != "") |
| 1205 | 1205 | { |
@@ -1216,8 +1216,8 @@ discard block |
||
| 1216 | 1216 | { |
| 1217 | 1217 | $limit_array = explode(",", $limit); |
| 1218 | 1218 | |
| 1219 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1220 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1219 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1220 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1221 | 1221 | |
| 1222 | 1222 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1223 | 1223 | { |
@@ -26,7 +26,9 @@ discard block |
||
| 26 | 26 | if (isset($filter[0]['source'])) { |
| 27 | 27 | $filters = array_merge($filters,$filter); |
| 28 | 28 | } |
| 29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 29 | + if (is_array($globalFilter)) { |
|
| 30 | + $filter = array_merge($filter,$globalFilter); |
|
| 31 | + } |
|
| 30 | 32 | $filter_query_join = ''; |
| 31 | 33 | $filter_query_where = ''; |
| 32 | 34 | foreach($filters as $flt) { |
@@ -72,8 +74,11 @@ discard block |
||
| 72 | 74 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 73 | 75 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 74 | 76 | } |
| 75 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 76 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 77 | + if ($filter_query_where == '' && $where) { |
|
| 78 | + $filter_query_where = ' WHERE'; |
|
| 79 | + } elseif ($filter_query_where != '' && $and) { |
|
| 80 | + $filter_query_where .= ' AND'; |
|
| 81 | + } |
|
| 77 | 82 | if ($filter_query_where != '') { |
| 78 | 83 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 79 | 84 | } |
@@ -87,9 +92,14 @@ discard block |
||
| 87 | 92 | if ($over_country == '') { |
| 88 | 93 | $Tracker = new Tracker($this->db); |
| 89 | 94 | $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 90 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 91 | - else $country = ''; |
|
| 92 | - } else $country = $over_country; |
|
| 95 | + if (!empty($data_country)) { |
|
| 96 | + $country = $data_country['iso2']; |
|
| 97 | + } else { |
|
| 98 | + $country = ''; |
|
| 99 | + } |
|
| 100 | + } else { |
|
| 101 | + $country = $over_country; |
|
| 102 | + } |
|
| 93 | 103 | // Route is not added in tracker_archive |
| 94 | 104 | $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
| 95 | 105 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -588,7 +598,9 @@ discard block |
||
| 588 | 598 | $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 589 | 599 | $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
| 590 | 600 | $translate = $Translation->ident2icao($q_item); |
| 591 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 601 | + if ($translate != $q_item) { |
|
| 602 | + $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
| 603 | + } |
|
| 592 | 604 | $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
| 593 | 605 | $additional_query .= ")"; |
| 594 | 606 | } |
@@ -806,7 +818,9 @@ discard block |
||
| 806 | 818 | date_default_timezone_set($globalTimezone); |
| 807 | 819 | $datetime = new DateTime(); |
| 808 | 820 | $offset = $datetime->format('P'); |
| 809 | - } else $offset = '+00:00'; |
|
| 821 | + } else { |
|
| 822 | + $offset = '+00:00'; |
|
| 823 | + } |
|
| 810 | 824 | |
| 811 | 825 | |
| 812 | 826 | if ($date_array[1] != "") |
@@ -1082,9 +1096,13 @@ discard block |
||
| 1082 | 1096 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1083 | 1097 | } |
| 1084 | 1098 | } |
| 1085 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1099 | + if ($sincedate != '') { |
|
| 1100 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1101 | + } |
|
| 1086 | 1102 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1087 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1103 | + if ($limit) { |
|
| 1104 | + $query .= " LIMIT 0,10"; |
|
| 1105 | + } |
|
| 1088 | 1106 | |
| 1089 | 1107 | |
| 1090 | 1108 | $sth = $this->db->prepare($query); |
@@ -1128,9 +1146,13 @@ discard block |
||
| 1128 | 1146 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1129 | 1147 | } |
| 1130 | 1148 | } |
| 1131 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1149 | + if ($sincedate != '') { |
|
| 1150 | + $query .= "AND s.date > '".$sincedate."' "; |
|
| 1151 | + } |
|
| 1132 | 1152 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1133 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1153 | + if ($limit) { |
|
| 1154 | + $query .= " LIMIT 0,10"; |
|
| 1155 | + } |
|
| 1134 | 1156 | |
| 1135 | 1157 | |
| 1136 | 1158 | $sth = $this->db->prepare($query); |