@@ -7,121 +7,121 @@ |
||
7 | 7 | require_once(dirname(__FILE__).'/class.Translation.php'); |
8 | 8 | |
9 | 9 | class SpotterServer { |
10 | - public $dbs = null; |
|
10 | + public $dbs = null; |
|
11 | 11 | |
12 | - function __construct($dbs = null) { |
|
12 | + function __construct($dbs = null) { |
|
13 | 13 | if ($dbs === null) { |
14 | - $Connection = new Connection(null,'server'); |
|
15 | - $this->dbs = $Connection->dbs; |
|
16 | - $query = "CREATE TABLE IF NOT EXISTS `spotter_temp` ( `id_data` INT NOT NULL AUTO_INCREMENT , `id_user` INT NOT NULL , `datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `hex` VARCHAR(20) NOT NULL , `ident` VARCHAR(20) NULL , `latitude` FLOAT NULL , `longitude` FLOAT NULL , `verticalrate` INT NULL , `speed` INT NULL , `squawk` INT NULL , `altitude` INT NULL , `heading` INT NULL , `registration` VARCHAR(10) NULL , `aircraft_icao` VARCHAR(10) NULL , `waypoints` VARCHAR(255) NULL , `noarchive` BOOLEAN NOT NULL DEFAULT FALSE, `id_source` INT NOT NULL DEFAULT '1', `format_source` VARCHAR(25) NULL, `source_name` VARCHAR(25) NULL, `over_country` VARCHAR(255) NULL, PRIMARY KEY (`id_data`) ) ENGINE = MEMORY;"; |
|
17 | - try { |
|
14 | + $Connection = new Connection(null,'server'); |
|
15 | + $this->dbs = $Connection->dbs; |
|
16 | + $query = "CREATE TABLE IF NOT EXISTS `spotter_temp` ( `id_data` INT NOT NULL AUTO_INCREMENT , `id_user` INT NOT NULL , `datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `hex` VARCHAR(20) NOT NULL , `ident` VARCHAR(20) NULL , `latitude` FLOAT NULL , `longitude` FLOAT NULL , `verticalrate` INT NULL , `speed` INT NULL , `squawk` INT NULL , `altitude` INT NULL , `heading` INT NULL , `registration` VARCHAR(10) NULL , `aircraft_icao` VARCHAR(10) NULL , `waypoints` VARCHAR(255) NULL , `noarchive` BOOLEAN NOT NULL DEFAULT FALSE, `id_source` INT NOT NULL DEFAULT '1', `format_source` VARCHAR(25) NULL, `source_name` VARCHAR(25) NULL, `over_country` VARCHAR(255) NULL, PRIMARY KEY (`id_data`) ) ENGINE = MEMORY;"; |
|
17 | + try { |
|
18 | 18 | $sth = $this->dbs['server']->exec($query); |
19 | - } catch(PDOException $e) { |
|
19 | + } catch(PDOException $e) { |
|
20 | 20 | return "error : ".$e->getMessage(); |
21 | - } |
|
21 | + } |
|
22 | + } |
|
22 | 23 | } |
23 | - } |
|
24 | 24 | |
25 | - function checkAll() { |
|
26 | - return true; |
|
27 | - } |
|
25 | + function checkAll() { |
|
26 | + return true; |
|
27 | + } |
|
28 | 28 | |
29 | - function add($line) { |
|
29 | + function add($line) { |
|
30 | 30 | global $globalDebug, $globalServerUserID; |
31 | 31 | date_default_timezone_set('UTC'); |
32 | 32 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'aprs')) { |
33 | 33 | if (isset($line['format_source'])) { |
34 | - if(is_array($line) && isset($line['hex'])) { |
|
34 | + if(is_array($line) && isset($line['hex'])) { |
|
35 | 35 | if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) { |
36 | - $data['hex'] = trim($line['hex']); |
|
37 | - if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
38 | - $data['datetime'] = $line['datetime']; |
|
39 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
40 | - if (!isset($line['aircraft_icao'])) { |
|
41 | - $Spotter = new Spotter(); |
|
42 | - $aircraft_icao = $Spotter->getAllAircraftType($data['hex']); |
|
43 | - $Spotter->db = null; |
|
36 | + $data['hex'] = trim($line['hex']); |
|
37 | + if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
38 | + $data['datetime'] = $line['datetime']; |
|
39 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
40 | + if (!isset($line['aircraft_icao'])) { |
|
41 | + $Spotter = new Spotter(); |
|
42 | + $aircraft_icao = $Spotter->getAllAircraftType($data['hex']); |
|
43 | + $Spotter->db = null; |
|
44 | 44 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
45 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
46 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
47 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
48 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
45 | + if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
46 | + elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
47 | + elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
48 | + elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
49 | 49 | } |
50 | 50 | $data['aircraft_icao'] = $aircraft_icao; |
51 | - } else $data['aircraft_icao'] = $line['aircraft_icao']; |
|
52 | - //if ($globalDebug) echo "*********** New aircraft hex : ".$data['hex']." ***********\n"; |
|
51 | + } else $data['aircraft_icao'] = $line['aircraft_icao']; |
|
52 | + //if ($globalDebug) echo "*********** New aircraft hex : ".$data['hex']." ***********\n"; |
|
53 | 53 | } |
54 | 54 | if (isset($line['registration']) && $line['registration'] != '') { |
55 | - $data['registration'] = $line['registration']; |
|
55 | + $data['registration'] = $line['registration']; |
|
56 | 56 | } else $data['registration'] = null; |
57 | 57 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
58 | - $data['waypoints'] = $line['waypoints']; |
|
58 | + $data['waypoints'] = $line['waypoints']; |
|
59 | 59 | } else $data['waypoints'] = null; |
60 | 60 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
61 | - $data['ident'] = trim($line['ident']); |
|
61 | + $data['ident'] = trim($line['ident']); |
|
62 | 62 | } else $data['ident'] = null; |
63 | 63 | |
64 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') { |
|
65 | - if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
|
64 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') { |
|
65 | + if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
|
66 | 66 | $data['latitude'] = $line['latitude']; |
67 | - } else $data['latitude'] = null; |
|
68 | - if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
|
69 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
67 | + } else $data['latitude'] = null; |
|
68 | + if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
|
69 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
70 | 70 | $data['longitude'] = $line['longitude']; |
71 | - } else $data['longitude'] = null; |
|
71 | + } else $data['longitude'] = null; |
|
72 | 72 | } else { |
73 | - $data['latitude'] = null; |
|
74 | - $data['longitude'] = null; |
|
73 | + $data['latitude'] = null; |
|
74 | + $data['longitude'] = null; |
|
75 | 75 | } |
76 | 76 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
77 | - $data['verticalrate'] = $line['verticalrate']; |
|
77 | + $data['verticalrate'] = $line['verticalrate']; |
|
78 | 78 | } else $data['verticalrate'] = null; |
79 | 79 | if (isset($line['emergency']) && $line['emergency'] != '') { |
80 | - $data['emergency'] = $line['emergency']; |
|
80 | + $data['emergency'] = $line['emergency']; |
|
81 | 81 | } else $data['emergency'] = null; |
82 | 82 | if (isset($line['ground']) && $line['ground'] != '') { |
83 | - $data['ground'] = $line['ground']; |
|
83 | + $data['ground'] = $line['ground']; |
|
84 | 84 | } else $data['ground'] = null; |
85 | 85 | if (isset($line['speed']) && $line['speed'] != '') { |
86 | - $data['speed'] = round($line['speed']); |
|
86 | + $data['speed'] = round($line['speed']); |
|
87 | 87 | } else $data['speed'] = null; |
88 | 88 | if (isset($line['squawk']) && $line['squawk'] != '') { |
89 | - $data['squawk'] = $line['squawk']; |
|
89 | + $data['squawk'] = $line['squawk']; |
|
90 | 90 | } else $data['squawk'] = null; |
91 | 91 | |
92 | 92 | if (isset($line['altitude']) && $line['altitude'] != '') { |
93 | 93 | $data['altitude'] = round($line['altitude']); |
94 | 94 | } else $data['altitude'] = null; |
95 | 95 | if (isset($line['heading']) && $line['heading'] != '') { |
96 | - $data['heading'] = round($line['heading']); |
|
96 | + $data['heading'] = round($line['heading']); |
|
97 | 97 | } else $data['heading'] = null; |
98 | 98 | if (isset($line['source_name']) && $line['source_name'] != '') { |
99 | - $data['source_name'] = $line['source_name']; |
|
99 | + $data['source_name'] = $line['source_name']; |
|
100 | 100 | } else $data['source_name'] = null; |
101 | 101 | if (isset($line['over_country']) && $line['over_country'] != '') { |
102 | - $data['over_country'] = $line['over_country']; |
|
102 | + $data['over_country'] = $line['over_country']; |
|
103 | 103 | } else $data['over_country'] = null; |
104 | 104 | if (isset($line['noarchive']) && $line['noarchive']) { |
105 | - $data['noarchive'] = true; |
|
105 | + $data['noarchive'] = true; |
|
106 | 106 | } else $data['noarchive'] = false; |
107 | 107 | $data['format_source'] = $line['format_source']; |
108 | 108 | if (isset($line['id_source'])) $id_source = $line['id_source']; |
109 | 109 | if (isset($data['hex'])) { |
110 | - echo '.'; |
|
111 | - $id_user = $globalServerUserID; |
|
112 | - if ($id_user == NULL) $id_user = 1; |
|
113 | - if (!isset($id_source)) $id_source = 1; |
|
114 | - $query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)'; |
|
115 | - $query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']); |
|
116 | - try { |
|
117 | - $sth = $this->dbs['server']->prepare($query); |
|
118 | - $sth->execute($query_values); |
|
119 | - } catch(PDOException $e) { |
|
120 | - return "error : ".$e->getMessage(); |
|
121 | - } |
|
122 | - } |
|
123 | - } |
|
110 | + echo '.'; |
|
111 | + $id_user = $globalServerUserID; |
|
112 | + if ($id_user == NULL) $id_user = 1; |
|
113 | + if (!isset($id_source)) $id_source = 1; |
|
114 | + $query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)'; |
|
115 | + $query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']); |
|
116 | + try { |
|
117 | + $sth = $this->dbs['server']->prepare($query); |
|
118 | + $sth->execute($query_values); |
|
119 | + } catch(PDOException $e) { |
|
120 | + return "error : ".$e->getMessage(); |
|
121 | + } |
|
122 | + } |
|
123 | + } |
|
124 | + } |
|
124 | 125 | } |
125 | - } |
|
126 | 126 | } |
127 | 127 | ?> |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | |
12 | 12 | function __construct($dbs = null) { |
13 | 13 | if ($dbs === null) { |
14 | - $Connection = new Connection(null,'server'); |
|
14 | + $Connection = new Connection(null, 'server'); |
|
15 | 15 | $this->dbs = $Connection->dbs; |
16 | 16 | $query = "CREATE TABLE IF NOT EXISTS `spotter_temp` ( `id_data` INT NOT NULL AUTO_INCREMENT , `id_user` INT NOT NULL , `datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `hex` VARCHAR(20) NOT NULL , `ident` VARCHAR(20) NULL , `latitude` FLOAT NULL , `longitude` FLOAT NULL , `verticalrate` INT NULL , `speed` INT NULL , `squawk` INT NULL , `altitude` INT NULL , `heading` INT NULL , `registration` VARCHAR(10) NULL , `aircraft_icao` VARCHAR(10) NULL , `waypoints` VARCHAR(255) NULL , `noarchive` BOOLEAN NOT NULL DEFAULT FALSE, `id_source` INT NOT NULL DEFAULT '1', `format_source` VARCHAR(25) NULL, `source_name` VARCHAR(25) NULL, `over_country` VARCHAR(255) NULL, PRIMARY KEY (`id_data`) ) ENGINE = MEMORY;"; |
17 | 17 | try { |
18 | 18 | $sth = $this->dbs['server']->exec($query); |
19 | - } catch(PDOException $e) { |
|
19 | + } catch (PDOException $e) { |
|
20 | 20 | return "error : ".$e->getMessage(); |
21 | 21 | } |
22 | 22 | } |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | date_default_timezone_set('UTC'); |
32 | 32 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'aprs')) { |
33 | 33 | if (isset($line['format_source'])) { |
34 | - if(is_array($line) && isset($line['hex'])) { |
|
34 | + if (is_array($line) && isset($line['hex'])) { |
|
35 | 35 | if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) { |
36 | 36 | $data['hex'] = trim($line['hex']); |
37 | - if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
37 | + if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/', $line['datetime'])) { |
|
38 | 38 | $data['datetime'] = $line['datetime']; |
39 | 39 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
40 | 40 | if (!isset($line['aircraft_icao'])) { |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | if ($id_user == NULL) $id_user = 1; |
113 | 113 | if (!isset($id_source)) $id_source = 1; |
114 | 114 | $query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)'; |
115 | - $query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']); |
|
115 | + $query_values = array(':id_user' => $id_user, ':datetime' => $data['datetime'], ':hex' => $data['hex'], ':ident' => $data['ident'], ':latitude' => $data['latitude'], ':longitude' => $data['longitude'], ':verticalrate' => $data['verticalrate'], ':speed' => $data['speed'], ':squawk' => $data['squawk'], ':altitude' => $data['altitude'], ':heading' => $data['heading'], ':registration' => $data['registration'], ':aircraft_icao' => $data['aircraft_icao'], ':waypoints' => $data['waypoints'], ':id_source' => $id_source, ':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'], ':over_country' => $data['over_country']); |
|
116 | 116 | try { |
117 | 117 | $sth = $this->dbs['server']->prepare($query); |
118 | 118 | $sth->execute($query_values); |
119 | - } catch(PDOException $e) { |
|
119 | + } catch (PDOException $e) { |
|
120 | 120 | return "error : ".$e->getMessage(); |
121 | 121 | } |
122 | 122 | } |
@@ -36,81 +36,128 @@ |
||
36 | 36 | $data['hex'] = trim($line['hex']); |
37 | 37 | if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
38 | 38 | $data['datetime'] = $line['datetime']; |
39 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
39 | + } else { |
|
40 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
41 | + } |
|
40 | 42 | if (!isset($line['aircraft_icao'])) { |
41 | 43 | $Spotter = new Spotter(); |
42 | 44 | $aircraft_icao = $Spotter->getAllAircraftType($data['hex']); |
43 | 45 | $Spotter->db = null; |
44 | 46 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
45 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
46 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
47 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
48 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
47 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
48 | + $aircraft_icao = 'GLID'; |
|
49 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
50 | + $aircraft_icao = 'UHEL'; |
|
51 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
52 | + $aircraft_icao = 'TOWPLANE'; |
|
53 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
54 | + $aircraft_icao = 'POWAIRC'; |
|
55 | + } |
|
49 | 56 | } |
50 | 57 | $data['aircraft_icao'] = $aircraft_icao; |
51 | - } else $data['aircraft_icao'] = $line['aircraft_icao']; |
|
58 | + } else { |
|
59 | + $data['aircraft_icao'] = $line['aircraft_icao']; |
|
60 | + } |
|
52 | 61 | //if ($globalDebug) echo "*********** New aircraft hex : ".$data['hex']." ***********\n"; |
53 | 62 | } |
54 | 63 | if (isset($line['registration']) && $line['registration'] != '') { |
55 | 64 | $data['registration'] = $line['registration']; |
56 | - } else $data['registration'] = null; |
|
65 | + } else { |
|
66 | + $data['registration'] = null; |
|
67 | + } |
|
57 | 68 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
58 | 69 | $data['waypoints'] = $line['waypoints']; |
59 | - } else $data['waypoints'] = null; |
|
70 | + } else { |
|
71 | + $data['waypoints'] = null; |
|
72 | + } |
|
60 | 73 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
61 | 74 | $data['ident'] = trim($line['ident']); |
62 | - } else $data['ident'] = null; |
|
75 | + } else { |
|
76 | + $data['ident'] = null; |
|
77 | + } |
|
63 | 78 | |
64 | 79 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') { |
65 | 80 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
66 | 81 | $data['latitude'] = $line['latitude']; |
67 | - } else $data['latitude'] = null; |
|
82 | + } else { |
|
83 | + $data['latitude'] = null; |
|
84 | + } |
|
68 | 85 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
69 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
86 | + if ($line['longitude'] > 180) { |
|
87 | + $line['longitude'] = $line['longitude'] - 360; |
|
88 | + } |
|
70 | 89 | $data['longitude'] = $line['longitude']; |
71 | - } else $data['longitude'] = null; |
|
90 | + } else { |
|
91 | + $data['longitude'] = null; |
|
92 | + } |
|
72 | 93 | } else { |
73 | 94 | $data['latitude'] = null; |
74 | 95 | $data['longitude'] = null; |
75 | 96 | } |
76 | 97 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
77 | 98 | $data['verticalrate'] = $line['verticalrate']; |
78 | - } else $data['verticalrate'] = null; |
|
99 | + } else { |
|
100 | + $data['verticalrate'] = null; |
|
101 | + } |
|
79 | 102 | if (isset($line['emergency']) && $line['emergency'] != '') { |
80 | 103 | $data['emergency'] = $line['emergency']; |
81 | - } else $data['emergency'] = null; |
|
104 | + } else { |
|
105 | + $data['emergency'] = null; |
|
106 | + } |
|
82 | 107 | if (isset($line['ground']) && $line['ground'] != '') { |
83 | 108 | $data['ground'] = $line['ground']; |
84 | - } else $data['ground'] = null; |
|
109 | + } else { |
|
110 | + $data['ground'] = null; |
|
111 | + } |
|
85 | 112 | if (isset($line['speed']) && $line['speed'] != '') { |
86 | 113 | $data['speed'] = round($line['speed']); |
87 | - } else $data['speed'] = null; |
|
114 | + } else { |
|
115 | + $data['speed'] = null; |
|
116 | + } |
|
88 | 117 | if (isset($line['squawk']) && $line['squawk'] != '') { |
89 | 118 | $data['squawk'] = $line['squawk']; |
90 | - } else $data['squawk'] = null; |
|
119 | + } else { |
|
120 | + $data['squawk'] = null; |
|
121 | + } |
|
91 | 122 | |
92 | 123 | if (isset($line['altitude']) && $line['altitude'] != '') { |
93 | 124 | $data['altitude'] = round($line['altitude']); |
94 | - } else $data['altitude'] = null; |
|
125 | + } else { |
|
126 | + $data['altitude'] = null; |
|
127 | + } |
|
95 | 128 | if (isset($line['heading']) && $line['heading'] != '') { |
96 | 129 | $data['heading'] = round($line['heading']); |
97 | - } else $data['heading'] = null; |
|
130 | + } else { |
|
131 | + $data['heading'] = null; |
|
132 | + } |
|
98 | 133 | if (isset($line['source_name']) && $line['source_name'] != '') { |
99 | 134 | $data['source_name'] = $line['source_name']; |
100 | - } else $data['source_name'] = null; |
|
135 | + } else { |
|
136 | + $data['source_name'] = null; |
|
137 | + } |
|
101 | 138 | if (isset($line['over_country']) && $line['over_country'] != '') { |
102 | 139 | $data['over_country'] = $line['over_country']; |
103 | - } else $data['over_country'] = null; |
|
140 | + } else { |
|
141 | + $data['over_country'] = null; |
|
142 | + } |
|
104 | 143 | if (isset($line['noarchive']) && $line['noarchive']) { |
105 | 144 | $data['noarchive'] = true; |
106 | - } else $data['noarchive'] = false; |
|
145 | + } else { |
|
146 | + $data['noarchive'] = false; |
|
147 | + } |
|
107 | 148 | $data['format_source'] = $line['format_source']; |
108 | - if (isset($line['id_source'])) $id_source = $line['id_source']; |
|
149 | + if (isset($line['id_source'])) { |
|
150 | + $id_source = $line['id_source']; |
|
151 | + } |
|
109 | 152 | if (isset($data['hex'])) { |
110 | 153 | echo '.'; |
111 | 154 | $id_user = $globalServerUserID; |
112 | - if ($id_user == NULL) $id_user = 1; |
|
113 | - if (!isset($id_source)) $id_source = 1; |
|
155 | + if ($id_user == NULL) { |
|
156 | + $id_user = 1; |
|
157 | + } |
|
158 | + if (!isset($id_source)) { |
|
159 | + $id_source = 1; |
|
160 | + } |
|
114 | 161 | $query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)'; |
115 | 162 | $query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']); |
116 | 163 | try { |
@@ -4,55 +4,55 @@ discard block |
||
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | 6 | if (isset($_GET['start_date'])) { |
7 | - //for the date manipulation into the query |
|
8 | - if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
9 | - $start_date = $_GET['start_date'].":00"; |
|
10 | - $end_date = $_GET['end_date'].":00"; |
|
11 | - $sql_date = $start_date.",".$end_date; |
|
12 | - } else if($_GET['start_date'] != ""){ |
|
13 | - $start_date = $_GET['start_date'].":00"; |
|
14 | - $sql_date = $start_date; |
|
15 | - } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
16 | - $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
|
17 | - $sql_date = $end_date; |
|
18 | - } else $sql_date = ''; |
|
7 | + //for the date manipulation into the query |
|
8 | + if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
9 | + $start_date = $_GET['start_date'].":00"; |
|
10 | + $end_date = $_GET['end_date'].":00"; |
|
11 | + $sql_date = $start_date.",".$end_date; |
|
12 | + } else if($_GET['start_date'] != ""){ |
|
13 | + $start_date = $_GET['start_date'].":00"; |
|
14 | + $sql_date = $start_date; |
|
15 | + } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
16 | + $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
|
17 | + $sql_date = $end_date; |
|
18 | + } else $sql_date = ''; |
|
19 | 19 | } else $sql_date = ''; |
20 | 20 | |
21 | 21 | if (isset($_GET['highest_altitude'])) { |
22 | - //for altitude manipulation |
|
23 | - if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
24 | - $end_altitude = $_GET['highest_altitude']; |
|
25 | - $start_altitude = $_GET['lowest_altitude']; |
|
26 | - $sql_altitude = $start_altitude.",".$end_altitude; |
|
27 | - } else if($_GET['highest_altitude'] != ""){ |
|
28 | - $end_altitude = $_GET['highest_altitude']; |
|
29 | - $sql_altitude = $end_altitude; |
|
30 | - } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
31 | - $start_altitude = $_GET['lowest_altitude'].",60000"; |
|
32 | - $sql_altitude = $start_altitude; |
|
33 | - } else $sql_altitude = ''; |
|
22 | + //for altitude manipulation |
|
23 | + if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
24 | + $end_altitude = $_GET['highest_altitude']; |
|
25 | + $start_altitude = $_GET['lowest_altitude']; |
|
26 | + $sql_altitude = $start_altitude.",".$end_altitude; |
|
27 | + } else if($_GET['highest_altitude'] != ""){ |
|
28 | + $end_altitude = $_GET['highest_altitude']; |
|
29 | + $sql_altitude = $end_altitude; |
|
30 | + } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
31 | + $start_altitude = $_GET['lowest_altitude'].",60000"; |
|
32 | + $sql_altitude = $start_altitude; |
|
33 | + } else $sql_altitude = ''; |
|
34 | 34 | } else $sql_altitude = ''; |
35 | 35 | |
36 | 36 | //calculuation for the pagination |
37 | 37 | if(!isset($_GET['limit'])) |
38 | 38 | { |
39 | - if (!isset($_GET['number_results'])) |
|
40 | - { |
|
41 | - $limit_start = 0; |
|
42 | - $limit_end = 25; |
|
43 | - $absolute_difference = 25; |
|
44 | - } else { |
|
45 | - if ($_GET['number_results'] > 1000){ |
|
46 | - $_GET['number_results'] = 1000; |
|
47 | - } |
|
48 | - $limit_start = 0; |
|
49 | - $limit_end = $_GET['number_results']; |
|
50 | - $absolute_difference = $_GET['number_results']; |
|
51 | - } |
|
39 | + if (!isset($_GET['number_results'])) |
|
40 | + { |
|
41 | + $limit_start = 0; |
|
42 | + $limit_end = 25; |
|
43 | + $absolute_difference = 25; |
|
44 | + } else { |
|
45 | + if ($_GET['number_results'] > 1000){ |
|
46 | + $_GET['number_results'] = 1000; |
|
47 | + } |
|
48 | + $limit_start = 0; |
|
49 | + $limit_end = $_GET['number_results']; |
|
50 | + $absolute_difference = $_GET['number_results']; |
|
51 | + } |
|
52 | 52 | } else { |
53 | - $limit_explode = explode(",", $_GET['limit']); |
|
54 | - $limit_start = $limit_explode[0]; |
|
55 | - $limit_end = $limit_explode[1]; |
|
53 | + $limit_explode = explode(",", $_GET['limit']); |
|
54 | + $limit_start = $limit_explode[0]; |
|
55 | + $limit_end = $limit_explode[1]; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | $absolute_difference = abs($limit_start - $limit_end); |
@@ -89,52 +89,52 @@ discard block |
||
89 | 89 | |
90 | 90 | $output = '{'; |
91 | 91 | $output .= '"flightairmap": {'; |
92 | - $output .= '"title": "FlightAirMap JSON Feed",'; |
|
93 | - $output .= '"link": "http://www.flightairmap.fr",'; |
|
94 | - $output .= '"aircraft": ['; |
|
92 | + $output .= '"title": "FlightAirMap JSON Feed",'; |
|
93 | + $output .= '"link": "http://www.flightairmap.fr",'; |
|
94 | + $output .= '"aircraft": ['; |
|
95 | 95 | |
96 | - if (!empty($spotter_array)) |
|
96 | + if (!empty($spotter_array)) |
|
97 | 97 | { |
98 | - foreach($spotter_array as $spotter_item) |
|
99 | - { |
|
98 | + foreach($spotter_array as $spotter_item) |
|
99 | + { |
|
100 | 100 | |
101 | 101 | $output .= '{'; |
102 | - $output .= '"id": "'.$spotter_item['spotter_id'].'",'; |
|
103 | - $output .= '"ident": "'.$spotter_item['ident'].'",'; |
|
104 | - $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
105 | - $output .= '"aircraft_icao": "'.$spotter_item['aircraft_type'].'",'; |
|
106 | - $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].'",'; |
|
107 | - $output .= '"aircraft_manufacturer": "'.$spotter_item['aircraft_manufacturer'].'",'; |
|
108 | - $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
|
109 | - $output .= '"airline_icao": "'.$spotter_item['airline_icao'].'",'; |
|
110 | - $output .= '"airline_iata": "'.$spotter_item['airline_iata'].'",'; |
|
111 | - $output .= '"airline_country": "'.$spotter_item['airline_country'].'",'; |
|
112 | - $output .= '"airline_callsign": "'.$spotter_item['airline_callsign'].'",'; |
|
113 | - $output .= '"airline_type": "'.$spotter_item['airline_type'].'",'; |
|
114 | - $output .= '"departure_airport_city": "'.$spotter_item['departure_airport_city'].'",'; |
|
115 | - $output .= '"departure_airport_country": "'.$spotter_item['departure_airport_country'].'",'; |
|
116 | - $output .= '"departure_airport_iata": "'.$spotter_item['departure_airport_iata'].'",'; |
|
117 | - $output .= '"departure_airport_icao": "'.$spotter_item['departure_airport_icao'].'",'; |
|
118 | - $output .= '"departure_airport_latitude": "'.$spotter_item['departure_airport_latitude'].'",'; |
|
119 | - $output .= '"departure_airport_longitude": "'.$spotter_item['departure_airport_longitude'].'",'; |
|
120 | - $output .= '"departure_airport_altitude": "'.$spotter_item['departure_airport_altitude'].'",'; |
|
121 | - $output .= '"arrival_airport_city": "'.$spotter_item['arrival_airport_city'].'",'; |
|
122 | - $output .= '"arrival_airport_country": "'.$spotter_item['arrival_airport_country'].'",'; |
|
123 | - $output .= '"arrival_airport_iata": "'.$spotter_item['arrival_airport_iata'].'",'; |
|
124 | - $output .= '"departure_airport_icao": "'.$spotter_item['arrival_airport_icao'].'",'; |
|
125 | - $output .= '"arrival_airport_latitude": "'.$spotter_item['arrival_airport_latitude'].'",'; |
|
126 | - $output .= '"arrival_airport_longitude": "'.$spotter_item['arrival_airport_longitude'].'",'; |
|
127 | - $output .= '"arrival_airport_altitude": "'.$spotter_item['arrival_airport_altitude'].'",'; |
|
128 | - $output .= '"latitude": "'.$spotter_item['latitude'].'",'; |
|
129 | - $output .= '"longitude": "'.$spotter_item['longitude'].'",'; |
|
130 | - $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
131 | - $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",'; |
|
132 | - $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
133 | - $output .= '"heading_name": "'.$spotter_item['heading_name'].'",'; |
|
134 | - $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
|
135 | - $output .= '"date": "'.date("c", strtotime($spotter_item['date_iso_8601'])).'"'; |
|
102 | + $output .= '"id": "'.$spotter_item['spotter_id'].'",'; |
|
103 | + $output .= '"ident": "'.$spotter_item['ident'].'",'; |
|
104 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
105 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_type'].'",'; |
|
106 | + $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].'",'; |
|
107 | + $output .= '"aircraft_manufacturer": "'.$spotter_item['aircraft_manufacturer'].'",'; |
|
108 | + $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
|
109 | + $output .= '"airline_icao": "'.$spotter_item['airline_icao'].'",'; |
|
110 | + $output .= '"airline_iata": "'.$spotter_item['airline_iata'].'",'; |
|
111 | + $output .= '"airline_country": "'.$spotter_item['airline_country'].'",'; |
|
112 | + $output .= '"airline_callsign": "'.$spotter_item['airline_callsign'].'",'; |
|
113 | + $output .= '"airline_type": "'.$spotter_item['airline_type'].'",'; |
|
114 | + $output .= '"departure_airport_city": "'.$spotter_item['departure_airport_city'].'",'; |
|
115 | + $output .= '"departure_airport_country": "'.$spotter_item['departure_airport_country'].'",'; |
|
116 | + $output .= '"departure_airport_iata": "'.$spotter_item['departure_airport_iata'].'",'; |
|
117 | + $output .= '"departure_airport_icao": "'.$spotter_item['departure_airport_icao'].'",'; |
|
118 | + $output .= '"departure_airport_latitude": "'.$spotter_item['departure_airport_latitude'].'",'; |
|
119 | + $output .= '"departure_airport_longitude": "'.$spotter_item['departure_airport_longitude'].'",'; |
|
120 | + $output .= '"departure_airport_altitude": "'.$spotter_item['departure_airport_altitude'].'",'; |
|
121 | + $output .= '"arrival_airport_city": "'.$spotter_item['arrival_airport_city'].'",'; |
|
122 | + $output .= '"arrival_airport_country": "'.$spotter_item['arrival_airport_country'].'",'; |
|
123 | + $output .= '"arrival_airport_iata": "'.$spotter_item['arrival_airport_iata'].'",'; |
|
124 | + $output .= '"departure_airport_icao": "'.$spotter_item['arrival_airport_icao'].'",'; |
|
125 | + $output .= '"arrival_airport_latitude": "'.$spotter_item['arrival_airport_latitude'].'",'; |
|
126 | + $output .= '"arrival_airport_longitude": "'.$spotter_item['arrival_airport_longitude'].'",'; |
|
127 | + $output .= '"arrival_airport_altitude": "'.$spotter_item['arrival_airport_altitude'].'",'; |
|
128 | + $output .= '"latitude": "'.$spotter_item['latitude'].'",'; |
|
129 | + $output .= '"longitude": "'.$spotter_item['longitude'].'",'; |
|
130 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
131 | + $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",'; |
|
132 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
133 | + $output .= '"heading_name": "'.$spotter_item['heading_name'].'",'; |
|
134 | + $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
|
135 | + $output .= '"date": "'.date("c", strtotime($spotter_item['date_iso_8601'])).'"'; |
|
136 | 136 | $output .= '},'; |
137 | - } |
|
137 | + } |
|
138 | 138 | } |
139 | 139 | $output = substr($output, 0, -1); |
140 | 140 | $output .= ']'; |
@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | $Spotter = new Spotter(); |
6 | 6 | if (isset($_GET['start_date'])) { |
7 | 7 | //for the date manipulation into the query |
8 | - if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
8 | + if ($_GET['start_date'] != "" && $_GET['end_date'] != "") { |
|
9 | 9 | $start_date = $_GET['start_date'].":00"; |
10 | 10 | $end_date = $_GET['end_date'].":00"; |
11 | 11 | $sql_date = $start_date.",".$end_date; |
12 | - } else if($_GET['start_date'] != ""){ |
|
12 | + } else if ($_GET['start_date'] != "") { |
|
13 | 13 | $start_date = $_GET['start_date'].":00"; |
14 | 14 | $sql_date = $start_date; |
15 | - } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
15 | + } else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") { |
|
16 | 16 | $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
17 | 17 | $sql_date = $end_date; |
18 | 18 | } else $sql_date = ''; |
@@ -20,21 +20,21 @@ discard block |
||
20 | 20 | |
21 | 21 | if (isset($_GET['highest_altitude'])) { |
22 | 22 | //for altitude manipulation |
23 | - if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
23 | + if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") { |
|
24 | 24 | $end_altitude = $_GET['highest_altitude']; |
25 | 25 | $start_altitude = $_GET['lowest_altitude']; |
26 | 26 | $sql_altitude = $start_altitude.",".$end_altitude; |
27 | - } else if($_GET['highest_altitude'] != ""){ |
|
27 | + } else if ($_GET['highest_altitude'] != "") { |
|
28 | 28 | $end_altitude = $_GET['highest_altitude']; |
29 | 29 | $sql_altitude = $end_altitude; |
30 | - } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
30 | + } else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") { |
|
31 | 31 | $start_altitude = $_GET['lowest_altitude'].",60000"; |
32 | 32 | $sql_altitude = $start_altitude; |
33 | 33 | } else $sql_altitude = ''; |
34 | 34 | } else $sql_altitude = ''; |
35 | 35 | |
36 | 36 | //calculuation for the pagination |
37 | -if(!isset($_GET['limit'])) |
|
37 | +if (!isset($_GET['limit'])) |
|
38 | 38 | { |
39 | 39 | if (!isset($_GET['number_results'])) |
40 | 40 | { |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | $limit_end = 25; |
43 | 43 | $absolute_difference = 25; |
44 | 44 | } else { |
45 | - if ($_GET['number_results'] > 1000){ |
|
45 | + if ($_GET['number_results'] > 1000) { |
|
46 | 46 | $_GET['number_results'] = 1000; |
47 | 47 | } |
48 | 48 | $limit_start = 0; |
49 | 49 | $limit_end = $_GET['number_results']; |
50 | 50 | $absolute_difference = $_GET['number_results']; |
51 | 51 | } |
52 | -} else { |
|
52 | +} else { |
|
53 | 53 | $limit_explode = explode(",", $_GET['limit']); |
54 | 54 | $limit_start = $limit_explode[0]; |
55 | 55 | $limit_end = $limit_explode[1]; |
@@ -69,23 +69,23 @@ discard block |
||
69 | 69 | |
70 | 70 | if (isset($_GET['sort'])) $sort = $_GET['sort']; |
71 | 71 | else $sort = ''; |
72 | -$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING); |
|
73 | -$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING); |
|
74 | -$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING); |
|
75 | -$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING); |
|
76 | -$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING); |
|
77 | -$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
78 | -$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING); |
|
79 | -$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING); |
|
80 | -$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING); |
|
81 | -$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING); |
|
82 | -$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING); |
|
83 | -$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING); |
|
84 | -$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING); |
|
85 | -$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING); |
|
86 | -$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING); |
|
87 | -$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING); |
|
88 | -$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,''); |
|
72 | +$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING); |
|
73 | +$registration = filter_input(INPUT_GET, 'registratrion', FILTER_SANITIZE_STRING); |
|
74 | +$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING); |
|
75 | +$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING); |
|
76 | +$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING); |
|
77 | +$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
78 | +$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING); |
|
79 | +$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING); |
|
80 | +$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING); |
|
81 | +$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING); |
|
82 | +$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING); |
|
83 | +$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING); |
|
84 | +$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING); |
|
85 | +$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING); |
|
86 | +$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING); |
|
87 | +$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING); |
|
88 | +$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, ''); |
|
89 | 89 | |
90 | 90 | $output = '{'; |
91 | 91 | $output .= '"flightairmap": {'; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | if (!empty($spotter_array)) |
97 | 97 | { |
98 | - foreach($spotter_array as $spotter_item) |
|
98 | + foreach ($spotter_array as $spotter_item) |
|
99 | 99 | { |
100 | 100 | |
101 | 101 | $output .= '{'; |
@@ -15,8 +15,12 @@ discard block |
||
15 | 15 | } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
16 | 16 | $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
17 | 17 | $sql_date = $end_date; |
18 | - } else $sql_date = ''; |
|
19 | -} else $sql_date = ''; |
|
18 | + } else { |
|
19 | + $sql_date = ''; |
|
20 | + } |
|
21 | + } else { |
|
22 | + $sql_date = ''; |
|
23 | +} |
|
20 | 24 | |
21 | 25 | if (isset($_GET['highest_altitude'])) { |
22 | 26 | //for altitude manipulation |
@@ -30,8 +34,12 @@ discard block |
||
30 | 34 | } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
31 | 35 | $start_altitude = $_GET['lowest_altitude'].",60000"; |
32 | 36 | $sql_altitude = $start_altitude; |
33 | - } else $sql_altitude = ''; |
|
34 | -} else $sql_altitude = ''; |
|
37 | + } else { |
|
38 | + $sql_altitude = ''; |
|
39 | + } |
|
40 | + } else { |
|
41 | + $sql_altitude = ''; |
|
42 | +} |
|
35 | 43 | |
36 | 44 | //calculuation for the pagination |
37 | 45 | if(!isset($_GET['limit'])) |
@@ -49,7 +57,7 @@ discard block |
||
49 | 57 | $limit_end = $_GET['number_results']; |
50 | 58 | $absolute_difference = $_GET['number_results']; |
51 | 59 | } |
52 | -} else { |
|
60 | +} else { |
|
53 | 61 | $limit_explode = explode(",", $_GET['limit']); |
54 | 62 | $limit_start = $limit_explode[0]; |
55 | 63 | $limit_end = $limit_explode[1]; |
@@ -67,8 +75,11 @@ discard block |
||
67 | 75 | |
68 | 76 | header('Content-Type: application/json'); |
69 | 77 | |
70 | -if (isset($_GET['sort'])) $sort = $_GET['sort']; |
|
71 | -else $sort = ''; |
|
78 | +if (isset($_GET['sort'])) { |
|
79 | + $sort = $_GET['sort']; |
|
80 | +} else { |
|
81 | + $sort = ''; |
|
82 | +} |
|
72 | 83 | $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING); |
73 | 84 | $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING); |
74 | 85 | $aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING); |
@@ -3,15 +3,15 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
7 | -$registration = filter_input(INPUT_GET,'registration',FILTER_SANITIZE_STRING); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | +$registration = filter_input(INPUT_GET, 'registration', FILTER_SANITIZE_STRING); |
|
8 | 8 | $spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,1", $sort); |
9 | 9 | $aircraft_array = $Spotter->getAircraftInfoByRegistration($registration); |
10 | 10 | |
11 | 11 | |
12 | 12 | if (!empty($spotter_array)) |
13 | 13 | { |
14 | - $title = sprintf(_("Most Common Routes from aircraft with registration %s"),$registration); |
|
14 | + $title = sprintf(_("Most Common Routes from aircraft with registration %s"), $registration); |
|
15 | 15 | |
16 | 16 | require_once('header.php'); |
17 | 17 | print '<div class="info column">'; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | include('registration-sub-menu.php'); |
25 | 25 | print '<div class="column">'; |
26 | 26 | print '<h2>'._("Most Common Routes").'</h2>'; |
27 | - print '<p>'.sprintf(_("The statistic below shows the most common routes of aircraft with registration <strong>%s</strong>."),$registration).'</p>'; |
|
27 | + print '<p>'.sprintf(_("The statistic below shows the most common routes of aircraft with registration <strong>%s</strong>."), $registration).'</p>'; |
|
28 | 28 | |
29 | 29 | $route_array = $Spotter->countAllRoutesByRegistration($registration); |
30 | 30 | if (!empty($route_array)) |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | print '</thead>'; |
41 | 41 | print '<tbody>'; |
42 | 42 | $i = 1; |
43 | - foreach($route_array as $route_item) |
|
43 | + foreach ($route_array as $route_item) |
|
44 | 44 | { |
45 | 45 | print '<tr>'; |
46 | 46 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -8,7 +8,9 @@ |
||
8 | 8 | $registration = filter_input(INPUT_GET,'registration',FILTER_SANITIZE_STRING); |
9 | 9 | $spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,1", $sort); |
10 | 10 | $aircraft_array = $Spotter->getAircraftInfoByRegistration($registration); |
11 | -} else $spotter_array = array(); |
|
11 | +} else { |
|
12 | + $spotter_array = array(); |
|
13 | +} |
|
12 | 14 | |
13 | 15 | if (!empty($spotter_array)) |
14 | 16 | { |
@@ -3,16 +3,16 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | 7 | if (isset($_GET['registration'])) { |
8 | - $registration = filter_input(INPUT_GET,'registration',FILTER_SANITIZE_STRING); |
|
8 | + $registration = filter_input(INPUT_GET, 'registration', FILTER_SANITIZE_STRING); |
|
9 | 9 | $spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,1", $sort); |
10 | 10 | $aircraft_array = $Spotter->getAircraftInfoByRegistration($registration); |
11 | 11 | } else $spotter_array = array(); |
12 | 12 | |
13 | 13 | if (!empty($spotter_array)) |
14 | 14 | { |
15 | - $title = sprintf(_("Most Common Departure Airports by Country of aircraft with registration %s"),$registration); |
|
15 | + $title = sprintf(_("Most Common Departure Airports by Country of aircraft with registration %s"), $registration); |
|
16 | 16 | require_once('header.php'); |
17 | 17 | print '<div class="info column">'; |
18 | 18 | print '<h1>'.$registration.' - '.$aircraft_array[0]['aircraft_name'].' ('.$aircraft_array[0]['aircraft_icao'].')</h1>'; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | include('registration-sub-menu.php'); |
25 | 25 | print '<div class="column">'; |
26 | 26 | print '<h2>'._("Most Common Departure Airports by Country").'</h2>'; |
27 | - print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with aircraft registration <strong>%s</strong>."),$registration).'</p>'; |
|
27 | + print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with aircraft registration <strong>%s</strong>."), $registration).'</p>'; |
|
28 | 28 | $airport_country_array = $Spotter->countAllDepartureAirportCountriesByRegistration($registration); |
29 | 29 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
30 | 30 | print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>'; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
33 | 33 | print 'var series = ['; |
34 | 34 | $country_data = ''; |
35 | - foreach($airport_country_array as $airport_item) |
|
35 | + foreach ($airport_country_array as $airport_item) |
|
36 | 36 | { |
37 | 37 | $country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],'; |
38 | 38 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | print '</thead>'; |
81 | 81 | print '<tbody>'; |
82 | 82 | $i = 1; |
83 | - foreach($airport_country_array as $airport_item) |
|
83 | + foreach ($airport_country_array as $airport_item) |
|
84 | 84 | { |
85 | 85 | print '<tr>'; |
86 | 86 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | die(); |
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | -$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
|
11 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
10 | +$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'country', FILTER_SANITIZE_STRING))); |
|
11 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
12 | 12 | if (isset($_GET['sort'])) { |
13 | 13 | $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort); |
14 | 14 | } else { |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | |
18 | 18 | if (!empty($spotter_array)) |
19 | 19 | { |
20 | - $title = sprintf(_("Most Common Airlines of %s"),$country); |
|
20 | + $title = sprintf(_("Most Common Airlines of %s"), $country); |
|
21 | 21 | require_once('header.php'); |
22 | 22 | print '<div class="select-item">'; |
23 | 23 | print '<form action="'.$globalURL.'/country" method="post">'; |
24 | 24 | print '<select name="country" class="selectpicker" data-live-search="true">'; |
25 | 25 | print '<option></option>'; |
26 | 26 | $all_countries = $Spotter->getAllCountries(); |
27 | - foreach($all_countries as $all_country) |
|
27 | + foreach ($all_countries as $all_country) |
|
28 | 28 | { |
29 | - if($country == $all_country['country']) |
|
29 | + if ($country == $all_country['country']) |
|
30 | 30 | { |
31 | 31 | print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>'; |
32 | 32 | } else { |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | if ($_GET['country'] != "NA") |
42 | 42 | { |
43 | 43 | print '<div class="info column">'; |
44 | - print '<h1>'.sprintf(_("Airports & Airlines from %s"),$country).'</h1>'; |
|
44 | + print '<h1>'.sprintf(_("Airports & Airlines from %s"), $country).'</h1>'; |
|
45 | 45 | print '</div>'; |
46 | 46 | } else { |
47 | 47 | print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>'; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | include('country-sub-menu.php'); |
51 | 51 | print '<div class="column">'; |
52 | 52 | print '<h2>'._("Most Common Airlines").'</h2>'; |
53 | - print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights from airports & airlines of <strong>%s</strong>."),$country).'</p>'; |
|
53 | + print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights from airports & airlines of <strong>%s</strong>."), $country).'</p>'; |
|
54 | 54 | |
55 | 55 | $airline_array = $Spotter->countAllAirlinesByCountry($country); |
56 | 56 | if (!empty($airline_array)) |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | print '</thead>'; |
67 | 67 | print '<tbody>'; |
68 | 68 | $i = 1; |
69 | - foreach($airline_array as $airline_item) |
|
69 | + foreach ($airline_array as $airline_item) |
|
70 | 70 | { |
71 | 71 | print '<tr>'; |
72 | 72 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,8 +3,8 @@ |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['country'])) { |
6 | - header('Location: '.$globalURL.'/country'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/country'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
@@ -13,7 +13,7 @@ |
||
13 | 13 | $limit_start = 0; |
14 | 14 | $limit_end = 25; |
15 | 15 | $absolute_difference = 25; |
16 | - } else { |
|
16 | + } else { |
|
17 | 17 | $limit_explode = explode(",", $_GET['limit']); |
18 | 18 | $limit_start = $limit_explode[0]; |
19 | 19 | $limit_end = $limit_explode[1]; |
@@ -3,17 +3,17 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | |
6 | -if (!isset($_GET['country'])){ |
|
6 | +if (!isset($_GET['country'])) { |
|
7 | 7 | header('Location: '.$globalURL.''); |
8 | 8 | } else { |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | //calculuation for the pagination |
11 | - if(!isset($_GET['limit'])) |
|
11 | + if (!isset($_GET['limit'])) |
|
12 | 12 | { |
13 | 13 | $limit_start = 0; |
14 | 14 | $limit_end = 25; |
15 | 15 | $absolute_difference = 25; |
16 | - } else { |
|
16 | + } else { |
|
17 | 17 | $limit_explode = explode(",", $_GET['limit']); |
18 | 18 | $limit_start = $limit_explode[0]; |
19 | 19 | $limit_end = $limit_explode[1]; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $country = ucwords(str_replace("-", " ", $_GET['country'])); |
31 | 31 | |
32 | 32 | $page_url = $globalURL.'/country/'.$_GET['country']; |
33 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
33 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
34 | 34 | if ($sort != '') { |
35 | 35 | $spotter_array = $Spotter->getSpotterDataByCountry($country, $limit_start.",".$absolute_difference, $sort); |
36 | 36 | } else { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | if (!empty($spotter_array)) |
41 | 41 | { |
42 | - $title = sprintf(_("Detailed View for Airports & Airlines from %s"),$country); |
|
42 | + $title = sprintf(_("Detailed View for Airports & Airlines from %s"), $country); |
|
43 | 43 | |
44 | 44 | require_once('header.php'); |
45 | 45 | print '<div class="select-item">'; |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | print '<select name="country" class="selectpicker" data-live-search="true">'; |
48 | 48 | print '<option></option>'; |
49 | 49 | $all_countries = $Spotter->getAllCountries(); |
50 | - foreach($all_countries as $all_country) |
|
50 | + foreach ($all_countries as $all_country) |
|
51 | 51 | { |
52 | - if($country == $all_country['country']) |
|
52 | + if ($country == $all_country['country']) |
|
53 | 53 | { |
54 | 54 | print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>'; |
55 | 55 | } else { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | if ($_GET['country'] != "NA") |
65 | 65 | { |
66 | 66 | print '<div class="info column">'; |
67 | - print '<h1>'.sprintf(_("Airports & Airlines from %s"),$country).'</h1>'; |
|
67 | + print '<h1>'.sprintf(_("Airports & Airlines from %s"), $country).'</h1>'; |
|
68 | 68 | print '</div>'; |
69 | 69 | } else { |
70 | 70 | print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>'; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | include('country-sub-menu.php'); |
74 | 74 | print '<div class="table column">'; |
75 | - print '<p>'.sprintf(_("The table below shows the detailed information of all flights of airports (both departure & arrival) OR airlines from <strong>%s</strong>."),$country).'</p>'; |
|
75 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights of airports (both departure & arrival) OR airlines from <strong>%s</strong>."), $country).'</p>'; |
|
76 | 76 | |
77 | 77 | include('table-output.php'); |
78 | 78 | print '<div class="pagination">'; |
@@ -11,12 +11,12 @@ |
||
11 | 11 | //checks to see if FlightAware import is set |
12 | 12 | if ($globalFlightAware == TRUE) |
13 | 13 | { |
14 | - $SpotterLive = new SpotterLive(); |
|
15 | - $Spotter = new Spotter(); |
|
16 | - //deletes the spotter LIVE data |
|
17 | - $SpotterLive->deleteLiveSpotterData(); |
|
14 | + $SpotterLive = new SpotterLive(); |
|
15 | + $Spotter = new Spotter(); |
|
16 | + //deletes the spotter LIVE data |
|
17 | + $SpotterLive->deleteLiveSpotterData(); |
|
18 | 18 | |
19 | - //imports the new data from FlightAware |
|
20 | - $Spotter->importFromFlightAware(); |
|
19 | + //imports the new data from FlightAware |
|
20 | + $Spotter->importFromFlightAware(); |
|
21 | 21 | } |
22 | 22 | ?> |
23 | 23 | \ No newline at end of file |
@@ -5,8 +5,8 @@ |
||
5 | 5 | */ |
6 | 6 | require_once(dirname(__FILE__).'/../require/settings.php'); |
7 | 7 | if ($globalInstalled) { |
8 | - echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
9 | - exit; |
|
8 | + echo '$globalInstalled must be set to FALSE in require/settings.php'; |
|
9 | + exit; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | require_once('../require/class.Connection.php'); |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
12 | 12 | $schema = new Connection(); |
13 | 13 | if ($schema->latest() === false) { |
14 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
15 | - exit(); |
|
14 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
15 | + exit(); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | $debug = true; |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | date_default_timezone_set('UTC'); |
22 | 22 | // signal handler - playing nice with sockets and dump1090 |
23 | 23 | pcntl_signal(SIGINT, function($signo) { |
24 | - global $sock; |
|
25 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
26 | - socket_shutdown($sock, 0); |
|
27 | - socket_close($sock); |
|
28 | - die("Bye!\n"); |
|
24 | + global $sock; |
|
25 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
26 | + socket_shutdown($sock, 0); |
|
27 | + socket_close($sock); |
|
28 | + die("Bye!\n"); |
|
29 | 29 | }); |
30 | 30 | pcntl_signal_dispatch(); |
31 | 31 | |
@@ -38,24 +38,24 @@ discard block |
||
38 | 38 | // Bind the source address |
39 | 39 | if( !socket_bind($sock, $globalACARSHost , $globalACARSPort) ) |
40 | 40 | { |
41 | - $errorcode = socket_last_error(); |
|
42 | - $errormsg = socket_strerror($errorcode); |
|
41 | + $errorcode = socket_last_error(); |
|
42 | + $errormsg = socket_strerror($errorcode); |
|
43 | 43 | |
44 | - die("Could not bind socket : [$errorcode] $errormsg \n"); |
|
44 | + die("Could not bind socket : [$errorcode] $errormsg \n"); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | echo "LISTEN UDP MODE \n\n"; |
48 | 48 | while(1) { |
49 | - $r = socket_recvfrom($sock, $buffer, 512, 0, $remote_ip, $remote_port); |
|
50 | - |
|
51 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
52 | - pcntl_signal_dispatch(); |
|
53 | - $dataFound = false; |
|
54 | - // (null) 2 23/02/2015 14:46:06 0 -16 X .D-AIPW ! 1L 7 M82A LH077P 010952342854:VP-MIBI+W+0)-V+(),GB1 |
|
55 | - echo $buffer."\n"; |
|
56 | - $ACARS->add(trim($buffer)); |
|
57 | - socket_sendto($sock, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
58 | - $ACARS->deleteLiveAcarsData(); |
|
49 | + $r = socket_recvfrom($sock, $buffer, 512, 0, $remote_ip, $remote_port); |
|
50 | + |
|
51 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
52 | + pcntl_signal_dispatch(); |
|
53 | + $dataFound = false; |
|
54 | + // (null) 2 23/02/2015 14:46:06 0 -16 X .D-AIPW ! 1L 7 M82A LH077P 010952342854:VP-MIBI+W+0)-V+(),GB1 |
|
55 | + echo $buffer."\n"; |
|
56 | + $ACARS->add(trim($buffer)); |
|
57 | + socket_sendto($sock, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
58 | + $ACARS->deleteLiveAcarsData(); |
|
59 | 59 | } |
60 | 60 | pcntl_exec($_,$argv); |
61 | 61 | ?> |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | |
18 | 18 | $debug = true; |
19 | 19 | |
20 | -$ACARS=new ACARS(); |
|
20 | +$ACARS = new ACARS(); |
|
21 | 21 | date_default_timezone_set('UTC'); |
22 | 22 | // signal handler - playing nice with sockets and dump1090 |
23 | -pcntl_signal(SIGINT, function($signo) { |
|
23 | +pcntl_signal(SIGINT, function($signo) { |
|
24 | 24 | global $sock; |
25 | 25 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
26 | 26 | socket_shutdown($sock, 0); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $sock = socket_create(AF_INET, SOCK_DGRAM, 0) or die("Unable to create socket\n"); |
37 | 37 | |
38 | 38 | // Bind the source address |
39 | -if( !socket_bind($sock, $globalACARSHost , $globalACARSPort) ) |
|
39 | +if (!socket_bind($sock, $globalACARSHost, $globalACARSPort)) |
|
40 | 40 | { |
41 | 41 | $errorcode = socket_last_error(); |
42 | 42 | $errormsg = socket_strerror($errorcode); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | echo "LISTEN UDP MODE \n\n"; |
48 | -while(1) { |
|
48 | +while (1) { |
|
49 | 49 | $r = socket_recvfrom($sock, $buffer, 512, 0, $remote_ip, $remote_port); |
50 | 50 | |
51 | 51 | // lets play nice and handle signals such as ctrl-c/kill properly |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | // (null) 2 23/02/2015 14:46:06 0 -16 X .D-AIPW ! 1L 7 M82A LH077P 010952342854:VP-MIBI+W+0)-V+(),GB1 |
55 | 55 | echo $buffer."\n"; |
56 | 56 | $ACARS->add(trim($buffer)); |
57 | - socket_sendto($sock, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
57 | + socket_sendto($sock, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
58 | 58 | $ACARS->deleteLiveAcarsData(); |
59 | 59 | } |
60 | -pcntl_exec($_,$argv); |
|
60 | +pcntl_exec($_, $argv); |
|
61 | 61 | ?> |