Completed
Push — master ( 6eadb9...5e27ff )
by Yannick
09:33
created
airport-geojson.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 if (isset($_GET['coord'])) 
13 13
 {
14
-	$coords = explode(',',$_GET['coord']);
14
+	$coords = explode(',', $_GET['coord']);
15 15
 	$spotter_array = $Spotter->getAllAirportInfobyCoord($coords);
16 16
 } else {
17 17
 	$spotter_array = $Spotter->getAllAirportInfo();
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
             
23 23
 if (!empty($spotter_array))
24 24
 {	  
25
-	foreach($spotter_array as $spotter_item)
25
+	foreach ($spotter_array as $spotter_item)
26 26
 	{
27 27
 		date_default_timezone_set('UTC');
28 28
 		//waypoint plotting
29 29
 		$output .= '{"type": "Feature",';
30 30
 		    $output .= '"properties": {';
31
-			$output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",';
32
-			$output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",';
31
+			$output .= '"name": "'.str_replace('"', "'", $spotter_item['name']).'",';
32
+			$output .= '"city": "'.str_replace('"', "'", $spotter_item['city']).'",';
33 33
 			$output .= '"country": "'.$spotter_item['country'].'",';
34 34
 			$output .= '"altitude": "'.$spotter_item['altitude'].'",';
35
-			$output .= '"popupContent": "'.str_replace('"',"'",$spotter_item['name']).' : '.str_replace('"',"'",$spotter_item['city']).', '.$spotter_item['country'].'",';
35
+			$output .= '"popupContent": "'.str_replace('"', "'", $spotter_item['name']).' : '.str_replace('"', "'", $spotter_item['city']).', '.$spotter_item['country'].'",';
36 36
 			if ($spotter_item['type'] == 'large_airport') {
37 37
 				$output .= '"icon": "'.$globalURL.'/images/airport.png",';
38 38
 			} elseif ($spotter_item['type'] == 'heliport') {
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		date_default_timezone_set('UTC');
28 28
 		//waypoint plotting
29 29
 		$output .= '{"type": "Feature",';
30
-		    $output .= '"properties": {';
30
+			$output .= '"properties": {';
31 31
 			$output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",';
32 32
 			$output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",';
33 33
 			$output .= '"country": "'.$spotter_item['country'].'",';
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 			$output .= '"homepage": "'.$spotter_item['home_link'].'",';
51 51
 			$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
52 52
 //			$output .= '"photo": "'.$spotter_item['image_thumbnail'].'",';
53
-		    $output .= '},';
54
-		    $output .= '"geometry": {';
53
+			$output .= '},';
54
+			$output .= '"geometry": {';
55 55
 			$output .= '"type": "Point",';
56 56
 			$output .= '"coordinates": [';
57
-			    $output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
57
+				$output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
58 58
 			$output .= ']';
59
-		    $output .= '}';
59
+			$output .= '}';
60 60
 		$output .= '},';
61 61
 	}
62 62
 }
Please login to merge, or discard this patch.
require/class.ACARS.php 3 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
 		$this->SI = new SpotterImport($this->db);
17 17
 	}
18 18
 	/**
19
-	* Change IATA to ICAO value for ident
20
-	*
21
-	* @param String $ident ident
22
-	* @return String the icao
23
-	*/
19
+	 * Change IATA to ICAO value for ident
20
+	 *
21
+	 * @param String $ident ident
22
+	 * @return String the icao
23
+	 */
24 24
 	public function ident2icao($ident) {
25 25
 		if (substr($ident,0,2) == 'AF') {
26 26
 			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 	}
37 37
 
38 38
 	/**
39
-	* Deletes all info in the live table
40
-	*
41
-	* @return String success or false
42
-	*
43
-	*/
39
+	 * Deletes all info in the live table
40
+	 *
41
+	 * @return String success or false
42
+	 *
43
+	 */
44 44
 	public function deleteLiveAcarsData()
45 45
 	{
46 46
 		global $globalDBdriver;
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 
62 62
 	/**
63
-	* Deletes all info in the archive table
64
-	*
65
-	* @return String success or false
66
-	*
67
-	*/
63
+	 * Deletes all info in the archive table
64
+	 *
65
+	 * @return String success or false
66
+	 *
67
+	 */
68 68
 	public function deleteArchiveAcarsData()
69 69
 	{
70 70
 		global $globalACARSArchiveKeepMonths, $globalDBdriver;
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 
86 86
 
87 87
 	/**
88
-	* Parse ACARS data
89
-	*
90
-	* @param String ACARS data in acarsdec data
91
-	*
92
-	*/
88
+	 * Parse ACARS data
89
+	 *
90
+	 * @param String ACARS data in acarsdec data
91
+	 *
92
+	 */
93 93
 	public function parse($data) {
94 94
 		global $globalDebug, $globalACARSArchive;
95 95
 		//$Image = new Image($this->db);
@@ -666,11 +666,11 @@  discard block
 block discarded – undo
666 666
 
667 667
 
668 668
 	/**
669
-	* Add ACARS data
670
-	*
671
-	* @param String ACARS data in acarsdec data
672
-	*
673
-	*/
669
+	 * Add ACARS data
670
+	 *
671
+	 * @param String ACARS data in acarsdec data
672
+	 *
673
+	 */
674 674
 	function add($data) {
675 675
 		global $globalDebug, $globalACARSArchive;
676 676
 		$Image = new Image($this->db);
@@ -725,15 +725,15 @@  discard block
 block discarded – undo
725 725
 	}
726 726
 
727 727
 	/**
728
-	* Add Live ACARS data in DB
729
-	*
730
-	* @param String $ident ident
731
-	* @param String $registration Registration of the aircraft
732
-	* @param String $label Label of the ACARS message
733
-	* @param String $block_id Block id of the ACARS message
734
-	* @param String $msg_no Number of the ACARS message
735
-	* @param String $message ACARS message
736
-	*/
728
+	 * Add Live ACARS data in DB
729
+	 *
730
+	 * @param String $ident ident
731
+	 * @param String $registration Registration of the aircraft
732
+	 * @param String $label Label of the ACARS message
733
+	 * @param String $block_id Block id of the ACARS message
734
+	 * @param String $msg_no Number of the ACARS message
735
+	 * @param String $message ACARS message
736
+	 */
737 737
 	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
738 738
 		global $globalDebug;
739 739
 		date_default_timezone_set('UTC');
@@ -771,15 +771,15 @@  discard block
 block discarded – undo
771 771
 	}
772 772
 
773 773
 	/**
774
-	* Add Archive ACARS data in DB
775
-	*
776
-	* @param String $ident ident
777
-	* @param String $registration Registration of the aircraft
778
-	* @param String $label Label of the ACARS message
779
-	* @param String $block_id Block id of the ACARS message
780
-	* @param String $msg_no Number of the ACARS message
781
-	* @param String $message ACARS message
782
-	*/
774
+	 * Add Archive ACARS data in DB
775
+	 *
776
+	 * @param String $ident ident
777
+	 * @param String $registration Registration of the aircraft
778
+	 * @param String $label Label of the ACARS message
779
+	 * @param String $block_id Block id of the ACARS message
780
+	 * @param String $msg_no Number of the ACARS message
781
+	 * @param String $message ACARS message
782
+	 */
783 783
 	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
784 784
 		global $globalDebug;
785 785
 		date_default_timezone_set('UTC');
@@ -813,11 +813,11 @@  discard block
 block discarded – undo
813 813
 	}
814 814
 
815 815
 	/**
816
-	* Get Message title from label from DB
817
-	*
818
-	* @param String $label
819
-	* @return String Return ACARS title
820
-	*/
816
+	 * Get Message title from label from DB
817
+	 *
818
+	 * @param String $label
819
+	 * @return String Return ACARS title
820
+	 */
821 821
 	public function getTitlefromLabel($label) {
822 822
 		$Connection = new Connection($this->db);
823 823
 		$this->db = $Connection->db;
@@ -837,10 +837,10 @@  discard block
 block discarded – undo
837 837
 	}
838 838
 
839 839
 	/**
840
-	* List all Message title & label from DB
841
-	*
842
-	* @return Array Return ACARS data in array
843
-	*/
840
+	 * List all Message title & label from DB
841
+	 *
842
+	 * @return Array Return ACARS data in array
843
+	 */
844 844
 	public function getAllTitleLabel() {
845 845
 		$query = "SELECT * FROM acars_label ORDER BY title";
846 846
 		$query_values = array();
@@ -858,11 +858,11 @@  discard block
 block discarded – undo
858 858
 	}
859 859
 
860 860
 	/**
861
-	* Get Live ACARS data from DB
862
-	*
863
-	* @param String $ident
864
-	* @return Array Return ACARS data in array
865
-	*/
861
+	 * Get Live ACARS data from DB
862
+	 *
863
+	 * @param String $ident
864
+	 * @return Array Return ACARS data in array
865
+	 */
866 866
 	public function getLiveAcarsData($ident) {
867 867
 		$query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC";
868 868
 		$query_values = array(':ident' => $ident);
@@ -880,10 +880,10 @@  discard block
 block discarded – undo
880 880
 	}
881 881
 
882 882
 	/**
883
-	* Get Latest ACARS data from DB
884
-	*
885
-	* @return Array Return ACARS data in array
886
-	*/
883
+	 * Get Latest ACARS data from DB
884
+	 *
885
+	 * @return Array Return ACARS data in array
886
+	 */
887 887
 	public function getLatestAcarsData($limit = '',$label = '') {
888 888
 		global $globalURL, $globalDBdriver;
889 889
 		$Image = new Image($this->db);
@@ -980,10 +980,10 @@  discard block
 block discarded – undo
980 980
 	}
981 981
 
982 982
 	/**
983
-	* Get Archive ACARS data from DB
984
-	*
985
-	* @return Array Return ACARS data in array
986
-	*/
983
+	 * Get Archive ACARS data from DB
984
+	 *
985
+	 * @return Array Return ACARS data in array
986
+	 */
987 987
 	public function getArchiveAcarsData($limit = '',$label = '') {
988 988
 		global $globalURL, $globalDBdriver;
989 989
 		$Image = new Image($this->db);
@@ -1085,13 +1085,13 @@  discard block
 block discarded – undo
1085 1085
 	}
1086 1086
 
1087 1087
 	/**
1088
-	* Add ModeS data to DB
1089
-	*
1090
-	* @param String $ident ident
1091
-	* @param String $registration Registration of the aircraft
1092
-	* @param String $icao
1093
-	* @param String $ICAOTypeCode
1094
-	*/
1088
+	 * Add ModeS data to DB
1089
+	 *
1090
+	 * @param String $ident ident
1091
+	 * @param String $registration Registration of the aircraft
1092
+	 * @param String $icao
1093
+	 * @param String $ICAOTypeCode
1094
+	 */
1095 1095
 	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1096 1096
 		global $globalDebug, $globalDBdriver;
1097 1097
 		$ident = trim($ident);
Please login to merge, or discard this patch.
Spacing   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 	* @return String the icao
23 23
 	*/
24 24
 	public function ident2icao($ident) {
25
-		if (substr($ident,0,2) == 'AF') {
26
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
25
+		if (substr($ident, 0, 2) == 'AF') {
26
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
28 28
 		} else {
29 29
 			$Spotter = new Spotter($this->db);
30
-			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
30
+			$identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2));
31 31
 			if (isset($identicao[0])) {
32
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
32
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
33 33
 			} else $icao = $ident;
34 34
 		}
35 35
 		return $icao;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 			$sth = $this->db->prepare($query);
55 55
 			$sth->execute();
56
-		} catch(PDOException $e) {
56
+		} catch (PDOException $e) {
57 57
 			return "error";
58 58
 		}
59 59
 		return "success";
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 			$sth = $this->db->prepare($query);
79 79
 			$sth->execute();
80
-		} catch(PDOException $e) {
80
+		} catch (PDOException $e) {
81 81
 			return "error";
82 82
 		}
83 83
 		return "success";
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
 		$ident = '';
103 103
 		$message = '';
104 104
 		$result = array();
105
-		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
106
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
107
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
108
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
105
+		$n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
106
+		if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
107
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
108
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
109 109
 		if ($n != 0) {
110
-			$registration = str_replace('.','',$registration);
111
-			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
110
+			$registration = str_replace('.', '', $registration);
111
+			$result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message);
112 112
 			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
113 113
 		} else $message = $data;
114 114
 		$decode = array();
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 				$temp = '';
129 129
 				$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp);
130 130
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
131
-					$latitude = $la / 10000.0;
132
-					$longitude = $ln / 10000.0;
131
+					$latitude = $la/10000.0;
132
+					$longitude = $ln/10000.0;
133 133
 					if ($lac == 'S') $latitude = '-'.$latitude;
134 134
 					if ($lnc == 'W') $longitude = '-'.$longitude;
135 135
 					// Temp not always available
136 136
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
137
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
138
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
137
+					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
138
+					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C');
139 139
 
140 140
 					//$icao = $Translation->checkTranslation($ident);
141 141
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -147,19 +147,19 @@  discard block
 block discarded – undo
147 147
 				$dhour = '';
148 148
 				$darr = '';
149 149
 				$ahour = '';
150
-				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
150
+				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
151 151
 				if ($n == 4 && strlen($darr) == 4) {
152
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
153
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
154
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
152
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
153
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
154
+					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n";
155 155
 					//$icao = ACARS->ident2icao($ident);
156 156
 					//$icao = $Translation->checkTranslation($ident);
157 157
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
158 158
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
159 159
 					$found = true;
160 160
 				}
161
-				elseif ($n == 2 || $n  == 4) {
162
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
161
+				elseif ($n == 2 || $n == 4) {
162
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
163 163
 					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
164 164
 					//$icao = ACARS->ident2icao($ident);
165 165
 					//$icao = $Translation->checkTranslation($ident);
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 				$ahour = '';
218 218
 				$aair = '';
219 219
 				$apiste = '';
220
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
220
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste);
221 221
 				if ($n > 8) {
222
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
224
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
222
+					if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
224
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
225 225
 					$icao = trim($aident);
226 226
 
227 227
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 				if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
247 247
 					$las = $las.'.'.$lass;
248 248
 					$lns = $lns.'.'.$lns;
249
-					$latitude = $las / 1000.0;
250
-					$longitude = $lns / 1000.0;
249
+					$latitude = $las/1000.0;
250
+					$longitude = $lns/1000.0;
251 251
 					if ($lac == 'S') $latitude = '-'.$latitude;
252 252
 					if ($lnc == 'W') $longitude = '-'.$longitude;
253 253
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
@@ -342,17 +342,17 @@  discard block
 block discarded – undo
342 342
 				$alt = '';
343 343
 				$fuel = '';
344 344
 				$speed = '';
345
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
345
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
346 346
 				if ($n == 9) {
347 347
 					//if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
348 348
 					$icao = trim($aident);
349 349
 					$decode['icao'] = $icao;
350
-					$latitude = $las / 100.0;
351
-					$longitude = $lns / 100.0;
350
+					$latitude = $las/100.0;
351
+					$longitude = $lns/100.0;
352 352
 					if ($lac == 'S') $latitude = '-'.$latitude;
353 353
 					if ($lnc == 'W') $longitude = '-'.$longitude;
354 354
 
355
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
355
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed);
356 356
 					$found = true;
357 357
 				}
358 358
 			}
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 					if ($lac == 'S') $latitude = '-'.$latitude;
372 372
 					if ($lnc == 'W') $longitude = '-'.$longitude;
373 373
 
374
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
374
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
375 375
 					$found = true;
376 376
 				}
377 377
 			}
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 				$dair = '';
405 405
 				$darr = '';
406 406
 				$aident = '';
407
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
407
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
408 408
 				if ($n == 8) {
409 409
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
410 410
 					$icao = trim($aident);
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 				*/
438 438
 				$dair = '';
439 439
 				$darr = '';
440
-				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
440
+				$n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
441 441
 				if ($n == 3) {
442 442
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
443 443
 					//$icao = $Translation->checkTranslation($ident);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 				*/
454 454
 				$dair = '';
455 455
 				$darr = '';
456
-				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
456
+				$n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
457 457
 				if ($n == 3) {
458 458
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
459 459
 					//$icao = $Translation->checkTranslation($ident);
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 				}
465 465
 			}
466 466
 			if (!$found) {
467
-				$n = sscanf($message,'MET01%4c',$airport);
467
+				$n = sscanf($message, 'MET01%4c', $airport);
468 468
 				if ($n == 1) {
469 469
 					if ($globalDebug) echo 'airport name : '.$airport;
470 470
 					$decode = array('Airport/Waypoint name' => $airport);
@@ -473,241 +473,241 @@  discard block
 block discarded – undo
473 473
 			}
474 474
 
475 475
 			if ($label == 'H1') {
476
-				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
477
-					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
476
+				if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
477
+					$decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
478 478
 				}
479
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
480
-					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
479
+				elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
480
+					$decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
481 481
 				}
482
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
483
-					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
482
+				elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
483
+					$decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
484 484
 				}
485
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
486
-					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
485
+				elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
486
+					$decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
487 487
 				}
488
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
489
-					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
488
+				elseif (preg_match(':^#DFB/PIREP:', $message)) {
489
+					$decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
490 490
 				}
491
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
492
-					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
491
+				elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
492
+					$decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
493 493
 				}
494
-				elseif (preg_match(':^#M1AAEP:',$message)) {
495
-					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
494
+				elseif (preg_match(':^#M1AAEP:', $message)) {
495
+					$decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
496 496
 				}
497
-				elseif (preg_match(':^#M2APWD:',$message)) {
498
-					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
497
+				elseif (preg_match(':^#M2APWD:', $message)) {
498
+					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
499 499
 				}
500
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
501
-					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
500
+				elseif (preg_match(':^#M1BREQPWI:', $message)) {
501
+					$decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
502 502
 				}
503
-				elseif (preg_match(':^#CF:',$message)) {
504
-					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
503
+				elseif (preg_match(':^#CF:', $message)) {
504
+					$decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
505 505
 				}
506
-				elseif (preg_match(':^#DF:',$message)) {
507
-					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
506
+				elseif (preg_match(':^#DF:', $message)) {
507
+					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
508 508
 				}
509
-				elseif (preg_match(':^#EC:',$message)) {
510
-					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
509
+				elseif (preg_match(':^#EC:', $message)) {
510
+					$decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
511 511
 				}
512
-				elseif (preg_match(':^#EI:',$message)) {
513
-					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
512
+				elseif (preg_match(':^#EI:', $message)) {
513
+					$decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
514 514
 				}
515
-				elseif (preg_match(':^#H1:',$message)) {
516
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
515
+				elseif (preg_match(':^#H1:', $message)) {
516
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
517 517
 				}
518
-				elseif (preg_match(':^#H2:',$message)) {
519
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
518
+				elseif (preg_match(':^#H2:', $message)) {
519
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
520 520
 				}
521
-				elseif (preg_match(':^#HD:',$message)) {
522
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
521
+				elseif (preg_match(':^#HD:', $message)) {
522
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
523 523
 				}
524
-				elseif (preg_match(':^#M1:',$message)) {
525
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
524
+				elseif (preg_match(':^#M1:', $message)) {
525
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
526 526
 				}
527
-				elseif (preg_match(':^#M2:',$message)) {
528
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
527
+				elseif (preg_match(':^#M2:', $message)) {
528
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
529 529
 				}
530
-				elseif (preg_match(':^#M3:',$message)) {
531
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
530
+				elseif (preg_match(':^#M3:', $message)) {
531
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
532 532
 				}
533
-				elseif (preg_match(':^#MD:',$message)) {
534
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
533
+				elseif (preg_match(':^#MD:', $message)) {
534
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
535 535
 				}
536
-				elseif (preg_match(':^#PS:',$message)) {
537
-					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
536
+				elseif (preg_match(':^#PS:', $message)) {
537
+					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
538 538
 				}
539
-				elseif (preg_match(':^#S1:',$message)) {
540
-					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
539
+				elseif (preg_match(':^#S1:', $message)) {
540
+					$decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
541 541
 				}
542
-				elseif (preg_match(':^#S2:',$message)) {
543
-					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
542
+				elseif (preg_match(':^#S2:', $message)) {
543
+					$decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
544 544
 				}
545
-				elseif (preg_match(':^#SD:',$message)) {
546
-					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
545
+				elseif (preg_match(':^#SD:', $message)) {
546
+					$decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
547 547
 				}
548
-				elseif (preg_match(':^#T[0-8]:',$message)) {
549
-					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
548
+				elseif (preg_match(':^#T[0-8]:', $message)) {
549
+					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
550 550
 				}
551
-				elseif (preg_match(':^#WO:',$message)) {
552
-					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
551
+				elseif (preg_match(':^#WO:', $message)) {
552
+					$decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
553 553
 				}
554
-				elseif (preg_match(':^#A1:',$message)) {
555
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
554
+				elseif (preg_match(':^#A1:', $message)) {
555
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
556 556
 				}
557
-				elseif (preg_match(':^#A3:',$message)) {
558
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
557
+				elseif (preg_match(':^#A3:', $message)) {
558
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
559 559
 				}
560
-				elseif (preg_match(':^#A4:',$message)) {
561
-					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
560
+				elseif (preg_match(':^#A4:', $message)) {
561
+					$decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
562 562
 				}
563
-				elseif (preg_match(':^#A6:',$message)) {
564
-					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
563
+				elseif (preg_match(':^#A6:', $message)) {
564
+					$decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
565 565
 				}
566
-				elseif (preg_match(':^#A8:',$message)) {
567
-					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
566
+				elseif (preg_match(':^#A8:', $message)) {
567
+					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
568 568
 				}
569
-				elseif (preg_match(':^#A9:',$message)) {
570
-					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
569
+				elseif (preg_match(':^#A9:', $message)) {
570
+					$decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
571 571
 				}
572
-				elseif (preg_match(':^#A0:',$message)) {
573
-					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
572
+				elseif (preg_match(':^#A0:', $message)) {
573
+					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
574 574
 				}
575
-				elseif (preg_match(':^#AA:',$message)) {
576
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
575
+				elseif (preg_match(':^#AA:', $message)) {
576
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
577 577
 				}
578
-				elseif (preg_match(':^#AB:',$message)) {
579
-					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
578
+				elseif (preg_match(':^#AB:', $message)) {
579
+					$decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
580 580
 				}
581
-				elseif (preg_match(':^#AC:',$message)) {
582
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
581
+				elseif (preg_match(':^#AC:', $message)) {
582
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
583 583
 				}
584
-				elseif (preg_match(':^#AD:',$message)) {
585
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
584
+				elseif (preg_match(':^#AD:', $message)) {
585
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
586 586
 				}
587
-				elseif (preg_match(':^#AF:',$message)) {
588
-					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
587
+				elseif (preg_match(':^#AF:', $message)) {
588
+					$decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
589 589
 				}
590
-				elseif (preg_match(':^#B1:',$message)) {
591
-					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
590
+				elseif (preg_match(':^#B1:', $message)) {
591
+					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
592 592
 				}
593
-				elseif (preg_match(':^#B2:',$message)) {
594
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
593
+				elseif (preg_match(':^#B2:', $message)) {
594
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
595 595
 				}
596
-				elseif (preg_match(':^#B3:',$message)) {
597
-					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
596
+				elseif (preg_match(':^#B3:', $message)) {
597
+					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
598 598
 				}
599
-				elseif (preg_match(':^#B4:',$message)) {
600
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
599
+				elseif (preg_match(':^#B4:', $message)) {
600
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
601 601
 				}
602
-				elseif (preg_match(':^#B6:',$message)) {
603
-					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
602
+				elseif (preg_match(':^#B6:', $message)) {
603
+					$decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
604 604
 				}
605
-				elseif (preg_match(':^#B8:',$message)) {
606
-					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
605
+				elseif (preg_match(':^#B8:', $message)) {
606
+					$decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
607 607
 				}
608
-				elseif (preg_match(':^#B9:',$message)) {
609
-					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
608
+				elseif (preg_match(':^#B9:', $message)) {
609
+					$decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
610 610
 				}
611
-				elseif (preg_match(':^#B0:',$message)) {
612
-					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
611
+				elseif (preg_match(':^#B0:', $message)) {
612
+					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
613 613
 				}
614
-				elseif (preg_match(':^#BA:',$message)) {
615
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
614
+				elseif (preg_match(':^#BA:', $message)) {
615
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
616 616
 				}
617
-				elseif (preg_match(':^#BB:',$message)) {
618
-					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
617
+				elseif (preg_match(':^#BB:', $message)) {
618
+					$decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
619 619
 				}
620
-				elseif (preg_match(':^#BC:',$message)) {
621
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
620
+				elseif (preg_match(':^#BC:', $message)) {
621
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
622 622
 				}
623
-				elseif (preg_match(':^#BD:',$message)) {
624
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
623
+				elseif (preg_match(':^#BD:', $message)) {
624
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
625 625
 				}
626
-				elseif (preg_match(':^#BE:',$message)) {
627
-					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
626
+				elseif (preg_match(':^#BE:', $message)) {
627
+					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
628 628
 				}
629
-				elseif (preg_match(':^#BF:',$message)) {
630
-					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
629
+				elseif (preg_match(':^#BF:', $message)) {
630
+					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
631 631
 				}
632
-				elseif (preg_match(':^#H3:',$message)) {
633
-					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
632
+				elseif (preg_match(':^#H3:', $message)) {
633
+					$decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
634 634
 				}
635 635
 			}
636 636
 			if ($label == '10') {
637
-				if (preg_match(':^DTO01:',$message)) {
638
-					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
637
+				if (preg_match(':^DTO01:', $message)) {
638
+					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
639 639
 				}
640
-				elseif (preg_match(':^AIS01:',$message)) {
641
-					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
640
+				elseif (preg_match(':^AIS01:', $message)) {
641
+					$decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
642 642
 				}
643
-				elseif (preg_match(':^FTX01:',$message)) {
644
-					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
643
+				elseif (preg_match(':^FTX01:', $message)) {
644
+					$decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
645 645
 				}
646
-				elseif (preg_match(':^FPL01:',$message)) {
647
-					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
646
+				elseif (preg_match(':^FPL01:', $message)) {
647
+					$decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
648 648
 				}
649
-				elseif (preg_match(':^WAB01:',$message)) {
650
-					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
649
+				elseif (preg_match(':^WAB01:', $message)) {
650
+					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
651 651
 				}
652
-				elseif (preg_match(':^MET01:',$message)) {
653
-					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
652
+				elseif (preg_match(':^MET01:', $message)) {
653
+					$decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
654 654
 				}
655
-				elseif (preg_match(':^WAB02:',$message)) {
656
-					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
655
+				elseif (preg_match(':^WAB02:', $message)) {
656
+					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
657 657
 				}
658 658
 			}
659 659
 			if ($label == '15') {
660
-				if (preg_match(':^FST01:',$message)) {
661
-					$decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode);
660
+				if (preg_match(':^FST01:', $message)) {
661
+					$decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
662 662
 				}
663 663
 			}
664 664
 			if (!$found && $label == 'SA') {
665
-				$n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at);
665
+				$n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
666 666
 				if ($n == 4) {
667 667
 					$vsta = array('Version' => $version);
668 668
 					if ($state == 'E') {
669
-						$vsta = array_merge($vsta,array('Link state' => 'Established'));
669
+						$vsta = array_merge($vsta, array('Link state' => 'Established'));
670 670
 					}
671 671
 					elseif ($state == 'L') {
672
-						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
672
+						$vsta = array_merge($vsta, array('Link state' => 'Lost'));
673 673
 					}
674 674
 					else {
675
-						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
675
+						$vsta = array_merge($vsta, array('Link state' => 'Unknown'));
676 676
 					}
677 677
 					if ($type == 'V') {
678
-						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
678
+						$vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
679 679
 					}
680 680
 					elseif ($type == 'S') {
681
-						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
681
+						$vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
682 682
 					}
683 683
 					elseif ($type == 'H') {
684
-						$vsta = array_merge($vsta,array('Link type' => 'HF'));
684
+						$vsta = array_merge($vsta, array('Link type' => 'HF'));
685 685
 					}
686 686
 					elseif ($type == 'G') {
687
-						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
687
+						$vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
688 688
 					}
689 689
 					elseif ($type == 'C') {
690
-						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
690
+						$vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
691 691
 					}
692 692
 					elseif ($type == '2') {
693
-						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
693
+						$vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
694 694
 					}
695 695
 					elseif ($type == 'X') {
696
-						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
696
+						$vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
697 697
 					}
698 698
 					elseif ($type == 'I') {
699
-						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
699
+						$vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
700 700
 					}
701 701
 					else {
702
-						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
702
+						$vsta = array_merge($vsta, array('Link type' => 'Unknown'));
703 703
 					}
704
-					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
705
-					$decode = array_merge($vsta,$decode);
704
+					$vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
705
+					$decode = array_merge($vsta, $decode);
706 706
 				}
707 707
 			}
708 708
 
709 709
 			$title = $this->getTitlefromLabel($label);
710
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
710
+			if ($title != '') $decode = array_merge(array('Message title' => $title), $decode);
711 711
 
712 712
 			/*
713 713
 			// Business jets always use GS0001
@@ -740,13 +740,13 @@  discard block
 block discarded – undo
740 740
 		$message = $this->parse($data);
741 741
 		if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') {
742 742
 		
743
-			$ident = (string)$message['ident'];
743
+			$ident = (string) $message['ident'];
744 744
 			$label = $message['label'];
745 745
 			$block_id = $message['block_id'];
746 746
 			$msg_no = $message['msg_no'];
747 747
 			$msg = $message['message'];
748 748
 			$decode = $message['decode'];
749
-			$registration = (string)$message['registration'];
749
+			$registration = (string) $message['registration'];
750 750
 		
751 751
 			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
752 752
 			else $latitude = '';
@@ -763,23 +763,23 @@  discard block
 block discarded – undo
763 763
 			}
764 764
 		
765 765
 			// Business jets always use GS0001
766
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
766
+			if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude);
767 767
 			if ($globalDebug && isset($info) && $info != '') echo $info;
768 768
 
769 769
 			if (count($decode) > 0) $decode_json = json_encode($decode);
770 770
 			else $decode_json = '';
771 771
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
772
-				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
772
+				$Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS');
773 773
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
774
-				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
774
+				$Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS');
775 775
 			}
776 776
 
777
-			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
778
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
779
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
777
+			$result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
778
+			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F');
779
+			if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
780 780
 
781 781
 			if ($globalDebug && count($decode) > 0) {
782
-				echo "Human readable data : ".implode(' - ',$decode)."\n";
782
+				echo "Human readable data : ".implode(' - ', $decode)."\n";
783 783
 			}
784 784
 		}
785 785
 	}
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 	* @param String $msg_no Number of the ACARS message
795 795
 	* @param String $message ACARS message
796 796
 	*/
797
-	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
797
+	public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
798 798
 		global $globalDebug;
799 799
 		date_default_timezone_set('UTC');
800 800
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
@@ -803,22 +803,22 @@  discard block
 block discarded – undo
803 803
 
804 804
 			if ($globalDebug) echo "Test if not already in Live ACARS table...";
805 805
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
806
-			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
806
+			$query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message);
807 807
 			try {
808 808
 				$stht = $this->db->prepare($query_test);
809 809
 				$stht->execute($query_test_values);
810
-			} catch(PDOException $e) {
810
+			} catch (PDOException $e) {
811 811
 				return "error : ".$e->getMessage();
812 812
 			}
813 813
 			if ($stht->fetchColumn() == 0) {
814 814
 				if ($globalDebug) echo "Add Live ACARS data...";
815 815
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
816
-				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
816
+				$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s"));
817 817
 				try {
818 818
 
819 819
 					$sth = $this->db->prepare($query);
820 820
 					$sth->execute($query_values);
821
-				} catch(PDOException $e) {
821
+				} catch (PDOException $e) {
822 822
 					return "error : ".$e->getMessage();
823 823
 				}
824 824
 			} else {
@@ -840,10 +840,10 @@  discard block
 block discarded – undo
840 840
 	* @param String $msg_no Number of the ACARS message
841 841
 	* @param String $message ACARS message
842 842
 	*/
843
-	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
843
+	public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
844 844
 		global $globalDebug;
845 845
 		date_default_timezone_set('UTC');
846
-		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) {
846
+		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) {
847 847
 			/*
848 848
 				    if ($globalDebug) echo "Test if not already in Archive ACARS table...";
849 849
 			    	    $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message";
@@ -859,12 +859,12 @@  discard block
 block discarded – undo
859 859
 			*/
860 860
 			if ($globalDebug) echo "Add Live ACARS data...";
861 861
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
862
-			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
862
+			$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
863 863
 			try {
864 864
 
865 865
 				$sth = $this->db->prepare($query);
866 866
 				$sth->execute($query_values);
867
-			} catch(PDOException $e) {
867
+			} catch (PDOException $e) {
868 868
 				return "error : ".$e->getMessage();
869 869
 			}
870 870
 //    	    }
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 
888 888
 			$sth = $this->db->prepare($query);
889 889
 			$sth->execute($query_values);
890
-		} catch(PDOException $e) {
890
+		} catch (PDOException $e) {
891 891
 			echo "error : ".$e->getMessage();
892 892
 			die;
893 893
 		}
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 
909 909
 			$sth = $this->db->prepare($query);
910 910
 			$sth->execute($query_values);
911
-		} catch(PDOException $e) {
911
+		} catch (PDOException $e) {
912 912
 			echo "error : ".$e->getMessage();
913 913
 			die;
914 914
 		}
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 
931 931
 			$sth = $this->db->prepare($query);
932 932
 			$sth->execute($query_values);
933
-		} catch(PDOException $e) {
933
+		} catch (PDOException $e) {
934 934
 			echo "error : ".$e->getMessage();
935 935
 			die;
936 936
 		}
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 	*
945 945
 	* @return Array Return ACARS data in array
946 946
 	*/
947
-	public function getLatestAcarsData($limit = '',$label = '') {
947
+	public function getLatestAcarsData($limit = '', $label = '') {
948 948
 		global $globalURL, $globalDBdriver;
949 949
 		$Image = new Image($this->db);
950 950
 		$Spotter = new Spotter($this->db);
@@ -956,8 +956,8 @@  discard block
 block discarded – undo
956 956
 		{
957 957
 			$limit_array = explode(",", $limit);
958 958
 
959
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
960
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
959
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
960
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
961 961
 
962 962
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
963 963
 			{
@@ -979,48 +979,48 @@  discard block
 block discarded – undo
979 979
 
980 980
 			$sth = $this->db->prepare($query);
981 981
 			$sth->execute($query_values);
982
-		} catch(PDOException $e) {
982
+		} catch (PDOException $e) {
983 983
 			return "error : ".$e->getMessage();
984 984
 		}
985 985
 		$i = 0;
986 986
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
987 987
 			$data = array();
988 988
 			if ($row['registration'] != '') {
989
-				$row['registration'] = str_replace('.','',$row['registration']);
989
+				$row['registration'] = str_replace('.', '', $row['registration']);
990 990
 				$image_array = $Image->getSpotterImage($row['registration']);
991
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
992
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
993
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
991
+				if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
992
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
993
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
994 994
 			if ($row['registration'] == '') $row['registration'] = 'NA';
995 995
 			if ($row['ident'] == '') $row['ident'] = 'NA';
996
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
996
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
997 997
 			if (isset($identicao[0])) {
998
-				if (substr($row['ident'],0,2) == 'AF') {
999
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1000
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1001
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
998
+				if (substr($row['ident'], 0, 2) == 'AF') {
999
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1000
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1001
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1002 1002
 
1003
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1003
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1004 1004
 			} else $icao = $row['ident'];
1005
-			$icao = $Translation->checkTranslation($icao,false);
1005
+			$icao = $Translation->checkTranslation($icao, false);
1006 1006
 
1007
-			$decode = json_decode($row['decode'],true);
1007
+			$decode = json_decode($row['decode'], true);
1008 1008
 			$found = false;
1009
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1009
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1010 1010
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1011 1011
 				if (isset($airport_info[0]['icao'])) {
1012 1012
 					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1013 1013
 					$found = true;
1014 1014
 				}
1015 1015
 			}
1016
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1016
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1017 1017
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1018 1018
 				if (isset($airport_info[0]['icao'])) {
1019 1019
 					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1020 1020
 					$found = true;
1021 1021
 				}
1022 1022
 			}
1023
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1023
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1024 1024
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1025 1025
 				if (isset($airport_info[0]['icao'])) {
1026 1026
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 				}
1029 1029
 			}
1030 1030
 			if ($found) $row['decode'] = json_encode($decode);
1031
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1031
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1032 1032
 			$result[] = $data;
1033 1033
 			$i++;
1034 1034
 		}
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 	*
1045 1045
 	* @return Array Return ACARS data in array
1046 1046
 	*/
1047
-	public function getArchiveAcarsData($limit = '',$label = '') {
1047
+	public function getArchiveAcarsData($limit = '', $label = '') {
1048 1048
 		global $globalURL, $globalDBdriver;
1049 1049
 		$Image = new Image($this->db);
1050 1050
 		$Spotter = new Spotter($this->db);
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
 		{
1057 1057
 			$limit_array = explode(",", $limit);
1058 1058
 
1059
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1060
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1059
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1060
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1061 1061
 
1062 1062
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1063 1063
 			{
@@ -1087,45 +1087,45 @@  discard block
 block discarded – undo
1087 1087
 
1088 1088
 			$sth = $this->db->prepare($query);
1089 1089
 			$sth->execute($query_values);
1090
-		} catch(PDOException $e) {
1090
+		} catch (PDOException $e) {
1091 1091
 			return "error : ".$e->getMessage();
1092 1092
 		}
1093
-		$i=0;
1093
+		$i = 0;
1094 1094
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1095 1095
 			$data = array();
1096 1096
 			if ($row['registration'] != '') {
1097
-				$row['registration'] = str_replace('.','',$row['registration']);
1097
+				$row['registration'] = str_replace('.', '', $row['registration']);
1098 1098
 				$image_array = $Image->getSpotterImage($row['registration']);
1099
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1100
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1101
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1099
+				if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
1100
+				else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1101
+			} else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1102 1102
 			$icao = '';
1103 1103
 			if ($row['registration'] == '') $row['registration'] = 'NA';
1104 1104
 			if ($row['ident'] == '') $row['ident'] = 'NA';
1105
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1105
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
1106 1106
 			if (isset($identicao[0])) {
1107
-				if (substr($row['ident'],0,2) == 'AF') {
1108
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1109
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1110
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1111
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1107
+				if (substr($row['ident'], 0, 2) == 'AF') {
1108
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1109
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1110
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1111
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1112 1112
 			} else $icao = $row['ident'];
1113 1113
 			$icao = $Translation->checkTranslation($icao);
1114 1114
 
1115 1115
 
1116
-			$decode = json_decode($row['decode'],true);
1116
+			$decode = json_decode($row['decode'], true);
1117 1117
 			$found = false;
1118
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1118
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1119 1119
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1120 1120
 				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1121 1121
 				$found = true;
1122 1122
 			}
1123
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1123
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1124 1124
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1125 1125
 				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1126 1126
 				$found = true;
1127 1127
 			}
1128
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1128
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1129 1129
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1130 1130
 				if (isset($airport_info[0]['icao'])) {
1131 1131
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 			}
1135 1135
 			if ($found) $row['decode'] = json_encode($decode);
1136 1136
 
1137
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1137
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1138 1138
 			$result[] = $data;
1139 1139
 			$i++;
1140 1140
 		}
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 	* @param String $icao
1153 1153
 	* @param String $ICAOTypeCode
1154 1154
 	*/
1155
-	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1155
+	public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') {
1156 1156
 		global $globalDebug, $globalDBdriver;
1157 1157
 		$ident = trim($ident);
1158 1158
 		$Translation = new Translation($this->db);
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 			return '';
1167 1167
 		}
1168 1168
 
1169
-		$registration = str_replace('.','',$registration);
1169
+		$registration = str_replace('.', '', $registration);
1170 1170
 		$ident = $Translation->ident2icao($ident);
1171 1171
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1172 1172
 		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 
1177 1177
 			$sthsi = $this->db->prepare($querysi);
1178 1178
 			$sthsi->execute($querysi_values);
1179
-		} catch(PDOException $e) {
1179
+		} catch (PDOException $e) {
1180 1180
 			if ($globalDebug) echo $e->getMessage();
1181 1181
 			return "error : ".$e->getMessage();
1182 1182
 		}
@@ -1187,8 +1187,8 @@  discard block
 block discarded – undo
1187 1187
 			$Translation = new Translation($this->db);
1188 1188
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1189 1189
 			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1190
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1191
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1190
+			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
1191
+			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
1192 1192
 		} else {
1193 1193
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1194 1194
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 				try {
1197 1197
 					$sth = $this->db->prepare($query);
1198 1198
 					$sth->execute($query_values);
1199
-				} catch(PDOException $e) {
1199
+				} catch (PDOException $e) {
1200 1200
 					if ($globalDebug) echo $e->getMessage();
1201 1201
 					return "error : ".$e->getMessage();
1202 1202
 				}
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 				$sth->closeCursor();
1205 1205
 				if (isset($result['modes'])) $hex = $result['modes'];
1206 1206
 				else $hex = '';
1207
-				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1207
+				$SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS');
1208 1208
 				$this->SI->add($SI_data);
1209 1209
 			}
1210 1210
 		}
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 
1217 1217
 			$sth = $this->db->prepare($query);
1218 1218
 			$sth->execute($query_values);
1219
-		} catch(PDOException $e) {
1219
+		} catch (PDOException $e) {
1220 1220
 			if ($globalDebug) echo $e->getMessage();
1221 1221
 			return "error : ".$e->getMessage();
1222 1222
 		}
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1228 1228
 			else $ModeS = '';
1229 1229
 			if ($ModeS == '') {
1230
-				$id = explode('-',$result['flightaware_id']);
1230
+				$id = explode('-', $result['flightaware_id']);
1231 1231
 				$ModeS = $id[0];
1232 1232
 			}
1233 1233
 			if ($ModeS != '') {
@@ -1238,21 +1238,21 @@  discard block
 block discarded – undo
1238 1238
 
1239 1239
 					$sthc = $this->db->prepare($queryc);
1240 1240
 					$sthc->execute($queryc_values);
1241
-				} catch(PDOException $e) {
1241
+				} catch (PDOException $e) {
1242 1242
 					if ($globalDebug) echo $e->getMessage();
1243 1243
 					return "error : ".$e->getMessage();
1244 1244
 				}
1245 1245
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1246 1246
 				$sthc->closeCursor();
1247
-				if (count($row) ==  0) {
1247
+				if (count($row) == 0) {
1248 1248
 					if ($globalDebug) echo " Add to ModeS table - ";
1249 1249
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1250
-					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1250
+					$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1251 1251
 					try {
1252 1252
 
1253 1253
 						$sthi = $this->db->prepare($queryi);
1254 1254
 						$sthi->execute($queryi_values);
1255
-					} catch(PDOException $e) {
1255
+					} catch (PDOException $e) {
1256 1256
 						if ($globalDebug) echo $e->getMessage();
1257 1257
 						return "error : ".$e->getMessage();
1258 1258
 					}
@@ -1260,16 +1260,16 @@  discard block
 block discarded – undo
1260 1260
 					if ($globalDebug) echo " Update ModeS table - ";
1261 1261
 					if ($ICAOTypeCode != '') {
1262 1262
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1263
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1263
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1264 1264
 					} else {
1265 1265
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1266
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration);
1266
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
1267 1267
 					}
1268 1268
 					try {
1269 1269
 
1270 1270
 						$sthi = $this->db->prepare($queryi);
1271 1271
 						$sthi->execute($queryi_values);
1272
-					} catch(PDOException $e) {
1272
+					} catch (PDOException $e) {
1273 1273
 						if ($globalDebug) echo $e->getMessage();
1274 1274
 						return "error : ".$e->getMessage();
1275 1275
 					}
@@ -1307,13 +1307,13 @@  discard block
 block discarded – undo
1307 1307
 					elseif ($globalDBdriver == 'pgsql') {
1308 1308
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1309 1309
 					}
1310
-					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
1310
+					$queryi_values = array(':Registration' => $registration, ':ident' => $icao);
1311 1311
 				}
1312 1312
 				try {
1313 1313
 
1314 1314
 					$sthi = $this->db->prepare($queryi);
1315 1315
 					$sthi->execute($queryi_values);
1316
-				} catch(PDOException $e) {
1316
+				} catch (PDOException $e) {
1317 1317
 					if ($globalDebug) echo $e->getMessage();
1318 1318
 					return "error : ".$e->getMessage();
1319 1319
 				}
Please login to merge, or discard this patch.
Braces   +409 added lines, -261 removed lines patch added patch discarded remove patch
@@ -23,14 +23,19 @@  discard block
 block discarded – undo
23 23
 	*/
24 24
 	public function ident2icao($ident) {
25 25
 		if (substr($ident,0,2) == 'AF') {
26
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
26
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
27
+				$icao = $ident;
28
+			} else {
29
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
30
+			}
28 31
 		} else {
29 32
 			$Spotter = new Spotter($this->db);
30 33
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
31 34
 			if (isset($identicao[0])) {
32 35
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
33
-			} else $icao = $ident;
36
+			} else {
37
+				$icao = $ident;
38
+			}
34 39
 		}
35 40
 		return $icao;
36 41
 	}
@@ -103,14 +108,24 @@  discard block
 block discarded – undo
103 108
 		$message = '';
104 109
 		$result = array();
105 110
 		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
106
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
107
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
108
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
111
+		if ($n == 0) {
112
+			$n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
113
+		}
114
+		if ($n == 0) {
115
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
116
+		}
117
+		if ($n == 0) {
118
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
119
+		}
109 120
 		if ($n != 0) {
110 121
 			$registration = str_replace('.','',$registration);
111 122
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
112
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
113
-		} else $message = $data;
123
+			if ($globalDebug) {
124
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
125
+			}
126
+		} else {
127
+			$message = $data;
128
+		}
114 129
 		$decode = array();
115 130
 		$found = false;
116 131
 //		if ($registration != '' && $ident != '' && $registration != '!') {
@@ -130,12 +145,21 @@  discard block
 block discarded – undo
130 145
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
131 146
 					$latitude = $la / 10000.0;
132 147
 					$longitude = $ln / 10000.0;
133
-					if ($lac == 'S') $latitude = '-'.$latitude;
134
-					if ($lnc == 'W') $longitude = '-'.$longitude;
148
+					if ($lac == 'S') {
149
+						$latitude = '-'.$latitude;
150
+					}
151
+					if ($lnc == 'W') {
152
+						$longitude = '-'.$longitude;
153
+					}
135 154
 					// Temp not always available
136
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
137
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
138
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
155
+					if ($globalDebug) {
156
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
157
+					}
158
+					if ($temp == '') {
159
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
160
+					} else {
161
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
162
+					}
139 163
 
140 164
 					//$icao = $Translation->checkTranslation($ident);
141 165
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -149,25 +173,35 @@  discard block
 block discarded – undo
149 173
 				$ahour = '';
150 174
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
151 175
 				if ($n == 4 && strlen($darr) == 4) {
152
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
153
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
154
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
176
+					if ($dhour != '') {
177
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
178
+					}
179
+					if ($ahour != '') {
180
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
181
+					}
182
+					if ($globalDebug) {
183
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
184
+					}
155 185
 					//$icao = ACARS->ident2icao($ident);
156 186
 					//$icao = $Translation->checkTranslation($ident);
157 187
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
158 188
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
159 189
 					$found = true;
160
-				}
161
-				elseif ($n == 2 || $n  == 4) {
162
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
163
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
190
+				} elseif ($n == 2 || $n  == 4) {
191
+					if ($dhour != '') {
192
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
193
+					}
194
+					if ($globalDebug) {
195
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
196
+					}
164 197
 					//$icao = ACARS->ident2icao($ident);
165 198
 					//$icao = $Translation->checkTranslation($ident);
166 199
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
167 200
 					$found = true;
168
-				}
169
-				elseif ($n == 1) {
170
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
201
+				} elseif ($n == 1) {
202
+					if ($globalDebug) {
203
+						echo 'airport arrival : '.$darr."\n";
204
+					}
171 205
 					//$icao = ACARS->ident2icao($ident);
172 206
 					//$icao = $Translation->checkTranslation($ident);
173 207
 					$decode = array('Arrival airport' => $darr);
@@ -185,7 +219,9 @@  discard block
 block discarded – undo
185 219
 				$darr = '';
186 220
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
187 221
 				if ($n == 4) {
188
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
222
+					if ($globalDebug) {
223
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
224
+					}
189 225
 					//$icao = ACARS->ident2icao($ident);
190 226
 					//$icao = $Translation->checkTranslation($ident);
191 227
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -219,14 +255,23 @@  discard block
 block discarded – undo
219 255
 				$apiste = '';
220 256
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
221 257
 				if ($n > 8) {
222
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
224
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
258
+					if ($globalDebug) {
259
+						echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
260
+					}
261
+					if ($dhour != '') {
262
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
263
+					}
264
+					if ($ahour != '') {
265
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
266
+					}
225 267
 					$icao = trim($aident);
226 268
 
227 269
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
228
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
229
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
270
+					if ($ahour == '') {
271
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
272
+					} else {
273
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
274
+					}
230 275
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
231 276
 					$decode['icao'] = $icao;
232 277
 					$found = true;
@@ -248,9 +293,15 @@  discard block
 block discarded – undo
248 293
 					$lns = $lns.'.'.$lns;
249 294
 					$latitude = $las / 1000.0;
250 295
 					$longitude = $lns / 1000.0;
251
-					if ($lac == 'S') $latitude = '-'.$latitude;
252
-					if ($lnc == 'W') $longitude = '-'.$longitude;
253
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
296
+					if ($lac == 'S') {
297
+						$latitude = '-'.$latitude;
298
+					}
299
+					if ($lnc == 'W') {
300
+						$longitude = '-'.$longitude;
301
+					}
302
+					if ($globalDebug) {
303
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
304
+					}
254 305
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
255 306
 					$found = true;
256 307
 				}
@@ -268,7 +319,9 @@  discard block
 block discarded – undo
268 319
 				$darr = '';
269 320
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
270 321
 				if ($n == 4) {
271
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
322
+					if ($globalDebug) {
323
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
324
+					}
272 325
 					//$icao = $Translation->checkTranslation($ident);
273 326
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
274 327
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -281,7 +334,9 @@  discard block
 block discarded – undo
281 334
 				$darr = '';
282 335
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
283 336
 				if ($n == 4) {
284
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
337
+					if ($globalDebug) {
338
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
339
+					}
285 340
 					//$icao = $Translation->checkTranslation($ident);
286 341
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
287 342
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -294,7 +349,9 @@  discard block
 block discarded – undo
294 349
 				$darr = '';
295 350
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
296 351
 				if ($n == 2) {
297
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
352
+					if ($globalDebug) {
353
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
354
+					}
298 355
 					//$icao = $Translation->checkTranslation($ident);
299 356
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
300 357
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -308,7 +365,9 @@  discard block
 block discarded – undo
308 365
 				$darr = '';
309 366
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
310 367
 				if ($n == 6) {
311
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
368
+					if ($globalDebug) {
369
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
370
+					}
312 371
 					//$icao = $Translation->checkTranslation($ident);
313 372
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
314 373
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -321,7 +380,9 @@  discard block
 block discarded – undo
321 380
 				$darr = '';
322 381
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
323 382
 				if ($n == 7) {
324
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
383
+					if ($globalDebug) {
384
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
385
+					}
325 386
 					//$icao = $Translation->checkTranslation($ident);
326 387
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
327 388
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -349,8 +410,12 @@  discard block
 block discarded – undo
349 410
 					$decode['icao'] = $icao;
350 411
 					$latitude = $las / 100.0;
351 412
 					$longitude = $lns / 100.0;
352
-					if ($lac == 'S') $latitude = '-'.$latitude;
353
-					if ($lnc == 'W') $longitude = '-'.$longitude;
413
+					if ($lac == 'S') {
414
+						$latitude = '-'.$latitude;
415
+					}
416
+					if ($lnc == 'W') {
417
+						$longitude = '-'.$longitude;
418
+					}
354 419
 
355 420
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
356 421
 					$found = true;
@@ -368,8 +433,12 @@  discard block
 block discarded – undo
368 433
 				if ($n == 4) {
369 434
 					$latitude = $las;
370 435
 					$longitude = $lns;
371
-					if ($lac == 'S') $latitude = '-'.$latitude;
372
-					if ($lnc == 'W') $longitude = '-'.$longitude;
436
+					if ($lac == 'S') {
437
+						$latitude = '-'.$latitude;
438
+					}
439
+					if ($lnc == 'W') {
440
+						$longitude = '-'.$longitude;
441
+					}
373 442
 
374 443
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
375 444
 					$found = true;
@@ -385,7 +454,9 @@  discard block
 block discarded – undo
385 454
 				$darr = '';
386 455
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
387 456
 				if ($n == 5) {
388
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
457
+					if ($globalDebug) {
458
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
459
+					}
389 460
 					//$icao = $Translation->checkTranslation($ident);
390 461
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
391 462
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -406,7 +477,9 @@  discard block
 block discarded – undo
406 477
 				$aident = '';
407 478
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
408 479
 				if ($n == 8) {
409
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
480
+					if ($globalDebug) {
481
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
482
+					}
410 483
 					$icao = trim($aident);
411 484
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
412 485
 					$decode['icao'] = $icao;
@@ -423,7 +496,9 @@  discard block
 block discarded – undo
423 496
 				$darr = '';
424 497
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
425 498
 				if ($n == 5) {
426
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
499
+					if ($globalDebug) {
500
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
501
+					}
427 502
 					//$icao = $Translation->checkTranslation($ident);
428 503
 
429 504
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -439,7 +514,9 @@  discard block
 block discarded – undo
439 514
 				$darr = '';
440 515
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
441 516
 				if ($n == 3) {
442
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
517
+					if ($globalDebug) {
518
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
519
+					}
443 520
 					//$icao = $Translation->checkTranslation($ident);
444 521
 
445 522
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -455,7 +532,9 @@  discard block
 block discarded – undo
455 532
 				$darr = '';
456 533
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
457 534
 				if ($n == 3) {
458
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
535
+					if ($globalDebug) {
536
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
537
+					}
459 538
 					//$icao = $Translation->checkTranslation($ident);
460 539
 
461 540
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -466,7 +545,9 @@  discard block
 block discarded – undo
466 545
 			if (!$found) {
467 546
 				$n = sscanf($message,'MET01%4c',$airport);
468 547
 				if ($n == 1) {
469
-					if ($globalDebug) echo 'airport name : '.$airport;
548
+					if ($globalDebug) {
549
+						echo 'airport name : '.$airport;
550
+					}
470 551
 					$decode = array('Airport/Waypoint name' => $airport);
471 552
 					$found = true;
472 553
 				}
@@ -475,184 +556,126 @@  discard block
 block discarded – undo
475 556
 			if ($label == 'H1') {
476 557
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
477 558
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
478
-				}
479
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
559
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
480 560
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
481
-				}
482
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
561
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
483 562
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
484
-				}
485
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
563
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
486 564
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
487
-				}
488
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
565
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
489 566
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
490
-				}
491
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
567
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
492 568
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
493
-				}
494
-				elseif (preg_match(':^#M1AAEP:',$message)) {
569
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
495 570
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
496
-				}
497
-				elseif (preg_match(':^#M2APWD:',$message)) {
571
+				} elseif (preg_match(':^#M2APWD:',$message)) {
498 572
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
499
-				}
500
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
573
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
501 574
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
502
-				}
503
-				elseif (preg_match(':^#CF:',$message)) {
575
+				} elseif (preg_match(':^#CF:',$message)) {
504 576
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
505
-				}
506
-				elseif (preg_match(':^#DF:',$message)) {
577
+				} elseif (preg_match(':^#DF:',$message)) {
507 578
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
508
-				}
509
-				elseif (preg_match(':^#EC:',$message)) {
579
+				} elseif (preg_match(':^#EC:',$message)) {
510 580
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
511
-				}
512
-				elseif (preg_match(':^#EI:',$message)) {
581
+				} elseif (preg_match(':^#EI:',$message)) {
513 582
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
514
-				}
515
-				elseif (preg_match(':^#H1:',$message)) {
583
+				} elseif (preg_match(':^#H1:',$message)) {
516 584
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
517
-				}
518
-				elseif (preg_match(':^#H2:',$message)) {
585
+				} elseif (preg_match(':^#H2:',$message)) {
519 586
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
520
-				}
521
-				elseif (preg_match(':^#HD:',$message)) {
587
+				} elseif (preg_match(':^#HD:',$message)) {
522 588
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
523
-				}
524
-				elseif (preg_match(':^#M1:',$message)) {
589
+				} elseif (preg_match(':^#M1:',$message)) {
525 590
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
526
-				}
527
-				elseif (preg_match(':^#M2:',$message)) {
591
+				} elseif (preg_match(':^#M2:',$message)) {
528 592
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
529
-				}
530
-				elseif (preg_match(':^#M3:',$message)) {
593
+				} elseif (preg_match(':^#M3:',$message)) {
531 594
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
532
-				}
533
-				elseif (preg_match(':^#MD:',$message)) {
595
+				} elseif (preg_match(':^#MD:',$message)) {
534 596
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
535
-				}
536
-				elseif (preg_match(':^#PS:',$message)) {
597
+				} elseif (preg_match(':^#PS:',$message)) {
537 598
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
538
-				}
539
-				elseif (preg_match(':^#S1:',$message)) {
599
+				} elseif (preg_match(':^#S1:',$message)) {
540 600
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
541
-				}
542
-				elseif (preg_match(':^#S2:',$message)) {
601
+				} elseif (preg_match(':^#S2:',$message)) {
543 602
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
544
-				}
545
-				elseif (preg_match(':^#SD:',$message)) {
603
+				} elseif (preg_match(':^#SD:',$message)) {
546 604
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
547
-				}
548
-				elseif (preg_match(':^#T[0-8]:',$message)) {
605
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
549 606
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
550
-				}
551
-				elseif (preg_match(':^#WO:',$message)) {
607
+				} elseif (preg_match(':^#WO:',$message)) {
552 608
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
553
-				}
554
-				elseif (preg_match(':^#A1:',$message)) {
609
+				} elseif (preg_match(':^#A1:',$message)) {
555 610
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
556
-				}
557
-				elseif (preg_match(':^#A3:',$message)) {
611
+				} elseif (preg_match(':^#A3:',$message)) {
558 612
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
559
-				}
560
-				elseif (preg_match(':^#A4:',$message)) {
613
+				} elseif (preg_match(':^#A4:',$message)) {
561 614
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
562
-				}
563
-				elseif (preg_match(':^#A6:',$message)) {
615
+				} elseif (preg_match(':^#A6:',$message)) {
564 616
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
565
-				}
566
-				elseif (preg_match(':^#A8:',$message)) {
617
+				} elseif (preg_match(':^#A8:',$message)) {
567 618
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
568
-				}
569
-				elseif (preg_match(':^#A9:',$message)) {
619
+				} elseif (preg_match(':^#A9:',$message)) {
570 620
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
571
-				}
572
-				elseif (preg_match(':^#A0:',$message)) {
621
+				} elseif (preg_match(':^#A0:',$message)) {
573 622
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
574
-				}
575
-				elseif (preg_match(':^#AA:',$message)) {
623
+				} elseif (preg_match(':^#AA:',$message)) {
576 624
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
577
-				}
578
-				elseif (preg_match(':^#AB:',$message)) {
625
+				} elseif (preg_match(':^#AB:',$message)) {
579 626
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
580
-				}
581
-				elseif (preg_match(':^#AC:',$message)) {
627
+				} elseif (preg_match(':^#AC:',$message)) {
582 628
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
583
-				}
584
-				elseif (preg_match(':^#AD:',$message)) {
629
+				} elseif (preg_match(':^#AD:',$message)) {
585 630
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
586
-				}
587
-				elseif (preg_match(':^#AF:',$message)) {
631
+				} elseif (preg_match(':^#AF:',$message)) {
588 632
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
589
-				}
590
-				elseif (preg_match(':^#B1:',$message)) {
633
+				} elseif (preg_match(':^#B1:',$message)) {
591 634
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
592
-				}
593
-				elseif (preg_match(':^#B2:',$message)) {
635
+				} elseif (preg_match(':^#B2:',$message)) {
594 636
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
595
-				}
596
-				elseif (preg_match(':^#B3:',$message)) {
637
+				} elseif (preg_match(':^#B3:',$message)) {
597 638
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
598
-				}
599
-				elseif (preg_match(':^#B4:',$message)) {
639
+				} elseif (preg_match(':^#B4:',$message)) {
600 640
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
601
-				}
602
-				elseif (preg_match(':^#B6:',$message)) {
641
+				} elseif (preg_match(':^#B6:',$message)) {
603 642
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
604
-				}
605
-				elseif (preg_match(':^#B8:',$message)) {
643
+				} elseif (preg_match(':^#B8:',$message)) {
606 644
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
607
-				}
608
-				elseif (preg_match(':^#B9:',$message)) {
645
+				} elseif (preg_match(':^#B9:',$message)) {
609 646
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
610
-				}
611
-				elseif (preg_match(':^#B0:',$message)) {
647
+				} elseif (preg_match(':^#B0:',$message)) {
612 648
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
613
-				}
614
-				elseif (preg_match(':^#BA:',$message)) {
649
+				} elseif (preg_match(':^#BA:',$message)) {
615 650
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
616
-				}
617
-				elseif (preg_match(':^#BB:',$message)) {
651
+				} elseif (preg_match(':^#BB:',$message)) {
618 652
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
619
-				}
620
-				elseif (preg_match(':^#BC:',$message)) {
653
+				} elseif (preg_match(':^#BC:',$message)) {
621 654
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
622
-				}
623
-				elseif (preg_match(':^#BD:',$message)) {
655
+				} elseif (preg_match(':^#BD:',$message)) {
624 656
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
625
-				}
626
-				elseif (preg_match(':^#BE:',$message)) {
657
+				} elseif (preg_match(':^#BE:',$message)) {
627 658
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
628
-				}
629
-				elseif (preg_match(':^#BF:',$message)) {
659
+				} elseif (preg_match(':^#BF:',$message)) {
630 660
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
631
-				}
632
-				elseif (preg_match(':^#H3:',$message)) {
661
+				} elseif (preg_match(':^#H3:',$message)) {
633 662
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
634 663
 				}
635 664
 			}
636 665
 			if ($label == '10') {
637 666
 				if (preg_match(':^DTO01:',$message)) {
638 667
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
639
-				}
640
-				elseif (preg_match(':^AIS01:',$message)) {
668
+				} elseif (preg_match(':^AIS01:',$message)) {
641 669
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
642
-				}
643
-				elseif (preg_match(':^FTX01:',$message)) {
670
+				} elseif (preg_match(':^FTX01:',$message)) {
644 671
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
645
-				}
646
-				elseif (preg_match(':^FPL01:',$message)) {
672
+				} elseif (preg_match(':^FPL01:',$message)) {
647 673
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
648
-				}
649
-				elseif (preg_match(':^WAB01:',$message)) {
674
+				} elseif (preg_match(':^WAB01:',$message)) {
650 675
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
651
-				}
652
-				elseif (preg_match(':^MET01:',$message)) {
676
+				} elseif (preg_match(':^MET01:',$message)) {
653 677
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
654
-				}
655
-				elseif (preg_match(':^WAB02:',$message)) {
678
+				} elseif (preg_match(':^WAB02:',$message)) {
656 679
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
657 680
 				}
658 681
 			}
@@ -667,38 +690,28 @@  discard block
 block discarded – undo
667 690
 					$vsta = array('Version' => $version);
668 691
 					if ($state == 'E') {
669 692
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
670
-					}
671
-					elseif ($state == 'L') {
693
+					} elseif ($state == 'L') {
672 694
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
673
-					}
674
-					else {
695
+					} else {
675 696
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
676 697
 					}
677 698
 					if ($type == 'V') {
678 699
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
679
-					}
680
-					elseif ($type == 'S') {
700
+					} elseif ($type == 'S') {
681 701
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
682
-					}
683
-					elseif ($type == 'H') {
702
+					} elseif ($type == 'H') {
684 703
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
685
-					}
686
-					elseif ($type == 'G') {
704
+					} elseif ($type == 'G') {
687 705
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
688
-					}
689
-					elseif ($type == 'C') {
706
+					} elseif ($type == 'C') {
690 707
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
691
-					}
692
-					elseif ($type == '2') {
708
+					} elseif ($type == '2') {
693 709
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
694
-					}
695
-					elseif ($type == 'X') {
710
+					} elseif ($type == 'X') {
696 711
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
697
-					}
698
-					elseif ($type == 'I') {
712
+					} elseif ($type == 'I') {
699 713
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
700
-					}
701
-					else {
714
+					} else {
702 715
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
703 716
 					}
704 717
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -707,7 +720,9 @@  discard block
 block discarded – undo
707 720
 			}
708 721
 
709 722
 			$title = $this->getTitlefromLabel($label);
710
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
723
+			if ($title != '') {
724
+				$decode = array_merge(array('Message title' => $title),$decode);
725
+			}
711 726
 
712 727
 			/*
713 728
 			// Business jets always use GS0001
@@ -748,14 +763,26 @@  discard block
 block discarded – undo
748 763
 			$decode = $message['decode'];
749 764
 			$registration = (string)$message['registration'];
750 765
 		
751
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
752
-			else $latitude = '';
753
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
754
-			else $longitude = '';
755
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
756
-			else $airicao = '';
757
-			if (isset($decode['icao'])) $icao = $decode['icao'];
758
-			else $icao = $Translation->checkTranslation($ident);
766
+			if (isset($decode['latitude'])) {
767
+				$latitude = $decode['latitude'];
768
+			} else {
769
+				$latitude = '';
770
+			}
771
+			if (isset($decode['longitude'])) {
772
+				$longitude = $decode['longitude'];
773
+			} else {
774
+				$longitude = '';
775
+			}
776
+			if (isset($decode['airicao'])) {
777
+				$airicao = $decode['airicao'];
778
+			} else {
779
+				$airicao = '';
780
+			}
781
+			if (isset($decode['icao'])) {
782
+				$icao = $decode['icao'];
783
+			} else {
784
+				$icao = $Translation->checkTranslation($ident);
785
+			}
759 786
 		
760 787
 			$image_array = $Image->getSpotterImage($registration);
761 788
 			if (!isset($image_array[0]['registration'])) {
@@ -763,11 +790,18 @@  discard block
 block discarded – undo
763 790
 			}
764 791
 		
765 792
 			// Business jets always use GS0001
766
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
767
-			if ($globalDebug && isset($info) && $info != '') echo $info;
793
+			if ($ident != 'GS0001') {
794
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
795
+			}
796
+			if ($globalDebug && isset($info) && $info != '') {
797
+				echo $info;
798
+			}
768 799
 
769
-			if (count($decode) > 0) $decode_json = json_encode($decode);
770
-			else $decode_json = '';
800
+			if (count($decode) > 0) {
801
+				$decode_json = json_encode($decode);
802
+			} else {
803
+				$decode_json = '';
804
+			}
771 805
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
772 806
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
773 807
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
@@ -775,8 +809,12 @@  discard block
 block discarded – undo
775 809
 			}
776 810
 
777 811
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
778
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
779
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
812
+			if (!isset($globalACARSArchive)) {
813
+				$globalACARSArchive = array('10','80','81','82','3F');
814
+			}
815
+			if ($result && in_array($label,$globalACARSArchive)) {
816
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
817
+			}
780 818
 
781 819
 			if ($globalDebug && count($decode) > 0) {
782 820
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
@@ -801,7 +839,9 @@  discard block
 block discarded – undo
801 839
 			$Connection = new Connection($this->db);
802 840
 			$this->db = $Connection->db;
803 841
 
804
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
842
+			if ($globalDebug) {
843
+				echo "Test if not already in Live ACARS table...";
844
+			}
805 845
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
806 846
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
807 847
 			try {
@@ -811,7 +851,9 @@  discard block
 block discarded – undo
811 851
 				return "error : ".$e->getMessage();
812 852
 			}
813 853
 			if ($stht->fetchColumn() == 0) {
814
-				if ($globalDebug) echo "Add Live ACARS data...";
854
+				if ($globalDebug) {
855
+					echo "Add Live ACARS data...";
856
+				}
815 857
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
816 858
 				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
817 859
 				try {
@@ -822,10 +864,14 @@  discard block
 block discarded – undo
822 864
 					return "error : ".$e->getMessage();
823 865
 				}
824 866
 			} else {
825
-				if ($globalDebug) echo "Data already in DB...\n";
867
+				if ($globalDebug) {
868
+					echo "Data already in DB...\n";
869
+				}
826 870
 				return false;
827 871
 			}
828
-			if ($globalDebug) echo "Done\n";
872
+			if ($globalDebug) {
873
+				echo "Done\n";
874
+			}
829 875
 			return true;
830 876
 		}
831 877
 	}
@@ -857,7 +903,9 @@  discard block
 block discarded – undo
857 903
 			    	    }
858 904
 				    if ($stht->fetchColumn() == 0) {
859 905
 			*/
860
-			if ($globalDebug) echo "Add Live ACARS data...";
906
+			if ($globalDebug) {
907
+				echo "Add Live ACARS data...";
908
+			}
861 909
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
862 910
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
863 911
 			try {
@@ -868,7 +916,9 @@  discard block
 block discarded – undo
868 916
 				return "error : ".$e->getMessage();
869 917
 			}
870 918
 //    	    }
871
-			if ($globalDebug) echo "Done\n";
919
+			if ($globalDebug) {
920
+				echo "Done\n";
921
+			}
872 922
 		}
873 923
 	}
874 924
 
@@ -892,8 +942,11 @@  discard block
 block discarded – undo
892 942
 			die;
893 943
 		}
894 944
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
895
-		if (count($row) > 0) return $row[0]['title'];
896
-		else return '';
945
+		if (count($row) > 0) {
946
+			return $row[0]['title'];
947
+		} else {
948
+			return '';
949
+		}
897 950
 	}
898 951
 
899 952
 	/**
@@ -913,8 +966,11 @@  discard block
 block discarded – undo
913 966
 			die;
914 967
 		}
915 968
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
916
-		if (count($row) > 0) return $row;
917
-		else return array();
969
+		if (count($row) > 0) {
970
+			return $row;
971
+		} else {
972
+			return array();
973
+		}
918 974
 	}
919 975
 
920 976
 	/**
@@ -935,8 +991,11 @@  discard block
 block discarded – undo
935 991
 			die;
936 992
 		}
937 993
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
938
-		if (count($row) > 0) return $row[0];
939
-		else return array();
994
+		if (count($row) > 0) {
995
+			return $row[0];
996
+		} else {
997
+			return array();
998
+		}
940 999
 	}
941 1000
 
942 1001
 	/**
@@ -988,20 +1047,36 @@  discard block
 block discarded – undo
988 1047
 			if ($row['registration'] != '') {
989 1048
 				$row['registration'] = str_replace('.','',$row['registration']);
990 1049
 				$image_array = $Image->getSpotterImage($row['registration']);
991
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
992
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
993
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
994
-			if ($row['registration'] == '') $row['registration'] = 'NA';
995
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1050
+				if (count($image_array) > 0) {
1051
+					$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1052
+				} else {
1053
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1054
+				}
1055
+			} else {
1056
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1057
+			}
1058
+			if ($row['registration'] == '') {
1059
+				$row['registration'] = 'NA';
1060
+			}
1061
+			if ($row['ident'] == '') {
1062
+				$row['ident'] = 'NA';
1063
+			}
996 1064
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
997 1065
 			if (isset($identicao[0])) {
998 1066
 				if (substr($row['ident'],0,2) == 'AF') {
999
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1000
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1001
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1067
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1068
+						$icao = $row['ident'];
1069
+					} else {
1070
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1071
+					}
1072
+				} else {
1073
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1074
+				}
1002 1075
 
1003 1076
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1004
-			} else $icao = $row['ident'];
1077
+			} else {
1078
+				$icao = $row['ident'];
1079
+			}
1005 1080
 			$icao = $Translation->checkTranslation($icao,false);
1006 1081
 
1007 1082
 			$decode = json_decode($row['decode'],true);
@@ -1027,7 +1102,9 @@  discard block
 block discarded – undo
1027 1102
 					$found = true;
1028 1103
 				}
1029 1104
 			}
1030
-			if ($found) $row['decode'] = json_encode($decode);
1105
+			if ($found) {
1106
+				$row['decode'] = json_encode($decode);
1107
+			}
1031 1108
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1032 1109
 			$result[] = $data;
1033 1110
 			$i++;
@@ -1035,8 +1112,9 @@  discard block
 block discarded – undo
1035 1112
 		if (isset($result)) {
1036 1113
 			$result[0]['query_number_rows'] = $i;
1037 1114
 			return $result;
1115
+		} else {
1116
+			return array();
1038 1117
 		}
1039
-		else return array();
1040 1118
 	}
1041 1119
 
1042 1120
 	/**
@@ -1096,20 +1174,36 @@  discard block
 block discarded – undo
1096 1174
 			if ($row['registration'] != '') {
1097 1175
 				$row['registration'] = str_replace('.','',$row['registration']);
1098 1176
 				$image_array = $Image->getSpotterImage($row['registration']);
1099
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1100
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1101
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1177
+				if (count($image_array) > 0) {
1178
+					$data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1179
+				} else {
1180
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1181
+				}
1182
+			} else {
1183
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1184
+			}
1102 1185
 			$icao = '';
1103
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1104
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1186
+			if ($row['registration'] == '') {
1187
+				$row['registration'] = 'NA';
1188
+			}
1189
+			if ($row['ident'] == '') {
1190
+				$row['ident'] = 'NA';
1191
+			}
1105 1192
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1106 1193
 			if (isset($identicao[0])) {
1107 1194
 				if (substr($row['ident'],0,2) == 'AF') {
1108
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1109
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1110
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1195
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1196
+						$icao = $row['ident'];
1197
+					} else {
1198
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1199
+					}
1200
+				} else {
1201
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1202
+				}
1111 1203
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1112
-			} else $icao = $row['ident'];
1204
+			} else {
1205
+				$icao = $row['ident'];
1206
+			}
1113 1207
 			$icao = $Translation->checkTranslation($icao);
1114 1208
 
1115 1209
 
@@ -1117,12 +1211,16 @@  discard block
 block discarded – undo
1117 1211
 			$found = false;
1118 1212
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1119 1213
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1120
-				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1214
+				if (isset($airport_info[0]['icao'])) {
1215
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1216
+				}
1121 1217
 				$found = true;
1122 1218
 			}
1123 1219
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1124 1220
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1125
-				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1221
+				if (isset($airport_info[0]['icao'])) {
1222
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1223
+				}
1126 1224
 				$found = true;
1127 1225
 			}
1128 1226
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1132,7 +1230,9 @@  discard block
 block discarded – undo
1132 1230
 					$found = true;
1133 1231
 				}
1134 1232
 			}
1135
-			if ($found) $row['decode'] = json_encode($decode);
1233
+			if ($found) {
1234
+				$row['decode'] = json_encode($decode);
1235
+			}
1136 1236
 
1137 1237
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1138 1238
 			$result[] = $data;
@@ -1141,7 +1241,9 @@  discard block
 block discarded – undo
1141 1241
 		if (isset($result)) {
1142 1242
 			$result[0]['query_number_rows'] = $i;
1143 1243
 			return $result;
1144
-		} else return array();
1244
+		} else {
1245
+			return array();
1246
+		}
1145 1247
 	}
1146 1248
 
1147 1249
 	/**
@@ -1157,19 +1259,29 @@  discard block
 block discarded – undo
1157 1259
 		$ident = trim($ident);
1158 1260
 		$Translation = new Translation($this->db);
1159 1261
 		$Spotter = new Spotter($this->db);
1160
-		if ($globalDebug) echo "Test if we add ModeS data...";
1262
+		if ($globalDebug) {
1263
+			echo "Test if we add ModeS data...";
1264
+		}
1161 1265
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1162
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1163
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1266
+		if ($icao == '') {
1267
+			$icao = $Translation->checkTranslation($ident);
1268
+		}
1269
+		if ($globalDebug) {
1270
+			echo '- Ident : '.$icao.' - ';
1271
+		}
1164 1272
 		if ($ident == '' || $registration == '') {
1165
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1273
+			if ($globalDebug) {
1274
+				echo "Ident or registration null, exit\n";
1275
+			}
1166 1276
 			return '';
1167 1277
 		}
1168 1278
 
1169 1279
 		$registration = str_replace('.','',$registration);
1170 1280
 		$ident = $Translation->ident2icao($ident);
1171 1281
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1172
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1282
+		if ($globalDebug) {
1283
+			echo "Check if needed to add translation ".$ident.'... ';
1284
+		}
1173 1285
 		$querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1";
1174 1286
 		$querysi_values = array(':registration' => $registration);
1175 1287
 		try {
@@ -1177,7 +1289,9 @@  discard block
 block discarded – undo
1177 1289
 			$sthsi = $this->db->prepare($querysi);
1178 1290
 			$sthsi->execute($querysi_values);
1179 1291
 		} catch(PDOException $e) {
1180
-			if ($globalDebug) echo $e->getMessage();
1292
+			if ($globalDebug) {
1293
+				echo $e->getMessage();
1294
+			}
1181 1295
 			return "error : ".$e->getMessage();
1182 1296
 		}
1183 1297
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1186,9 +1300,14 @@  discard block
 block discarded – undo
1186 1300
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1187 1301
 			$Translation = new Translation($this->db);
1188 1302
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1189
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1190
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1191
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1303
+			if ($globalDebug) {
1304
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1305
+			}
1306
+			if ($ident != $trans_ident) {
1307
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1308
+			} elseif ($trans_ident == $ident) {
1309
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1310
+			}
1192 1311
 		} else {
1193 1312
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1194 1313
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1197,18 +1316,25 @@  discard block
 block discarded – undo
1197 1316
 					$sth = $this->db->prepare($query);
1198 1317
 					$sth->execute($query_values);
1199 1318
 				} catch(PDOException $e) {
1200
-					if ($globalDebug) echo $e->getMessage();
1319
+					if ($globalDebug) {
1320
+						echo $e->getMessage();
1321
+					}
1201 1322
 					return "error : ".$e->getMessage();
1202 1323
 				}
1203 1324
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1204 1325
 				$sth->closeCursor();
1205
-				if (isset($result['modes'])) $hex = $result['modes'];
1206
-				else $hex = '';
1326
+				if (isset($result['modes'])) {
1327
+					$hex = $result['modes'];
1328
+				} else {
1329
+					$hex = '';
1330
+				}
1207 1331
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1208 1332
 				$this->SI->add($SI_data);
1209 1333
 			}
1210 1334
 		}
1211
-		if ($globalDebug) echo 'Done'."\n";
1335
+		if ($globalDebug) {
1336
+			echo 'Done'."\n";
1337
+		}
1212 1338
 
1213 1339
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1214 1340
 		$query_values = array(':ident' => $icao);
@@ -1217,15 +1343,20 @@  discard block
 block discarded – undo
1217 1343
 			$sth = $this->db->prepare($query);
1218 1344
 			$sth->execute($query_values);
1219 1345
 		} catch(PDOException $e) {
1220
-			if ($globalDebug) echo $e->getMessage();
1346
+			if ($globalDebug) {
1347
+				echo $e->getMessage();
1348
+			}
1221 1349
 			return "error : ".$e->getMessage();
1222 1350
 		}
1223 1351
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1224 1352
 		$sth->closeCursor();
1225 1353
 		//print_r($result);
1226 1354
 		if (isset($result['flightaware_id'])) {
1227
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1228
-			else $ModeS = '';
1355
+			if (isset($result['ModeS'])) {
1356
+				$ModeS = $result['ModeS'];
1357
+			} else {
1358
+				$ModeS = '';
1359
+			}
1229 1360
 			if ($ModeS == '') {
1230 1361
 				$id = explode('-',$result['flightaware_id']);
1231 1362
 				$ModeS = $id[0];
@@ -1239,13 +1370,17 @@  discard block
 block discarded – undo
1239 1370
 					$sthc = $this->db->prepare($queryc);
1240 1371
 					$sthc->execute($queryc_values);
1241 1372
 				} catch(PDOException $e) {
1242
-					if ($globalDebug) echo $e->getMessage();
1373
+					if ($globalDebug) {
1374
+						echo $e->getMessage();
1375
+					}
1243 1376
 					return "error : ".$e->getMessage();
1244 1377
 				}
1245 1378
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1246 1379
 				$sthc->closeCursor();
1247 1380
 				if (count($row) ==  0) {
1248
-					if ($globalDebug) echo " Add to ModeS table - ";
1381
+					if ($globalDebug) {
1382
+						echo " Add to ModeS table - ";
1383
+					}
1249 1384
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1250 1385
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1251 1386
 					try {
@@ -1253,11 +1388,15 @@  discard block
 block discarded – undo
1253 1388
 						$sthi = $this->db->prepare($queryi);
1254 1389
 						$sthi->execute($queryi_values);
1255 1390
 					} catch(PDOException $e) {
1256
-						if ($globalDebug) echo $e->getMessage();
1391
+						if ($globalDebug) {
1392
+							echo $e->getMessage();
1393
+						}
1257 1394
 						return "error : ".$e->getMessage();
1258 1395
 					}
1259 1396
 				} else {
1260
-					if ($globalDebug) echo " Update ModeS table - ";
1397
+					if ($globalDebug) {
1398
+						echo " Update ModeS table - ";
1399
+					}
1261 1400
 					if ($ICAOTypeCode != '') {
1262 1401
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1263 1402
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1270,7 +1409,9 @@  discard block
 block discarded – undo
1270 1409
 						$sthi = $this->db->prepare($queryi);
1271 1410
 						$sthi->execute($queryi_values);
1272 1411
 					} catch(PDOException $e) {
1273
-						if ($globalDebug) echo $e->getMessage();
1412
+						if ($globalDebug) {
1413
+							echo $e->getMessage();
1414
+						}
1274 1415
 						return "error : ".$e->getMessage();
1275 1416
 					}
1276 1417
 				}
@@ -1292,7 +1433,9 @@  discard block
 block discarded – undo
1292 1433
 					    return "error : ".$e->getMessage();
1293 1434
 				}
1294 1435
 				*/
1295
-				if ($globalDebug) echo " Update Spotter_output table - ";
1436
+				if ($globalDebug) {
1437
+					echo " Update Spotter_output table - ";
1438
+				}
1296 1439
 				if ($ICAOTypeCode != '') {
1297 1440
 					if ($globalDBdriver == 'mysql') {
1298 1441
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1303,8 +1446,7 @@  discard block
 block discarded – undo
1303 1446
 				} else {
1304 1447
 					if ($globalDBdriver == 'mysql') {
1305 1448
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1306
-					}
1307
-					elseif ($globalDBdriver == 'pgsql') {
1449
+					} elseif ($globalDBdriver == 'pgsql') {
1308 1450
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1309 1451
 					}
1310 1452
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1314,15 +1456,21 @@  discard block
 block discarded – undo
1314 1456
 					$sthi = $this->db->prepare($queryi);
1315 1457
 					$sthi->execute($queryi_values);
1316 1458
 				} catch(PDOException $e) {
1317
-					if ($globalDebug) echo $e->getMessage();
1459
+					if ($globalDebug) {
1460
+						echo $e->getMessage();
1461
+					}
1318 1462
 					return "error : ".$e->getMessage();
1319 1463
 				}
1320 1464
 
1321 1465
 			}
1322 1466
 		} else {
1323
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1467
+			if ($globalDebug) {
1468
+				echo " Can't find ModeS in spotter_output - ";
1469
+			}
1470
+		}
1471
+		if ($globalDebug) {
1472
+			echo "Done\n";
1324 1473
 		}
1325
-		if ($globalDebug) echo "Done\n";
1326 1474
 	}
1327 1475
 }
1328 1476
 ?>
Please login to merge, or discard this patch.
require/class.Image.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -319,6 +319,9 @@
 block discarded – undo
319 319
 		return false;
320 320
 	}
321 321
 
322
+	/**
323
+	 * @param string $aircraft_icao
324
+	 */
322 325
 	public function fromIvaoMtl($aircraft_icao,$airline_icao) {
323 326
 		$Common = new Common();
324 327
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
Please login to merge, or discard this patch.
Braces   +123 added lines, -45 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
23 23
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24 24
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
25
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
25
+		if ($registration == '' && $aircraft_icao != '') {
26
+			$registration = $aircraft_icao.$airline_icao;
27
+		}
26 28
 		$registration = trim($registration);
27 29
 		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
28 30
 			FROM spotter_image 
@@ -60,8 +62,11 @@  discard block
 block discarded – undo
60 62
 	public function getExifCopyright($url) {
61 63
 		$exif = exif_read_data($url);
62 64
 		$copyright = '';
63
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
64
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
65
+		if (isset($exif['COMPUTED']['copyright'])) {
66
+			$copyright = $exif['COMPUTED']['copyright'];
67
+		} elseif (isset($exif['copyright'])) {
68
+			$copyright = $exif['copyright'];
69
+		}
65 70
 		if ($copyright != '') {
66 71
 			$copyright = str_replace('Copyright ','',$copyright);
67 72
 			$copyright = str_replace('© ','',$copyright);
@@ -79,18 +84,29 @@  discard block
 block discarded – undo
79 84
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
80 85
 	{
81 86
 		global $globalDebug,$globalAircraftImageFetch;
82
-		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
87
+		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) {
88
+			return '';
89
+		}
83 90
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
84 91
 		$registration = trim($registration);
85 92
 		//getting the aircraft image
86
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
87
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
88
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
89
-		else return "success";
93
+		if ($globalDebug && $registration != '') {
94
+			echo 'Try to find an aircraft image for '.$registration.'...';
95
+		} elseif ($globalDebug && $aircraft_icao != '') {
96
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
97
+		} elseif ($globalDebug && $airline_icao != '') {
98
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
99
+		} else {
100
+			return "success";
101
+		}
90 102
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
91
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
103
+		if ($registration == '' && $aircraft_icao != '') {
104
+			$registration = $aircraft_icao.$airline_icao;
105
+		}
92 106
 		if ($image_url['original'] != '') {
93
-			if ($globalDebug) echo 'Found !'."\n";
107
+			if ($globalDebug) {
108
+				echo 'Found !'."\n";
109
+			}
94 110
 			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
95 111
 			try {
96 112
 				$sth = $this->db->prepare($query);
@@ -99,7 +115,9 @@  discard block
 block discarded – undo
99 115
 				echo $e->getMessage()."\n";
100 116
 				return "error";
101 117
 			}
102
-		} elseif ($globalDebug) echo "Not found :'(\n";
118
+		} elseif ($globalDebug) {
119
+			echo "Not found :'(\n";
120
+		}
103 121
 		return "success";
104 122
 	}
105 123
 
@@ -114,36 +132,75 @@  discard block
 block discarded – undo
114 132
 	{
115 133
 		global $globalAircraftImageSources, $globalIVAO;
116 134
 		$Spotter = new Spotter($this->db);
117
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
135
+		if (!isset($globalIVAO)) {
136
+			$globalIVAO = FALSE;
137
+		}
118 138
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
119 139
 		if ($aircraft_registration != '') {
120
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
140
+			if (strpos($aircraft_registration,'/') !== false) {
141
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
142
+			}
121 143
 			$aircraft_registration = urlencode(trim($aircraft_registration));
122 144
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
123
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
124
-			else $aircraft_name = '';
125
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
126
-			else $aircraft_icao = '';
127
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
128
-			else $airline_icao = '';
145
+			if (isset($aircraft_info[0]['aircraft_name'])) {
146
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
147
+			} else {
148
+				$aircraft_name = '';
149
+			}
150
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
151
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
152
+			} else {
153
+				$aircraft_icao = '';
154
+			}
155
+			if (isset($aircraft_info[0]['airline_icao'])) {
156
+				$airline_icao = $aircraft_info[0]['airline_icao'];
157
+			} else {
158
+				$airline_icao = '';
159
+			}
129 160
 		} elseif ($aircraft_icao != '') {
130 161
 			$aircraft_registration = $aircraft_icao;
131 162
 			$aircraft_name = '';
132
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
133
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
163
+		} else {
164
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
165
+		}
166
+		if (!isset($globalAircraftImageSources)) {
167
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
168
+		}
134 169
 		foreach ($globalAircraftImageSources as $source) {
135 170
 			$source = strtolower($source);
136
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
137
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
138
-			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
139
-			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name);
140
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
141
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
142
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
143
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
144
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
145
-			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
146
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
171
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
172
+				$images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
173
+			}
174
+			if ($source == 'planespotters' && !$globalIVAO) {
175
+				$images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
176
+			}
177
+			if ($source == 'flickr') {
178
+				$images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
179
+			}
180
+			if ($source == 'bing') {
181
+				$images_array = $this->fromBing($aircraft_registration,$aircraft_name);
182
+			}
183
+			if ($source == 'deviantart') {
184
+				$images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
185
+			}
186
+			if ($source == 'wikimedia') {
187
+				$images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
188
+			}
189
+			if ($source == 'jetphotos' && !$globalIVAO) {
190
+				$images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
191
+			}
192
+			if ($source == 'planepictures' && !$globalIVAO) {
193
+				$images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
194
+			}
195
+			if ($source == 'airportdata' && !$globalIVAO) {
196
+				$images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
197
+			}
198
+			if ($source == 'customsources') {
199
+				$images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
200
+			}
201
+			if (isset($images_array) && $images_array['original'] != '') {
202
+				return $images_array;
203
+			}
147 204
 		}
148 205
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
149 206
 	}
@@ -301,8 +358,11 @@  discard block
 block discarded – undo
301 358
 	*/
302 359
 	public function fromFlickr($aircraft_registration,$aircraft_name='') {
303 360
 		$Common = new Common();
304
-		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
305
-		else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
361
+		if ($aircraft_name != '') {
362
+			$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
363
+		} else {
364
+			$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
365
+		}
306 366
 		$data = $Common->getData($url);
307 367
 		if ($xml = simplexml_load_string($data)) {
308 368
 			if (isset($xml->channel->item)) {
@@ -346,9 +406,14 @@  discard block
 block discarded – undo
346 406
 	public function fromBing($aircraft_registration,$aircraft_name='') {
347 407
 		global $globalImageBingKey;
348 408
 		$Common = new Common();
349
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
350
-		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
351
-		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
409
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
410
+			return false;
411
+		}
412
+		if ($aircraft_name != '') {
413
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
414
+		} else {
415
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
416
+		}
352 417
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
353 418
 		$data = $Common->getData($url,'get','',$headers);
354 419
 		$result = json_decode($data);
@@ -402,13 +467,18 @@  discard block
 block discarded – undo
402 467
 	*/
403 468
 	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
404 469
 		$Common = new Common();
405
-		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
406
-		else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
470
+		if ($aircraft_name != '') {
471
+			$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
472
+		} else {
473
+			$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
474
+		}
407 475
 		$data = $Common->getData($url);
408 476
 		$result = json_decode($data);
409 477
 		if (isset($result->query->search[0]->title)) {
410 478
 			$fileo = $result->query->search[0]->title;
411
-			if (substr($fileo,-3) == 'pdf') return false;
479
+			if (substr($fileo,-3) == 'pdf') {
480
+				return false;
481
+			}
412 482
 			$file = urlencode($fileo);
413 483
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
414 484
 			$data2 = $Common->getData($url2);
@@ -478,17 +548,25 @@  discard block
 block discarded – undo
478 548
 					$image_url = array();
479 549
 					$image_url['thumbnail'] = $url_thumbnail;
480 550
 					$image_url['original'] = $url;
481
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
482
-					else $exifCopyright = '';
483
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
484
-					else $image_url['copyright'] = $source['copyright'];
551
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
552
+						$exifCopyright = $this->getExifCopyright($url);
553
+					} else {
554
+						$exifCopyright = '';
555
+					}
556
+					if ($exifCopyright  != '') {
557
+						$image_url['copyright'] = $exifCopyright;
558
+					} else {
559
+						$image_url['copyright'] = $source['copyright'];
560
+					}
485 561
 					$image_url['source_website'] = $source['source_website'];
486 562
 					$image_url['source'] = $source['source'];
487 563
 					return $image_url;
488 564
 				}
489 565
 			}
490 566
 			return false;
491
-		} else return false;
567
+		} else {
568
+			return false;
569
+		}
492 570
 	}
493 571
 }
494 572
 
Please login to merge, or discard this patch.
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	/**
15
-	* Gets the images based on the aircraft registration
16
-	*
17
-	* @return Array the images list
18
-	*
19
-	*/
15
+	 * Gets the images based on the aircraft registration
16
+	 *
17
+	 * @return Array the images list
18
+	 *
19
+	 */
20 20
 	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
21 21
 	{
22 22
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 			WHERE spotter_image.registration = :registration";
30 30
 		$sth = $this->db->prepare($query);
31 31
 		$sth->execute(array(':registration' => $registration));
32
-          /*
32
+		  /*
33 33
         $images_array = array();
34 34
 	$temp_array = array();
35 35
 
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	/**
55
-	* Gets the image copyright based on the Exif data
56
-	*
57
-	* @return String image copyright
58
-	*
59
-	*/
55
+	 * Gets the image copyright based on the Exif data
56
+	 *
57
+	 * @return String image copyright
58
+	 *
59
+	 */
60 60
 	public function getExifCopyright($url) {
61 61
 		$exif = exif_read_data($url);
62 62
 		$copyright = '';
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 	}
72 72
 
73 73
 	/**
74
-	* Adds the images based on the aircraft registration
75
-	*
76
-	* @return String either success or error
77
-	*
78
-	*/
74
+	 * Adds the images based on the aircraft registration
75
+	 *
76
+	 * @return String either success or error
77
+	 *
78
+	 */
79 79
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
80 80
 	{
81 81
 		global $globalDebug,$globalAircraftImageFetch;
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 
106 106
 	/**
107
-	* Gets the aircraft image
108
-	*
109
-	* @param String $aircraft_registration the registration of the aircraft
110
-	* @return Array the aircraft thumbnail, orignal url and copyright
111
-	*
112
-	*/
107
+	 * Gets the aircraft image
108
+	 *
109
+	 * @param String $aircraft_registration the registration of the aircraft
110
+	 * @return Array the aircraft thumbnail, orignal url and copyright
111
+	 *
112
+	 */
113 113
 	public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '')
114 114
 	{
115 115
 		global $globalAircraftImageSources, $globalIVAO;
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 	}
150 150
 
151 151
 	/**
152
-	* Gets the aircraft image from Planespotters
153
-	*
154
-	* @param String $aircraft_registration the registration of the aircraft
155
-	* @param String $aircraft_name type of the aircraft
156
-	* @return Array the aircraft thumbnail, orignal url and copyright
157
-	*
158
-	*/
152
+	 * Gets the aircraft image from Planespotters
153
+	 *
154
+	 * @param String $aircraft_registration the registration of the aircraft
155
+	 * @param String $aircraft_name type of the aircraft
156
+	 * @return Array the aircraft thumbnail, orignal url and copyright
157
+	 *
158
+	 */
159 159
 	public function fromPlanespotters($aircraft_registration, $aircraft_name='') {
160 160
 		$Common = new Common();
161 161
 		// If aircraft registration is only number, also check with aircraft model
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 	}
183 183
 
184 184
 	/**
185
-	* Gets the aircraft image from Deviantart
186
-	*
187
-	* @param String $aircraft_registration the registration of the aircraft
188
-	* @param String $aircraft_name type of the aircraft
189
-	* @return Array the aircraft thumbnail, orignal url and copyright
190
-	*
191
-	*/
185
+	 * Gets the aircraft image from Deviantart
186
+	 *
187
+	 * @param String $aircraft_registration the registration of the aircraft
188
+	 * @param String $aircraft_name type of the aircraft
189
+	 * @return Array the aircraft thumbnail, orignal url and copyright
190
+	 *
191
+	 */
192 192
 	public function fromDeviantart($aircraft_registration, $aircraft_name='') {
193 193
 		$Common = new Common();
194 194
 		// If aircraft registration is only number, also check with aircraft model
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 	}
217 217
 
218 218
 	/**
219
-	* Gets the aircraft image from JetPhotos
220
-	*
221
-	* @param String $aircraft_registration the registration of the aircraft
222
-	* @param String $aircraft_name type of the aircraft
223
-	* @return Array the aircraft thumbnail, orignal url and copyright
224
-	*
225
-	*/
219
+	 * Gets the aircraft image from JetPhotos
220
+	 *
221
+	 * @param String $aircraft_registration the registration of the aircraft
222
+	 * @param String $aircraft_name type of the aircraft
223
+	 * @return Array the aircraft thumbnail, orignal url and copyright
224
+	 *
225
+	 */
226 226
 	public function fromJetPhotos($aircraft_registration, $aircraft_name='') {
227 227
 		$Common = new Common();
228 228
 		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
 	}
259 259
 
260 260
 	/**
261
-	* Gets the aircraft image from PlanePictures
262
-	*
263
-	* @param String $aircraft_registration the registration of the aircraft
264
-	* @param String $aircraft_name type of the aircraft
265
-	* @return Array the aircraft thumbnail, orignal url and copyright
266
-	*
267
-	*/
261
+	 * Gets the aircraft image from PlanePictures
262
+	 *
263
+	 * @param String $aircraft_registration the registration of the aircraft
264
+	 * @param String $aircraft_name type of the aircraft
265
+	 * @return Array the aircraft thumbnail, orignal url and copyright
266
+	 *
267
+	 */
268 268
 	public function fromPlanePictures($aircraft_registration, $aircraft_name='') {
269 269
 		$Common = new Common();
270 270
 		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
@@ -292,13 +292,13 @@  discard block
 block discarded – undo
292 292
 	}
293 293
 
294 294
 	/**
295
-	* Gets the aircraft image from Flickr
296
-	*
297
-	* @param String $aircraft_registration the registration of the aircraft
298
-	* @param String $aircraft_name type of the aircraft
299
-	* @return Array the aircraft thumbnail, orignal url and copyright
300
-	*
301
-	*/
295
+	 * Gets the aircraft image from Flickr
296
+	 *
297
+	 * @param String $aircraft_registration the registration of the aircraft
298
+	 * @param String $aircraft_name type of the aircraft
299
+	 * @return Array the aircraft thumbnail, orignal url and copyright
300
+	 *
301
+	 */
302 302
 	public function fromFlickr($aircraft_registration,$aircraft_name='') {
303 303
 		$Common = new Common();
304 304
 		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 	}
337 337
 
338 338
 	/**
339
-	* Gets the aircraft image from Bing
340
-	*
341
-	* @param String $aircraft_registration the registration of the aircraft
342
-	* @param String $aircraft_name type of the aircraft
343
-	* @return Array the aircraft thumbnail, orignal url and copyright
344
-	*
345
-	*/
339
+	 * Gets the aircraft image from Bing
340
+	 *
341
+	 * @param String $aircraft_registration the registration of the aircraft
342
+	 * @param String $aircraft_name type of the aircraft
343
+	 * @return Array the aircraft thumbnail, orignal url and copyright
344
+	 *
345
+	 */
346 346
 	public function fromBing($aircraft_registration,$aircraft_name='') {
347 347
 		global $globalImageBingKey;
348 348
 		$Common = new Common();
@@ -368,13 +368,13 @@  discard block
 block discarded – undo
368 368
 	}
369 369
 
370 370
 	/**
371
-	* Gets the aircraft image from airport-data
372
-	*
373
-	* @param String $aircraft_registration the registration of the aircraft
374
-	* @param String $aircraft_name type of the aircraft
375
-	* @return Array the aircraft thumbnail, orignal url and copyright
376
-	*
377
-	*/
371
+	 * Gets the aircraft image from airport-data
372
+	 *
373
+	 * @param String $aircraft_registration the registration of the aircraft
374
+	 * @param String $aircraft_name type of the aircraft
375
+	 * @return Array the aircraft thumbnail, orignal url and copyright
376
+	 *
377
+	 */
378 378
 	public function fromAirportData($aircraft_registration,$aircraft_name='') {
379 379
 		$Common = new Common();
380 380
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
@@ -393,13 +393,13 @@  discard block
 block discarded – undo
393 393
 	}
394 394
 
395 395
 	/**
396
-	* Gets the aircraft image from WikiMedia
397
-	*
398
-	* @param String $aircraft_registration the registration of the aircraft
399
-	* @param String $aircraft_name type of the aircraft
400
-	* @return Array the aircraft thumbnail, orignal url and copyright
401
-	*
402
-	*/
396
+	 * Gets the aircraft image from WikiMedia
397
+	 *
398
+	 * @param String $aircraft_registration the registration of the aircraft
399
+	 * @param String $aircraft_name type of the aircraft
400
+	 * @return Array the aircraft thumbnail, orignal url and copyright
401
+	 *
402
+	 */
403 403
 	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
404 404
 		$Common = new Common();
405 405
 		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
 	}
450 450
 
451 451
 	/**
452
-	* Gets the aircraft image from custom url
453
-	*
454
-	* @param String $aircraft_registration the registration of the aircraft
455
-	* @param String $aircraft_name type of the aircraft
456
-	* @return Array the aircraft thumbnail, orignal url and copyright
457
-	*
458
-	*/
452
+	 * Gets the aircraft image from custom url
453
+	 *
454
+	 * @param String $aircraft_registration the registration of the aircraft
455
+	 * @param String $aircraft_name type of the aircraft
456
+	 * @return Array the aircraft thumbnail, orignal url and copyright
457
+	 *
458
+	 */
459 459
 	public function fromCustomSource($aircraft_registration,$aircraft_name='') {
460 460
 		global $globalAircraftImageCustomSources, $globalDebug;
461 461
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 	* @return Array the images list
18 18
 	*
19 19
 	*/
20
-	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
20
+	public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
21 21
 	{
22
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
23
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
22
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
23
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
24
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
25 25
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
26 26
 		$registration = trim($registration);
27
-		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
27
+		$query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
28 28
 			FROM spotter_image 
29 29
 			WHERE spotter_image.registration = :registration";
30 30
 		$sth = $this->db->prepare($query);
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
64 64
 		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
65 65
 		if ($copyright != '') {
66
-			$copyright = str_replace('Copyright ','',$copyright);
67
-			$copyright = str_replace('© ','',$copyright);
68
-			$copyright = str_replace('(c) ','',$copyright);
66
+			$copyright = str_replace('Copyright ', '', $copyright);
67
+			$copyright = str_replace('© ', '', $copyright);
68
+			$copyright = str_replace('(c) ', '', $copyright);
69 69
 		}
70 70
 		return $copyright;
71 71
 	}
@@ -76,26 +76,26 @@  discard block
 block discarded – undo
76 76
 	* @return String either success or error
77 77
 	*
78 78
 	*/
79
-	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
79
+	public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
80 80
 	{
81
-		global $globalDebug,$globalAircraftImageFetch;
81
+		global $globalDebug, $globalAircraftImageFetch;
82 82
 		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
83
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
83
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
84 84
 		$registration = trim($registration);
85 85
 		//getting the aircraft image
86 86
 		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
87 87
 		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
88 88
 		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
89 89
 		else return "success";
90
-		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
90
+		$image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao);
91 91
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
92 92
 		if ($image_url['original'] != '') {
93 93
 			if ($globalDebug) echo 'Found !'."\n";
94
-			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
94
+			$query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
95 95
 			try {
96 96
 				$sth = $this->db->prepare($query);
97
-				$sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
98
-			} catch(PDOException $e) {
97
+				$sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
98
+			} catch (PDOException $e) {
99 99
 				echo $e->getMessage()."\n";
100 100
 				return "error";
101 101
 			}
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 		global $globalAircraftImageSources, $globalIVAO;
116 116
 		$Spotter = new Spotter($this->db);
117 117
 		if (!isset($globalIVAO)) $globalIVAO = FALSE;
118
-		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
118
+		$aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING);
119 119
 		if ($aircraft_registration != '') {
120
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
120
+			if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
121 121
 			$aircraft_registration = urlencode(trim($aircraft_registration));
122 122
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
123 123
 			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
@@ -129,23 +129,23 @@  discard block
 block discarded – undo
129 129
 		} elseif ($aircraft_icao != '') {
130 130
 			$aircraft_registration = $aircraft_icao;
131 131
 			$aircraft_name = '';
132
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
133
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
132
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
133
+		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
134 134
 		foreach ($globalAircraftImageSources as $source) {
135 135
 			$source = strtolower($source);
136
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
137
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
138
-			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
139
-			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name);
140
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
141
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
142
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
143
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
144
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
145
-			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
136
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao, $airline_icao);
137
+			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration, $aircraft_name);
138
+			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration, $aircraft_name);
139
+			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration, $aircraft_name);
140
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration, $aircraft_name);
141
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration, $aircraft_name);
142
+			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration, $aircraft_name);
143
+			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration, $aircraft_name);
144
+			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration, $aircraft_name);
145
+			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration, $aircraft_name);
146 146
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
147 147
 		}
148
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
148
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
149 149
 	}
150 150
 
151 151
 	/**
@@ -156,24 +156,24 @@  discard block
 block discarded – undo
156 156
 	* @return Array the aircraft thumbnail, orignal url and copyright
157 157
 	*
158 158
 	*/
159
-	public function fromPlanespotters($aircraft_registration, $aircraft_name='') {
159
+	public function fromPlanespotters($aircraft_registration, $aircraft_name = '') {
160 160
 		$Common = new Common();
161 161
 		// If aircraft registration is only number, also check with aircraft model
162
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
163
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
162
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
163
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
164 164
 		} else {
165 165
 			//$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
166
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
166
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
167 167
 		}
168 168
 		$data = $Common->getData($url);
169 169
 		if ($xml = simplexml_load_string($data)) {
170 170
 			if (isset($xml->channel->item)) {
171 171
 				$image_url = array();
172
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
172
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
173 173
 				$image_url['thumbnail'] = $thumbnail_url;
174
-				$image_url['original'] = str_replace('thumbnail','original',$thumbnail_url);
175
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
176
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
174
+				$image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url);
175
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
176
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
177 177
 				$image_url['source'] = 'planespotters';
178 178
 				return $image_url;
179 179
 			}
@@ -189,25 +189,25 @@  discard block
 block discarded – undo
189 189
 	* @return Array the aircraft thumbnail, orignal url and copyright
190 190
 	*
191 191
 	*/
192
-	public function fromDeviantart($aircraft_registration, $aircraft_name='') {
192
+	public function fromDeviantart($aircraft_registration, $aircraft_name = '') {
193 193
 		$Common = new Common();
194 194
 		// If aircraft registration is only number, also check with aircraft model
195
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
196
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name);
195
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
196
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name);
197 197
 		} else {
198
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration;
198
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration;
199 199
 		}
200 200
 
201 201
 		$data = $Common->getData($url);
202 202
 		if ($xml = simplexml_load_string($data)) {
203 203
 			if (isset($xml->channel->item->link)) {
204 204
 				$image_url = array();
205
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
205
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
206 206
 				$image_url['thumbnail'] = $thumbnail_url;
207
-				$original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
207
+				$original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
208 208
 				$image_url['original'] = $original_url;
209
-				$image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
210
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
209
+				$image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
210
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
211 211
 				$image_url['source'] = 'deviantart';
212 212
 				return $image_url;
213 213
 			}
@@ -223,32 +223,32 @@  discard block
 block discarded – undo
223 223
 	* @return Array the aircraft thumbnail, orignal url and copyright
224 224
 	*
225 225
 	*/
226
-	public function fromJetPhotos($aircraft_registration, $aircraft_name='') {
226
+	public function fromJetPhotos($aircraft_registration, $aircraft_name = '') {
227 227
 		$Common = new Common();
228
-		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
228
+		$url = 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
229 229
 		$data = $Common->getData($url);
230 230
 		$dom = new DOMDocument();
231 231
 		@$dom->loadHTML($data);
232 232
 		$all_pics = array();
233
-		foreach($dom->getElementsByTagName('img') as $image) {
233
+		foreach ($dom->getElementsByTagName('img') as $image) {
234 234
 			if ($image->getAttribute('itemprop') == "http://schema.org/image") {
235 235
 				$all_pics[] = $image->getAttribute('src');
236 236
 			}
237 237
 		}
238 238
 		$all_authors = array();
239
-		foreach($dom->getElementsByTagName('meta') as $author) {
239
+		foreach ($dom->getElementsByTagName('meta') as $author) {
240 240
 			if ($author->getAttribute('itemprop') == "http://schema.org/author") {
241 241
 				$all_authors[] = $author->getAttribute('content');
242 242
 			}
243 243
 		}
244 244
 		$all_ref = array();
245
-		foreach($dom->getElementsByTagName('a') as $link) {
245
+		foreach ($dom->getElementsByTagName('a') as $link) {
246 246
 			$all_ref[] = $link->getAttribute('href');
247 247
 		}
248 248
 		if (isset($all_pics[0])) {
249 249
 			$image_url = array();
250 250
 			$image_url['thumbnail'] = $all_pics[0];
251
-			$image_url['original'] = str_replace('_tb','',$all_pics[0]);
251
+			$image_url['original'] = str_replace('_tb', '', $all_pics[0]);
252 252
 			$image_url['copyright'] = $all_authors[0];
253 253
 			$image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8];
254 254
 			$image_url['source'] = 'JetPhotos';
@@ -265,24 +265,24 @@  discard block
 block discarded – undo
265 265
 	* @return Array the aircraft thumbnail, orignal url and copyright
266 266
 	*
267 267
 	*/
268
-	public function fromPlanePictures($aircraft_registration, $aircraft_name='') {
268
+	public function fromPlanePictures($aircraft_registration, $aircraft_name = '') {
269 269
 		$Common = new Common();
270
-		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
270
+		$url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
271 271
 		$data = $Common->getData($url);
272 272
 		$dom = new DOMDocument();
273 273
 		@$dom->loadHTML($data);
274 274
 		$all_pics = array();
275
-		foreach($dom->getElementsByTagName('img') as $image) {
275
+		foreach ($dom->getElementsByTagName('img') as $image) {
276 276
 			$all_pics[] = $image->getAttribute('src');
277 277
 		}
278 278
 		$all_links = array();
279
-		foreach($dom->getElementsByTagName('a') as $link) {
280
-			$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
279
+		foreach ($dom->getElementsByTagName('a') as $link) {
280
+			$all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href'));
281 281
 		}
282
-		if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1])) {
282
+		if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1])) {
283 283
 			$image_url = array();
284 284
 			$image_url['thumbnail'] = 'http://www.planepictures.net'.$all_pics[1];
285
-			$image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN','',$all_pics[1]);
285
+			$image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN', '', $all_pics[1]);
286 286
 			$image_url['copyright'] = $all_links[6]['text'];
287 287
 			$image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href'];
288 288
 			$image_url['source'] = 'PlanePictures';
@@ -299,19 +299,19 @@  discard block
 block discarded – undo
299 299
 	* @return Array the aircraft thumbnail, orignal url and copyright
300 300
 	*
301 301
 	*/
302
-	public function fromFlickr($aircraft_registration,$aircraft_name='') {
302
+	public function fromFlickr($aircraft_registration, $aircraft_name = '') {
303 303
 		$Common = new Common();
304 304
 		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
305 305
 		else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
306 306
 		$data = $Common->getData($url);
307 307
 		if ($xml = simplexml_load_string($data)) {
308 308
 			if (isset($xml->channel->item)) {
309
-				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
309
+				$original_url = trim((string) $xml->channel->item->enclosure->attributes()->url);
310 310
 				$image_url = array();
311 311
 				$image_url['thumbnail'] = $original_url;
312 312
 				$image_url['original'] = $original_url;
313
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
314
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
313
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
314
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
315 315
 				$image_url['source'] = 'flickr';
316 316
 				return $image_url;
317 317
 			}
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		return false;
320 320
 	}
321 321
 
322
-	public function fromIvaoMtl($aircraft_icao,$airline_icao) {
322
+	public function fromIvaoMtl($aircraft_icao, $airline_icao) {
323 323
 		$Common = new Common();
324 324
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
325 325
 		if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) {
@@ -343,14 +343,14 @@  discard block
 block discarded – undo
343 343
 	* @return Array the aircraft thumbnail, orignal url and copyright
344 344
 	*
345 345
 	*/
346
-	public function fromBing($aircraft_registration,$aircraft_name='') {
346
+	public function fromBing($aircraft_registration, $aircraft_name = '') {
347 347
 		global $globalImageBingKey;
348 348
 		$Common = new Common();
349 349
 		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
350 350
 		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
351 351
 		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
352
-		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
353
-		$data = $Common->getData($url,'get','',$headers);
352
+		$headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey));
353
+		$data = $Common->getData($url, 'get', '', $headers);
354 354
 		$result = json_decode($data);
355 355
 		if (isset($result->d->results[0]->MediaUrl)) {
356 356
 			$image_url = array();
@@ -375,14 +375,14 @@  discard block
 block discarded – undo
375 375
 	* @return Array the aircraft thumbnail, orignal url and copyright
376 376
 	*
377 377
 	*/
378
-	public function fromAirportData($aircraft_registration,$aircraft_name='') {
378
+	public function fromAirportData($aircraft_registration, $aircraft_name = '') {
379 379
 		$Common = new Common();
380 380
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
381 381
 		$data = $Common->getData($url);
382 382
 		$result = json_decode($data);
383 383
 		if (isset($result->count) && $result->count > 0) {
384 384
 			$image_url = array();
385
-			$image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
385
+			$image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image);
386 386
 			$image_url['source_website'] = $result->data[0]->link;
387 387
 			$image_url['thumbnail'] = $result->data[0]->image;
388 388
 			$image_url['copyright'] = $result->data[0]->photographer;
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 	* @return Array the aircraft thumbnail, orignal url and copyright
401 401
 	*
402 402
 	*/
403
-	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
403
+	public function fromWikimedia($aircraft_registration, $aircraft_name = '') {
404 404
 		$Common = new Common();
405 405
 		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
406 406
 		else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 		$result = json_decode($data);
409 409
 		if (isset($result->query->search[0]->title)) {
410 410
 			$fileo = $result->query->search[0]->title;
411
-			if (substr($fileo,-3) == 'pdf') return false;
411
+			if (substr($fileo, -3) == 'pdf') return false;
412 412
 			$file = urlencode($fileo);
413 413
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
414 414
 			$data2 = $Common->getData($url2);
@@ -433,11 +433,11 @@  discard block
 block discarded – undo
433 433
 				if (isset($result2->query->pages)) {
434 434
 					foreach ($result2->query->pages as $page) {
435 435
 						if (isset($page->imageinfo[0]->extmetadata->Artist)) {
436
-							$image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
436
+							$image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
437 437
 							if (isset($page->imageinfo[0]->extmetadata->License->value)) {
438 438
 								$image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
439 439
 							}
440
-							$image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
440
+							$image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright']));
441 441
 							return $image_url;
442 442
 						}
443 443
 					}
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 	* @return Array the aircraft thumbnail, orignal url and copyright
457 457
 	*
458 458
 	*/
459
-	public function fromCustomSource($aircraft_registration,$aircraft_name='') {
459
+	public function fromCustomSource($aircraft_registration, $aircraft_name = '') {
460 460
 		global $globalAircraftImageCustomSources, $globalDebug;
461 461
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
462 462
 		if (!empty($globalAircraftImageCustomSources)) {
@@ -473,15 +473,15 @@  discard block
 block discarded – undo
473 473
 					print_r($source);
474 474
 					print_r($customsources);
475 475
 				}
476
-				$url = str_replace('{registration}',$aircraft_registration,$source['original']);
477
-				$url_thumbnail = str_replace('{registration}',$aircraft_registration,$source['thumbnail']);
476
+				$url = str_replace('{registration}', $aircraft_registration, $source['original']);
477
+				$url_thumbnail = str_replace('{registration}', $aircraft_registration, $source['thumbnail']);
478 478
 				if ($Common->urlexist($url)) {
479 479
 					$image_url = array();
480 480
 					$image_url['thumbnail'] = $url_thumbnail;
481 481
 					$image_url['original'] = $url;
482 482
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
483 483
 					else $exifCopyright = '';
484
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
484
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
485 485
 					else $image_url['copyright'] = $source['copyright'];
486 486
 					$image_url['source_website'] = $source['source_website'];
487 487
 					$image_url['source'] = $source['source'];
Please login to merge, or discard this patch.
require/class.SBS.php 4 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class SBS {
3
-    static $latlon = array();
3
+	static $latlon = array();
4 4
     
5
-    public function parse($buffer) {
5
+	public function parse($buffer) {
6 6
 	// Not yet finished, no CRC checks
7 7
 	//echo $buffer."\n";
8 8
 	$data = array();
@@ -13,47 +13,47 @@  discard block
 block discarded – undo
13 13
 	$bin = gmp_strval( gmp_init($hex,16), 2);
14 14
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
15 15
 	if (strlen($hex) == 28) {
16
-	    $df = intval(substr($bin,0,5),2);
17
-	    //$ca = intval(substr($bin,5,3),2);
18
-	    // Only support DF17 for now
19
-	    //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
20
-	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
16
+		$df = intval(substr($bin,0,5),2);
17
+		//$ca = intval(substr($bin,5,3),2);
18
+		// Only support DF17 for now
19
+		//if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
20
+		if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
21 21
 		$icao = substr($hex,2,6);
22 22
 		$data['hex'] = $icao;
23 23
 		$tc = intval(substr($bin,32,5),2);
24 24
 		if ($tc >= 1 && $tc <= 4) {
25
-		    //callsign
26
-		    $csbin = substr($bin,40,56);
27
-		    $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
28
-		    $cs = '';
29
-		    $cs .= $charset[intval(substr($csbin,0,6),2)];
30
-		    $cs .= $charset[intval(substr($csbin,6,6),2)];
31
-		    $cs .= $charset[intval(substr($csbin,12,6),2)];
32
-		    $cs .= $charset[intval(substr($csbin,18,6),2)];
33
-		    $cs .= $charset[intval(substr($csbin,24,6),2)];
34
-		    $cs .= $charset[intval(substr($csbin,30,6),2)];
35
-		    $cs .= $charset[intval(substr($csbin,36,6),2)];
36
-		    $cs .= $charset[intval(substr($csbin,42,6),2)];
37
-		    $cs = str_replace('_','',$cs);
38
-		    $cs = str_replace('#','',$cs);
39
-		    $callsign = $cs;
40
-		    $data['ident'] = $callsign;
25
+			//callsign
26
+			$csbin = substr($bin,40,56);
27
+			$charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
28
+			$cs = '';
29
+			$cs .= $charset[intval(substr($csbin,0,6),2)];
30
+			$cs .= $charset[intval(substr($csbin,6,6),2)];
31
+			$cs .= $charset[intval(substr($csbin,12,6),2)];
32
+			$cs .= $charset[intval(substr($csbin,18,6),2)];
33
+			$cs .= $charset[intval(substr($csbin,24,6),2)];
34
+			$cs .= $charset[intval(substr($csbin,30,6),2)];
35
+			$cs .= $charset[intval(substr($csbin,36,6),2)];
36
+			$cs .= $charset[intval(substr($csbin,42,6),2)];
37
+			$cs = str_replace('_','',$cs);
38
+			$cs = str_replace('#','',$cs);
39
+			$callsign = $cs;
40
+			$data['ident'] = $callsign;
41 41
 		} elseif ($tc >= 9 && $tc <= 18) {
42
-		    // Check Q-bit
43
-		    $q = substr($bin,47,1);
44
-		    if ($q) {
42
+			// Check Q-bit
43
+			$q = substr($bin,47,1);
44
+			if ($q) {
45 45
 			$n = intval(substr($bin,40,7).substr($bin,48,4),2);
46 46
 			$alt = $n*25-1000;
47 47
 			$data['altitude'] = $alt;
48
-		    }
49
-		    // Check odd/even flag
50
-		    $oe = substr($bin,53,1);
51
-		    //if ($oe) => odd else even
52
-		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
53
-		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
54
-		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
55
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
56
-		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
48
+			}
49
+			// Check odd/even flag
50
+			$oe = substr($bin,53,1);
51
+			//if ($oe) => odd else even
52
+			//  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
53
+			$cprlat = intval(substr($bin,54,17),2)/131072.0;
54
+			$cprlon = intval(substr($bin,71,17),2)/131072.0;
55
+			if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
56
+			elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
57 57
 			$cprlat_odd = $cprlat;
58 58
 			$cprlon_odd = $cprlon;
59 59
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
@@ -66,53 +66,53 @@  discard block
 block discarded – undo
66 66
 			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
67 67
 			// check latitude zone
68 68
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
69
-			    if ($this::$latlon[$icao]['created'] > time()) {
69
+				if ($this::$latlon[$icao]['created'] > time()) {
70 70
 				$ni = $this->cprN($lat_even,0);
71 71
 				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
72 72
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
73 73
 				$lat = $lat_even;
74 74
 				if ($lon > 180) $lon = $lon -360;
75 75
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
76
-				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
77
-				    $data['latitude'] = $lat;
78
-				    $data['longitude'] = $lon;
76
+					//if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
77
+					$data['latitude'] = $lat;
78
+					$data['longitude'] = $lon;
79 79
 				}
80
-			    } else {
80
+				} else {
81 81
 				$ni = $this->cprN($lat_odd,1);
82 82
 				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
83 83
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
84 84
 				$lat = $lat_odd;
85 85
 				if ($lon > 180) $lon = $lon -360;
86 86
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
87
-				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
88
-				    $data['latitude'] = $lat;
89
-				    $data['longitude'] = $lon;
87
+					//if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
88
+					$data['latitude'] = $lat;
89
+					$data['longitude'] = $lon;
90
+				}
90 91
 				}
91
-			    }
92 92
 			} else echo "Not cprNL";
93 93
 			unset($this::$latlon[$icao]);
94
-		    }
94
+			}
95 95
 		} elseif ($tc == 19) {
96
-		    // speed & heading
97
-		    $v_ew_dir = intval(substr($bin,45,1));
98
-		    $v_ew = intval(substr($bin,46,10),2);
99
-		    $v_ns_dir = intval(substr($bin,56,1));
100
-		    $v_ns = intval(substr($bin,57,10),2);
101
-		    if ($v_ew_dir) $v_ew = -1*$v_ew;
102
-		    if ($v_ns_dir) $v_ns = -1*$v_ns;
103
-		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
104
-		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
105
-		    if ($heading <0) $heading = $heading+360;
106
-		    $data['speed'] = $speed;
107
-		    $data['heading'] = $heading;
96
+			// speed & heading
97
+			$v_ew_dir = intval(substr($bin,45,1));
98
+			$v_ew = intval(substr($bin,46,10),2);
99
+			$v_ns_dir = intval(substr($bin,56,1));
100
+			$v_ns = intval(substr($bin,57,10),2);
101
+			if ($v_ew_dir) $v_ew = -1*$v_ew;
102
+			if ($v_ns_dir) $v_ns = -1*$v_ns;
103
+			$speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
104
+			$heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
105
+			if ($heading <0) $heading = $heading+360;
106
+			$data['speed'] = $speed;
107
+			$data['heading'] = $heading;
108
+		}
108 109
 		}
109
-	    }
110
-	    if (isset($data)) {
110
+		if (isset($data)) {
111 111
 		//print_r($data);
112 112
 		return $data;
113
-	    }
114
-        }
115
-    }
113
+		}
114
+		}
115
+	}
116 116
 
117 117
 
118 118
 	public function cprNL($lat) {
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
 	if ($lat < 86.53536998) return 3;
178 178
 	if ($lat < 87.00000000) return 2;
179 179
 	return 1;
180
-    }
180
+	}
181 181
     
182
-    public function cprN($lat,$isodd) {
182
+	public function cprN($lat,$isodd) {
183 183
 	$nl = $this->cprNL($lat) - $isodd;
184 184
 	if ($nl > 1) return $nl;
185 185
 	else return 1;
186
-    }
186
+	}
187 187
 
188 188
 
189
-    function parityCheck($msg, $bin) {
189
+	function parityCheck($msg, $bin) {
190 190
 $modes_checksum_table = array(
191 191
 0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178,
192 192
 0x2c38bc, 0x161c5e, 0x0b0e2f, 0xfa7d13, 0x82c48d, 0xbe9842, 0x5f4c21, 0xd05c14,
@@ -208,13 +208,13 @@  discard block
 block discarded – undo
208 208
 	$checksum = intval(substr($msg,22,6),16);
209 209
 
210 210
 	for ($j = 0; $j < strlen($bin); $j++) {
211
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
211
+		if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
212 212
 	}
213 213
 	if ($crc == $checksum) return true;
214 214
 	else {
215
-	    //echo "**** CRC ERROR ****\n";
216
-	    return false;
215
+		//echo "**** CRC ERROR ****\n";
216
+		return false;
217
+	}
217 218
 	}
218
-    }
219 219
 }
220 220
 ?>
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -6,83 +6,83 @@  discard block
 block discarded – undo
6 6
 	// Not yet finished, no CRC checks
7 7
 	//echo $buffer."\n";
8 8
 	$data = array();
9
-	$typehex = substr($buffer,0,1);
10
-	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
11
-	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
12
-	else $hex = substr($buffer,1,-1);
13
-	$bin = gmp_strval( gmp_init($hex,16), 2);
9
+	$typehex = substr($buffer, 0, 1);
10
+	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer, 1, -1);
11
+	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer, 13, -13);
12
+	else $hex = substr($buffer, 1, -1);
13
+	$bin = gmp_strval(gmp_init($hex, 16), 2);
14 14
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
15 15
 	if (strlen($hex) == 28) {
16
-	    $df = intval(substr($bin,0,5),2);
16
+	    $df = intval(substr($bin, 0, 5), 2);
17 17
 	    //$ca = intval(substr($bin,5,3),2);
18 18
 	    // Only support DF17 for now
19 19
 	    //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
20
-	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
21
-		$icao = substr($hex,2,6);
20
+	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex, $bin) || $typehex == '@')) {
21
+		$icao = substr($hex, 2, 6);
22 22
 		$data['hex'] = $icao;
23
-		$tc = intval(substr($bin,32,5),2);
23
+		$tc = intval(substr($bin, 32, 5), 2);
24 24
 		if ($tc >= 1 && $tc <= 4) {
25 25
 		    //callsign
26
-		    $csbin = substr($bin,40,56);
26
+		    $csbin = substr($bin, 40, 56);
27 27
 		    $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
28 28
 		    $cs = '';
29
-		    $cs .= $charset[intval(substr($csbin,0,6),2)];
30
-		    $cs .= $charset[intval(substr($csbin,6,6),2)];
31
-		    $cs .= $charset[intval(substr($csbin,12,6),2)];
32
-		    $cs .= $charset[intval(substr($csbin,18,6),2)];
33
-		    $cs .= $charset[intval(substr($csbin,24,6),2)];
34
-		    $cs .= $charset[intval(substr($csbin,30,6),2)];
35
-		    $cs .= $charset[intval(substr($csbin,36,6),2)];
36
-		    $cs .= $charset[intval(substr($csbin,42,6),2)];
37
-		    $cs = str_replace('_','',$cs);
38
-		    $cs = str_replace('#','',$cs);
29
+		    $cs .= $charset[intval(substr($csbin, 0, 6), 2)];
30
+		    $cs .= $charset[intval(substr($csbin, 6, 6), 2)];
31
+		    $cs .= $charset[intval(substr($csbin, 12, 6), 2)];
32
+		    $cs .= $charset[intval(substr($csbin, 18, 6), 2)];
33
+		    $cs .= $charset[intval(substr($csbin, 24, 6), 2)];
34
+		    $cs .= $charset[intval(substr($csbin, 30, 6), 2)];
35
+		    $cs .= $charset[intval(substr($csbin, 36, 6), 2)];
36
+		    $cs .= $charset[intval(substr($csbin, 42, 6), 2)];
37
+		    $cs = str_replace('_', '', $cs);
38
+		    $cs = str_replace('#', '', $cs);
39 39
 		    $callsign = $cs;
40 40
 		    $data['ident'] = $callsign;
41 41
 		} elseif ($tc >= 9 && $tc <= 18) {
42 42
 		    // Check Q-bit
43
-		    $q = substr($bin,47,1);
43
+		    $q = substr($bin, 47, 1);
44 44
 		    if ($q) {
45
-			$n = intval(substr($bin,40,7).substr($bin,48,4),2);
46
-			$alt = $n*25-1000;
45
+			$n = intval(substr($bin, 40, 7).substr($bin, 48, 4), 2);
46
+			$alt = $n*25 - 1000;
47 47
 			$data['altitude'] = $alt;
48 48
 		    }
49 49
 		    // Check odd/even flag
50
-		    $oe = substr($bin,53,1);
50
+		    $oe = substr($bin, 53, 1);
51 51
 		    //if ($oe) => odd else even
52 52
 		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
53
-		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
54
-		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
55
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
53
+		    $cprlat = intval(substr($bin, 54, 17), 2)/131072.0;
54
+		    $cprlon = intval(substr($bin, 71, 17), 2)/131072.0;
55
+		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat, 'longitude' => $cprlon, 'created' => time());
56 56
 		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
57 57
 			$cprlat_odd = $cprlat;
58 58
 			$cprlon_odd = $cprlon;
59 59
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
60 60
 			$cprlon_even = $this::$latlon[$icao]['longitude'];
61 61
 		    
62
-			$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
63
-			$lat_even = (360.0/60)*($j%60+$cprlat_even);
64
-			$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
62
+			$j = 59*$cprlat_even - 60*$cprlat_odd + 0.5;
63
+			$lat_even = (360.0/60)*($j%60 + $cprlat_even);
64
+			$lat_odd = (360.0/59)*($j%59 + $cprlat_odd);
65 65
 			if ($lat_even >= 270) $lat_even = $lat_even - 360;
66 66
 			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
67 67
 			// check latitude zone
68 68
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
69 69
 			    if ($this::$latlon[$icao]['created'] > time()) {
70
-				$ni = $this->cprN($lat_even,0);
71
-				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
72
-				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
70
+				$ni = $this->cprN($lat_even, 0);
71
+				$m = floor($cprlon_even*($this->cprNL($lat_even) - 1) - $cprlon_odd*$this->cprNL($lat_even) + 0.5);
72
+				$lon = (360.0/$ni)*($m%$ni + $cprlon_even);
73 73
 				$lat = $lat_even;
74
-				if ($lon > 180) $lon = $lon -360;
74
+				if ($lon > 180) $lon = $lon - 360;
75 75
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
76 76
 				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
77 77
 				    $data['latitude'] = $lat;
78 78
 				    $data['longitude'] = $lon;
79 79
 				}
80 80
 			    } else {
81
-				$ni = $this->cprN($lat_odd,1);
82
-				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
83
-				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
81
+				$ni = $this->cprN($lat_odd, 1);
82
+				$m = floor($cprlon_even*($this->cprNL($lat_odd) - 1) - $cprlon_odd*$this->cprNL($lat_odd) + 0.5);
83
+				$lon = (360.0/$ni)*($m%$ni + $cprlon_odd);
84 84
 				$lat = $lat_odd;
85
-				if ($lon > 180) $lon = $lon -360;
85
+				if ($lon > 180) $lon = $lon - 360;
86 86
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
87 87
 				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
88 88
 				    $data['latitude'] = $lat;
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 		    }
95 95
 		} elseif ($tc == 19) {
96 96
 		    // speed & heading
97
-		    $v_ew_dir = intval(substr($bin,45,1));
98
-		    $v_ew = intval(substr($bin,46,10),2);
99
-		    $v_ns_dir = intval(substr($bin,56,1));
100
-		    $v_ns = intval(substr($bin,57,10),2);
97
+		    $v_ew_dir = intval(substr($bin, 45, 1));
98
+		    $v_ew = intval(substr($bin, 46, 10), 2);
99
+		    $v_ns_dir = intval(substr($bin, 56, 1));
100
+		    $v_ns = intval(substr($bin, 57, 10), 2);
101 101
 		    if ($v_ew_dir) $v_ew = -1*$v_ew;
102 102
 		    if ($v_ns_dir) $v_ns = -1*$v_ns;
103
-		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
104
-		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
105
-		    if ($heading <0) $heading = $heading+360;
103
+		    $speed = sqrt($v_ns*$v_ns + $v_ew*$v_ew);
104
+		    $heading = atan2($v_ew, $v_ns)*360.0/(2*pi());
105
+		    if ($heading < 0) $heading = $heading + 360;
106 106
 		    $data['speed'] = $speed;
107 107
 		    $data['heading'] = $heading;
108 108
 		}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
 	public function cprNL($lat) {
119 119
 	//Lookup table to convert the latitude to index.
120
-	if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
120
+	if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator.
121 121
 	if ($lat < 10.47047130) return 59;
122 122
 	if ($lat < 14.82817437) return 58;
123 123
 	if ($lat < 18.18626357) return 57;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	return 1;
180 180
     }
181 181
     
182
-    public function cprN($lat,$isodd) {
182
+    public function cprN($lat, $isodd) {
183 183
 	$nl = $this->cprNL($lat) - $isodd;
184 184
 	if ($nl > 1) return $nl;
185 185
 	else return 1;
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
 );
206 206
 
207 207
 	$crc = 0;
208
-	$checksum = intval(substr($msg,22,6),16);
208
+	$checksum = intval(substr($msg, 22, 6), 16);
209 209
 
210 210
 	for ($j = 0; $j < strlen($bin); $j++) {
211
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
211
+	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j], 0);
212 212
 	}
213 213
 	if ($crc == $checksum) return true;
214 214
 	else {
Please login to merge, or discard this patch.
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -179,6 +179,10 @@  discard block
 block discarded – undo
179 179
 	return 1;
180 180
     }
181 181
     
182
+    /**
183
+     * @param double $lat
184
+     * @param integer $isodd
185
+     */
182 186
     public function cprN($lat,$isodd) {
183 187
 	$nl = $this->cprNL($lat) - $isodd;
184 188
 	if ($nl > 1) return $nl;
@@ -186,6 +190,10 @@  discard block
 block discarded – undo
186 190
     }
187 191
 
188 192
 
193
+    /**
194
+     * @param string $msg
195
+     * @param string $bin
196
+     */
189 197
     function parityCheck($msg, $bin) {
190 198
 $modes_checksum_table = array(
191 199
 0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178,
Please login to merge, or discard this patch.
Braces   +223 added lines, -77 removed lines patch added patch discarded remove patch
@@ -7,9 +7,13 @@  discard block
 block discarded – undo
7 7
 	//echo $buffer."\n";
8 8
 	$data = array();
9 9
 	$typehex = substr($buffer,0,1);
10
-	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
11
-	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
12
-	else $hex = substr($buffer,1,-1);
10
+	if ($typehex == '*' || $typehex == ':') {
11
+		$hex = substr($buffer,1,-1);
12
+	} elseif ($typehex == '@' || $typehex == '%') {
13
+		$hex = substr($buffer,13,-13);
14
+	} else {
15
+		$hex = substr($buffer,1,-1);
16
+	}
13 17
 	$bin = gmp_strval( gmp_init($hex,16), 2);
14 18
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
15 19
 	if (strlen($hex) == 28) {
@@ -52,8 +56,9 @@  discard block
 block discarded – undo
52 56
 		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
53 57
 		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
54 58
 		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
55
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
56
-		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
59
+		    if ($oe == 0) {
60
+		    	$this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
61
+		    } elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
57 62
 			$cprlat_odd = $cprlat;
58 63
 			$cprlon_odd = $cprlon;
59 64
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
@@ -62,8 +67,12 @@  discard block
 block discarded – undo
62 67
 			$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
63 68
 			$lat_even = (360.0/60)*($j%60+$cprlat_even);
64 69
 			$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
65
-			if ($lat_even >= 270) $lat_even = $lat_even - 360;
66
-			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
70
+			if ($lat_even >= 270) {
71
+				$lat_even = $lat_even - 360;
72
+			}
73
+			if ($lat_odd >= 270) {
74
+				$lat_odd = $lat_odd - 360;
75
+			}
67 76
 			// check latitude zone
68 77
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
69 78
 			    if ($this::$latlon[$icao]['created'] > time()) {
@@ -71,7 +80,9 @@  discard block
 block discarded – undo
71 80
 				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
72 81
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
73 82
 				$lat = $lat_even;
74
-				if ($lon > 180) $lon = $lon -360;
83
+				if ($lon > 180) {
84
+					$lon = $lon -360;
85
+				}
75 86
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
76 87
 				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
77 88
 				    $data['latitude'] = $lat;
@@ -82,14 +93,18 @@  discard block
 block discarded – undo
82 93
 				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
83 94
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
84 95
 				$lat = $lat_odd;
85
-				if ($lon > 180) $lon = $lon -360;
96
+				if ($lon > 180) {
97
+					$lon = $lon -360;
98
+				}
86 99
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
87 100
 				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
88 101
 				    $data['latitude'] = $lat;
89 102
 				    $data['longitude'] = $lon;
90 103
 				}
91 104
 			    }
92
-			} else echo "Not cprNL";
105
+			} else {
106
+				echo "Not cprNL";
107
+			}
93 108
 			unset($this::$latlon[$icao]);
94 109
 		    }
95 110
 		} elseif ($tc == 19) {
@@ -98,11 +113,17 @@  discard block
 block discarded – undo
98 113
 		    $v_ew = intval(substr($bin,46,10),2);
99 114
 		    $v_ns_dir = intval(substr($bin,56,1));
100 115
 		    $v_ns = intval(substr($bin,57,10),2);
101
-		    if ($v_ew_dir) $v_ew = -1*$v_ew;
102
-		    if ($v_ns_dir) $v_ns = -1*$v_ns;
116
+		    if ($v_ew_dir) {
117
+		    	$v_ew = -1*$v_ew;
118
+		    }
119
+		    if ($v_ns_dir) {
120
+		    	$v_ns = -1*$v_ns;
121
+		    }
103 122
 		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
104 123
 		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
105
-		    if ($heading <0) $heading = $heading+360;
124
+		    if ($heading <0) {
125
+		    	$heading = $heading+360;
126
+		    }
106 127
 		    $data['speed'] = $speed;
107 128
 		    $data['heading'] = $heading;
108 129
 		}
@@ -117,72 +138,194 @@  discard block
 block discarded – undo
117 138
 
118 139
 	public function cprNL($lat) {
119 140
 	//Lookup table to convert the latitude to index.
120
-	if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
121
-	if ($lat < 10.47047130) return 59;
122
-	if ($lat < 14.82817437) return 58;
123
-	if ($lat < 18.18626357) return 57;
124
-	if ($lat < 21.02939493) return 56;
125
-	if ($lat < 23.54504487) return 55;
126
-	if ($lat < 25.82924707) return 54;
127
-	if ($lat < 27.93898710) return 53;
128
-	if ($lat < 29.91135686) return 52;
129
-	if ($lat < 31.77209708) return 51;
130
-	if ($lat < 33.53993436) return 50;
131
-	if ($lat < 35.22899598) return 49;
132
-	if ($lat < 36.85025108) return 48;
133
-	if ($lat < 38.41241892) return 47;
134
-	if ($lat < 39.92256684) return 46;
135
-	if ($lat < 41.38651832) return 45;
136
-	if ($lat < 42.80914012) return 44;
137
-	if ($lat < 44.19454951) return 43;
138
-	if ($lat < 45.54626723) return 42;
139
-	if ($lat < 46.86733252) return 41;
140
-	if ($lat < 48.16039128) return 40;
141
-	if ($lat < 49.42776439) return 39;
142
-	if ($lat < 50.67150166) return 38;
143
-	if ($lat < 51.89342469) return 37;
144
-	if ($lat < 53.09516153) return 36;
145
-	if ($lat < 54.27817472) return 35;
146
-	if ($lat < 55.44378444) return 34;
147
-	if ($lat < 56.59318756) return 33;
148
-	if ($lat < 57.72747354) return 32;
149
-	if ($lat < 58.84763776) return 31;
150
-	if ($lat < 59.95459277) return 30;
151
-	if ($lat < 61.04917774) return 29;
152
-	if ($lat < 62.13216659) return 28;
153
-	if ($lat < 63.20427479) return 27;
154
-	if ($lat < 64.26616523) return 26;
155
-	if ($lat < 65.31845310) return 25;
156
-	if ($lat < 66.36171008) return 24;
157
-	if ($lat < 67.39646774) return 23;
158
-	if ($lat < 68.42322022) return 22;
159
-	if ($lat < 69.44242631) return 21;
160
-	if ($lat < 70.45451075) return 20;
161
-	if ($lat < 71.45986473) return 19;
162
-	if ($lat < 72.45884545) return 18;
163
-	if ($lat < 73.45177442) return 17;
164
-	if ($lat < 74.43893416) return 16;
165
-	if ($lat < 75.42056257) return 15;
166
-	if ($lat < 76.39684391) return 14;
167
-	if ($lat < 77.36789461) return 13;
168
-	if ($lat < 78.33374083) return 12;
169
-	if ($lat < 79.29428225) return 11;
170
-	if ($lat < 80.24923213) return 10;
171
-	if ($lat < 81.19801349) return 9;
172
-	if ($lat < 82.13956981) return 8;
173
-	if ($lat < 83.07199445) return 7;
174
-	if ($lat < 83.99173563) return 6;
175
-	if ($lat < 84.89166191) return 5;
176
-	if ($lat < 85.75541621) return 4;
177
-	if ($lat < 86.53536998) return 3;
178
-	if ($lat < 87.00000000) return 2;
141
+	if ($lat < 0) {
142
+		$lat = -$lat;
143
+	}
144
+	// Table is simmetric about the equator.
145
+	if ($lat < 10.47047130) {
146
+		return 59;
147
+	}
148
+	if ($lat < 14.82817437) {
149
+		return 58;
150
+	}
151
+	if ($lat < 18.18626357) {
152
+		return 57;
153
+	}
154
+	if ($lat < 21.02939493) {
155
+		return 56;
156
+	}
157
+	if ($lat < 23.54504487) {
158
+		return 55;
159
+	}
160
+	if ($lat < 25.82924707) {
161
+		return 54;
162
+	}
163
+	if ($lat < 27.93898710) {
164
+		return 53;
165
+	}
166
+	if ($lat < 29.91135686) {
167
+		return 52;
168
+	}
169
+	if ($lat < 31.77209708) {
170
+		return 51;
171
+	}
172
+	if ($lat < 33.53993436) {
173
+		return 50;
174
+	}
175
+	if ($lat < 35.22899598) {
176
+		return 49;
177
+	}
178
+	if ($lat < 36.85025108) {
179
+		return 48;
180
+	}
181
+	if ($lat < 38.41241892) {
182
+		return 47;
183
+	}
184
+	if ($lat < 39.92256684) {
185
+		return 46;
186
+	}
187
+	if ($lat < 41.38651832) {
188
+		return 45;
189
+	}
190
+	if ($lat < 42.80914012) {
191
+		return 44;
192
+	}
193
+	if ($lat < 44.19454951) {
194
+		return 43;
195
+	}
196
+	if ($lat < 45.54626723) {
197
+		return 42;
198
+	}
199
+	if ($lat < 46.86733252) {
200
+		return 41;
201
+	}
202
+	if ($lat < 48.16039128) {
203
+		return 40;
204
+	}
205
+	if ($lat < 49.42776439) {
206
+		return 39;
207
+	}
208
+	if ($lat < 50.67150166) {
209
+		return 38;
210
+	}
211
+	if ($lat < 51.89342469) {
212
+		return 37;
213
+	}
214
+	if ($lat < 53.09516153) {
215
+		return 36;
216
+	}
217
+	if ($lat < 54.27817472) {
218
+		return 35;
219
+	}
220
+	if ($lat < 55.44378444) {
221
+		return 34;
222
+	}
223
+	if ($lat < 56.59318756) {
224
+		return 33;
225
+	}
226
+	if ($lat < 57.72747354) {
227
+		return 32;
228
+	}
229
+	if ($lat < 58.84763776) {
230
+		return 31;
231
+	}
232
+	if ($lat < 59.95459277) {
233
+		return 30;
234
+	}
235
+	if ($lat < 61.04917774) {
236
+		return 29;
237
+	}
238
+	if ($lat < 62.13216659) {
239
+		return 28;
240
+	}
241
+	if ($lat < 63.20427479) {
242
+		return 27;
243
+	}
244
+	if ($lat < 64.26616523) {
245
+		return 26;
246
+	}
247
+	if ($lat < 65.31845310) {
248
+		return 25;
249
+	}
250
+	if ($lat < 66.36171008) {
251
+		return 24;
252
+	}
253
+	if ($lat < 67.39646774) {
254
+		return 23;
255
+	}
256
+	if ($lat < 68.42322022) {
257
+		return 22;
258
+	}
259
+	if ($lat < 69.44242631) {
260
+		return 21;
261
+	}
262
+	if ($lat < 70.45451075) {
263
+		return 20;
264
+	}
265
+	if ($lat < 71.45986473) {
266
+		return 19;
267
+	}
268
+	if ($lat < 72.45884545) {
269
+		return 18;
270
+	}
271
+	if ($lat < 73.45177442) {
272
+		return 17;
273
+	}
274
+	if ($lat < 74.43893416) {
275
+		return 16;
276
+	}
277
+	if ($lat < 75.42056257) {
278
+		return 15;
279
+	}
280
+	if ($lat < 76.39684391) {
281
+		return 14;
282
+	}
283
+	if ($lat < 77.36789461) {
284
+		return 13;
285
+	}
286
+	if ($lat < 78.33374083) {
287
+		return 12;
288
+	}
289
+	if ($lat < 79.29428225) {
290
+		return 11;
291
+	}
292
+	if ($lat < 80.24923213) {
293
+		return 10;
294
+	}
295
+	if ($lat < 81.19801349) {
296
+		return 9;
297
+	}
298
+	if ($lat < 82.13956981) {
299
+		return 8;
300
+	}
301
+	if ($lat < 83.07199445) {
302
+		return 7;
303
+	}
304
+	if ($lat < 83.99173563) {
305
+		return 6;
306
+	}
307
+	if ($lat < 84.89166191) {
308
+		return 5;
309
+	}
310
+	if ($lat < 85.75541621) {
311
+		return 4;
312
+	}
313
+	if ($lat < 86.53536998) {
314
+		return 3;
315
+	}
316
+	if ($lat < 87.00000000) {
317
+		return 2;
318
+	}
179 319
 	return 1;
180 320
     }
181 321
     
182 322
     public function cprN($lat,$isodd) {
183 323
 	$nl = $this->cprNL($lat) - $isodd;
184
-	if ($nl > 1) return $nl;
185
-	else return 1;
324
+	if ($nl > 1) {
325
+		return $nl;
326
+	} else {
327
+		return 1;
328
+	}
186 329
     }
187 330
 
188 331
 
@@ -208,10 +351,13 @@  discard block
 block discarded – undo
208 351
 	$checksum = intval(substr($msg,22,6),16);
209 352
 
210 353
 	for ($j = 0; $j < strlen($bin); $j++) {
211
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
354
+	    if ($bin[$j]) {
355
+	    	$crc = $crc^intval($modes_checksum_table[$j],0);
356
+	    }
212 357
 	}
213
-	if ($crc == $checksum) return true;
214
-	else {
358
+	if ($crc == $checksum) {
359
+		return true;
360
+	} else {
215 361
 	    //echo "**** CRC ERROR ****\n";
216 362
 	    return false;
217 363
 	}
Please login to merge, or discard this patch.
require/class.Common.php 4 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@  discard block
 block discarded – undo
6 6
 	//protected $cookies = array();
7 7
 	
8 8
 	/**
9
-	* Get data from form result
10
-	* @param String $url form URL
11
-	* @param String $type type of submit form method (get or post)
12
-	* @param String|Array $data values form post method
13
-	* @param Array $headers header to submit with the form
14
-	* @return String the result
15
-	*/
9
+	 * Get data from form result
10
+	 * @param String $url form URL
11
+	 * @param String $type type of submit form method (get or post)
12
+	 * @param String|Array $data values form post method
13
+	 * @param Array $headers header to submit with the form
14
+	 * @return String the result
15
+	 */
16 16
 	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
17 17
 		$ch = curl_init();
18 18
 		curl_setopt($ch, CURLOPT_URL, $url);
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
68 68
 			}
69 69
 		} else {
70
-		    return $result;
70
+			return $result;
71 71
 		}
72 72
 	}
73 73
 	
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 	}
81 81
 	
82 82
 	/**
83
-	* Convert a HTML table to an array
84
-	* @param String $data HTML page
85
-	* @return Array array of the tables in HTML page
86
-	*/
83
+	 * Convert a HTML table to an array
84
+	 * @param String $data HTML page
85
+	 * @return Array array of the tables in HTML page
86
+	 */
87 87
 	public function table2array($data) {
88 88
 		if (!is_string($data)) return array();
89 89
 		if ($data == '') return array();
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 	}
118 118
 	
119 119
 	/**
120
-	* Convert <p> part of a HTML page to an array
121
-	* @param String $data HTML page
122
-	* @return Array array of the <p> in HTML page
123
-	*/
120
+	 * Convert <p> part of a HTML page to an array
121
+	 * @param String $data HTML page
122
+	 * @return Array array of the <p> in HTML page
123
+	 */
124 124
 	public function text2array($data) {
125 125
 		$html = str_get_html($data);
126 126
 		if ($html === false) return array();
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 	}
136 136
 
137 137
 	/**
138
-	* Give distance between 2 coordonnates
139
-	* @param Float $lat latitude of first point
140
-	* @param Float $lon longitude of first point
141
-	* @param Float $latc latitude of second point
142
-	* @param Float $lonc longitude of second point
143
-	* @param String $unit km else no unit used
144
-	* @return Float Distance in $unit
145
-	*/
138
+	 * Give distance between 2 coordonnates
139
+	 * @param Float $lat latitude of first point
140
+	 * @param Float $lon longitude of first point
141
+	 * @param Float $latc latitude of second point
142
+	 * @param Float $lonc longitude of second point
143
+	 * @param String $unit km else no unit used
144
+	 * @return Float Distance in $unit
145
+	 */
146 146
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
147 147
 		if ($lat == $latc && $lon == $lonc) return 0;
148 148
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	}
161 161
 
162 162
 	/**
163
-	* Check is distance realistic
164
-	* @param int $timeDifference the time between the reception of both messages
165
-	* @param float $distance distance covered
166
-	* @return whether distance is realistic
167
-	*/
163
+	 * Check is distance realistic
164
+	 * @param int $timeDifference the time between the reception of both messages
165
+	 * @param float $distance distance covered
166
+	 * @return whether distance is realistic
167
+	 */
168 168
 	public function withinThreshold ($timeDifference, $distance) {
169 169
 		$x = abs($timeDifference);
170 170
 		$d = abs($distance);
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	}
183 183
 
184 184
 	public function isInteger($input){
185
-	    return(ctype_digit(strval($input)));
185
+		return(ctype_digit(strval($input)));
186 186
 	}
187 187
 
188 188
 
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
 	}
199 199
 	
200 200
 	/**
201
-	* Copy folder contents
202
-	* @param       string   $source    Source path
203
-	* @param       string   $dest      Destination path
204
-	* @return      bool     Returns true on success, false on failure
205
-	*/
201
+	 * Copy folder contents
202
+	 * @param       string   $source    Source path
203
+	 * @param       string   $dest      Destination path
204
+	 * @return      bool     Returns true on success, false on failure
205
+	 */
206 206
 	public function xcopy($source, $dest)
207 207
 	{
208 208
 		$files = glob($source.'*.*');
@@ -214,20 +214,20 @@  discard block
 block discarded – undo
214 214
 	}
215 215
 	
216 216
 	/**
217
-	* Check if an url exist
218
-	* @param	String $url url to check
219
-	* @return	bool Return true on succes false on failure
220
-	*/
217
+	 * Check if an url exist
218
+	 * @param	String $url url to check
219
+	 * @return	bool Return true on succes false on failure
220
+	 */
221 221
 	public function urlexist($url){
222 222
 		$headers=get_headers($url);
223 223
 		return stripos($headers[0],"200 OK")?true:false;
224 224
 	}
225 225
 	
226 226
 	/**
227
-	* Convert hexa to string
228
-	* @param	String $hex data in hexa
229
-	* @return	String Return result
230
-	*/
227
+	 * Convert hexa to string
228
+	 * @param	String $hex data in hexa
229
+	 * @return	String Return result
230
+	 */
231 231
 	public function hex2str($hex) {
232 232
 		$str = '';
233 233
 		$hexln = strlen($hex);
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 	}
276 276
 	
277 277
 	/**
278
-	* Returns list of available locales
279
-	*
280
-	* @return array
278
+	 * Returns list of available locales
279
+	 *
280
+	 * @return array
281 281
 	 */
282 282
 	public function listLocaleDir()
283 283
 	{
Please login to merge, or discard this patch.
Braces   +57 added lines, -24 removed lines patch added patch discarded remove patch
@@ -27,8 +27,11 @@  discard block
 block discarded – undo
27 27
 		} else {
28 28
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
29 29
 		}
30
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
31
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
30
+		if ($timeout == '') {
31
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
32
+		} else {
33
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
34
+		}
32 35
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
33 36
 		if ($type == 'post') {
34 37
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -74,8 +77,9 @@  discard block
 block discarded – undo
74 77
 	private function curlResponseHeaderCallback($ch, $headerLine) {
75 78
 		//global $cookies;
76 79
 		$cookies = array();
77
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
78
-			$cookies[] = $cookie;
80
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
81
+					$cookies[] = $cookie;
82
+		}
79 83
 		return strlen($headerLine); // Needed by curl
80 84
 	}
81 85
 
@@ -86,11 +90,15 @@  discard block
 block discarded – undo
86 90
 		curl_setopt($ch, CURLOPT_URL, $url);
87 91
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
88 92
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
89
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
93
+		if ($referer != '') {
94
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
95
+		}
90 96
 		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');
91 97
 		curl_setopt($ch, CURLOPT_FILE, $fp);
92 98
 		curl_exec($ch);
93
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
99
+		if (curl_errno($ch) && $globalDebug) {
100
+			echo 'Download error: '.curl_error($ch);
101
+		}
94 102
 		curl_close($ch);
95 103
 		fclose($fp);
96 104
 	}
@@ -101,10 +109,16 @@  discard block
 block discarded – undo
101 109
 	* @return Array array of the tables in HTML page
102 110
 	*/
103 111
 	public function table2array($data) {
104
-		if (!is_string($data)) return array();
105
-		if ($data == '') return array();
112
+		if (!is_string($data)) {
113
+			return array();
114
+		}
115
+		if ($data == '') {
116
+			return array();
117
+		}
106 118
 		$html = str_get_html($data);
107
-		if ($html === false) return array();
119
+		if ($html === false) {
120
+			return array();
121
+		}
108 122
 		$tabledata=array();
109 123
 		foreach($html->find('tr') as $element)
110 124
 		{
@@ -139,7 +153,9 @@  discard block
 block discarded – undo
139 153
 	*/
140 154
 	public function text2array($data) {
141 155
 		$html = str_get_html($data);
142
-		if ($html === false) return array();
156
+		if ($html === false) {
157
+			return array();
158
+		}
143 159
 		$tabledata=array();
144 160
 		foreach($html->find('p') as $element)
145 161
 		{
@@ -160,7 +176,9 @@  discard block
 block discarded – undo
160 176
 	* @return Float Distance in $unit
161 177
 	*/
162 178
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
163
-		if ($lat == $latc && $lon == $lonc) return 0;
179
+		if ($lat == $latc && $lon == $lonc) {
180
+			return 0;
181
+		}
164 182
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
165 183
 		if ($unit == "km") {
166 184
 			return round($dist * 1.609344);
@@ -184,10 +202,16 @@  discard block
 block discarded – undo
184 202
 	public function withinThreshold ($timeDifference, $distance) {
185 203
 		$x = abs($timeDifference);
186 204
 		$d = abs($distance);
187
-		if ($x == 0 || $d == 0) return true;
205
+		if ($x == 0 || $d == 0) {
206
+			return true;
207
+		}
188 208
 		// may be due to Internet jitter; distance is realistic
189
-		if ($x < 0.7 && $d < 2000) return true;
190
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
209
+		if ($x < 0.7 && $d < 2000) {
210
+			return true;
211
+		} else {
212
+			return $d/$x < 1500*0.27778;
213
+		}
214
+		// 1500 km/h max
191 215
 	}
192 216
 
193 217
 
@@ -247,7 +271,9 @@  discard block
 block discarded – undo
247 271
 	public function hex2str($hex) {
248 272
 		$str = '';
249 273
 		$hexln = strlen($hex);
250
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
274
+		for($i=0;$i<$hexln;$i+=2) {
275
+			$str .= chr(hexdec(substr($hex,$i,2)));
276
+		}
251 277
 		return $str;
252 278
 	}
253 279
 	
@@ -275,8 +301,11 @@  discard block
 block discarded – undo
275 301
 		$b = $lat2 - $lat1;
276 302
 		$c = -($a*$lat1+$b*$lon1);
277 303
 		$d = $a*$lat3+$b*$lon3+$c;
278
-		if ($d > -$approx && $d < $approx) return true;
279
-		else return false;
304
+		if ($d > -$approx && $d < $approx) {
305
+			return true;
306
+		} else {
307
+			return false;
308
+		}
280 309
 	}
281 310
 	
282 311
 	public function array_merge_noappend() {
@@ -312,7 +341,9 @@  discard block
 block discarded – undo
312 341
 			return $result;
313 342
 		}
314 343
 		$handle = @opendir('./locale');
315
-		if ($handle === false) return $result;
344
+		if ($handle === false) {
345
+			return $result;
346
+		}
316 347
 		while (false !== ($file = readdir($handle))) {
317 348
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
318 349
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -379,8 +410,9 @@  discard block
 block discarded – undo
379 410
 		$error = false; 
380 411
 		if ($fp_out = gzopen($dest, $mode)) { 
381 412
 			if ($fp_in = fopen($source,'rb')) { 
382
-				while (!feof($fp_in)) 
383
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
413
+				while (!feof($fp_in)) {
414
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
415
+				}
384 416
 				fclose($fp_in); 
385 417
 			} else {
386 418
 				$error = true; 
@@ -389,10 +421,11 @@  discard block
 block discarded – undo
389 421
 		} else {
390 422
 			$error = true; 
391 423
 		}
392
-		if ($error)
393
-			return false; 
394
-		else
395
-			return $dest; 
424
+		if ($error) {
425
+					return false;
426
+		} else {
427
+					return $dest;
428
+		}
396 429
 	} 
397 430
 }
398 431
 ?>
399 432
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 	* @param Array $headers header to submit with the form
14 14
 	* @return String the result
15 15
 	*/
16
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
16
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') {
17 17
 		$ch = curl_init();
18 18
 		curl_setopt($ch, CURLOPT_URL, $url);
19 19
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
20 20
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
21 21
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
22
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
22
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
23 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');
24 24
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
25 25
 		if ($useragent == '') {
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 		}
30 30
 		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
31 31
 		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
32
-		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
32
+		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback"));
33 33
 		if ($type == 'post') {
34 34
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
35 35
 			if (is_array($data)) {
36 36
 				curl_setopt($ch, CURLOPT_POST, count($data));
37 37
 				$data_string = '';
38
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
38
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
39 39
 				rtrim($data_string, '&');
40 40
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
41 41
 			} else {
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		}
48 48
 		if ($cookie != '') {
49 49
 			if (is_array($cookie)) {
50
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
50
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
51 51
 			} else {
52 52
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
53 53
 			}
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 		$result = curl_exec($ch);
59 59
 		$info = curl_getinfo($ch);
60 60
 		curl_close($ch);
61
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
61
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
62 62
 			echo "Cloudflare Detected\n";
63 63
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
64 64
 			$useragent = UAgent::random();
65 65
 			cloudflare::useUserAgent($useragent);
66 66
 			if ($clearanceCookie = cloudflare::bypass($url)) {
67
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
67
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
68 68
 			}
69 69
 		} else {
70 70
 		    return $result;
@@ -105,27 +105,27 @@  discard block
 block discarded – undo
105 105
 		if ($data == '') return array();
106 106
 		$html = str_get_html($data);
107 107
 		if ($html === false) return array();
108
-		$tabledata=array();
109
-		foreach($html->find('tr') as $element)
108
+		$tabledata = array();
109
+		foreach ($html->find('tr') as $element)
110 110
 		{
111 111
 			$td = array();
112
-			foreach( $element->find('th') as $row)
112
+			foreach ($element->find('th') as $row)
113 113
 			{
114 114
 				$td [] = trim($row->plaintext);
115 115
 			}
116
-			$td=array_filter($td);
116
+			$td = array_filter($td);
117 117
 			$tabledata[] = $td;
118 118
 
119 119
 			$td = array();
120 120
 			$tdi = array();
121
-			foreach( $element->find('td') as $row)
121
+			foreach ($element->find('td') as $row)
122 122
 			{
123 123
 				$td [] = trim($row->plaintext);
124 124
 				$tdi [] = trim($row->innertext);
125 125
 			}
126
-			$td=array_filter($td);
127
-			$tdi=array_filter($tdi);
128
-			$tabledata[]=array_merge($td,$tdi);
126
+			$td = array_filter($td);
127
+			$tdi = array_filter($tdi);
128
+			$tabledata[] = array_merge($td, $tdi);
129 129
 		}
130 130
 		$html->clear();
131 131
 		unset($html);
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	public function text2array($data) {
141 141
 		$html = str_get_html($data);
142 142
 		if ($html === false) return array();
143
-		$tabledata=array();
144
-		foreach($html->find('p') as $element)
143
+		$tabledata = array();
144
+		foreach ($html->find('p') as $element)
145 145
 		{
146 146
 			$tabledata [] = trim($element->plaintext);
147 147
 		}
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
 	*/
162 162
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
163 163
 		if ($lat == $latc && $lon == $lonc) return 0;
164
-		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
164
+		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515;
165 165
 		if ($unit == "km") {
166
-			return round($dist * 1.609344);
166
+			return round($dist*1.609344);
167 167
 		} elseif ($unit == "m") {
168
-			return round($dist * 1.609344 * 1000);
168
+			return round($dist*1.609344*1000);
169 169
 		} elseif ($unit == "mile" || $unit == "mi") {
170 170
 			return round($dist);
171 171
 		} elseif ($unit == "nm") {
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	* @param float $distance distance covered
182 182
 	* @return whether distance is realistic
183 183
 	*/
184
-	public function withinThreshold ($timeDifference, $distance) {
184
+	public function withinThreshold($timeDifference, $distance) {
185 185
 		$x = abs($timeDifference);
186 186
 		$d = abs($distance);
187 187
 		if ($x == 0 || $d == 0) return true;
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
 		return ($array !== array_values($array));
198 198
 	}
199 199
 
200
-	public function isInteger($input){
200
+	public function isInteger($input) {
201 201
 	    return(ctype_digit(strval($input)));
202 202
 	}
203 203
 
204 204
 
205
-	public function convertDec($dms,$latlong) {
205
+	public function convertDec($dms, $latlong) {
206 206
 		if ($latlong == 'latitude') {
207 207
 			$deg = substr($dms, 0, 2);
208 208
 			$min = substr($dms, 2, 4);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			$deg = substr($dms, 0, 3);
211 211
 			$min = substr($dms, 3, 5);
212 212
 		}
213
-		return $deg+(($min*60)/3600);
213
+		return $deg + (($min*60)/3600);
214 214
 	}
215 215
 	
216 216
 	/**
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	public function xcopy($source, $dest)
223 223
 	{
224 224
 		$files = glob($source.'*.*');
225
-		foreach($files as $file){
226
-			$file_to_go = str_replace($source,$dest,$file);
225
+		foreach ($files as $file) {
226
+			$file_to_go = str_replace($source, $dest, $file);
227 227
 			copy($file, $file_to_go);
228 228
 		}
229 229
 		return true;
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 	* @param	String $url url to check
235 235
 	* @return	bool Return true on succes false on failure
236 236
 	*/
237
-	public function urlexist($url){
238
-		$headers=get_headers($url);
239
-		return stripos($headers[0],"200 OK")?true:false;
237
+	public function urlexist($url) {
238
+		$headers = get_headers($url);
239
+		return stripos($headers[0], "200 OK") ? true : false;
240 240
 	}
241 241
 	
242 242
 	/**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	public function hex2str($hex) {
248 248
 		$str = '';
249 249
 		$hexln = strlen($hex);
250
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
250
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
251 251
 		return $str;
252 252
 	}
253 253
 	
@@ -256,33 +256,33 @@  discard block
 block discarded – undo
256 256
 		//difference in longitudinal coordinates
257 257
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
258 258
 		//difference in the phi of latitudinal coordinates
259
-		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
259
+		$dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4));
260 260
 		//we need to recalculate $dLon if it is greater than pi
261
-		if(abs($dLon) > pi()) {
262
-			if($dLon > 0) {
263
-				$dLon = (2 * pi() - $dLon) * -1;
261
+		if (abs($dLon) > pi()) {
262
+			if ($dLon > 0) {
263
+				$dLon = (2*pi() - $dLon)*-1;
264 264
 			} else {
265
-				$dLon = 2 * pi() + $dLon;
265
+				$dLon = 2*pi() + $dLon;
266 266
 			}
267 267
 		}
268 268
 		//return the angle, normalized
269
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
269
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
270 270
 	}
271 271
 	
272
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.1) {
272
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.1) {
273 273
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
274
-		$a = -($lon2-$lon1);
274
+		$a = -($lon2 - $lon1);
275 275
 		$b = $lat2 - $lat1;
276
-		$c = -($a*$lat1+$b*$lon1);
277
-		$d = $a*$lat3+$b*$lon3+$c;
276
+		$c = -($a*$lat1 + $b*$lon1);
277
+		$d = $a*$lat3 + $b*$lon3 + $c;
278 278
 		if ($d > -$approx && $d < $approx) return true;
279 279
 		else return false;
280 280
 	}
281 281
 	
282 282
 	public function array_merge_noappend() {
283 283
 		$output = array();
284
-		foreach(func_get_args() as $array) {
285
-			foreach($array as $key => $value) {
284
+		foreach (func_get_args() as $array) {
285
+			foreach ($array as $key => $value) {
286 286
 				$output[$key] = isset($output[$key]) ?
287 287
 				array_merge($output[$key], $value) : $value;
288 288
 			}
@@ -323,34 +323,34 @@  discard block
 block discarded – undo
323 323
 		return $result;
324 324
 	}
325 325
 
326
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){
326
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) {
327 327
 		global $globalMapRefresh;
328 328
 		$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
329 329
 		$r = 6378;
330 330
 		$latitude = deg2rad($latitude);
331 331
 		$longitude = deg2rad($longitude);
332 332
 		$bearing = deg2rad($heading); 
333
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
334
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
335
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
333
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
334
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
335
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
336 336
 	}
337 337
 	
338
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
338
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
339 339
 		// distance in meter
340 340
 		$R = 6378.14;
341
-		$latitude1 = $latitude * (M_PI/180);
342
-		$longitude1 = $longitude * (M_PI/180);
343
-		$brng = $bearing * (M_PI/180);
341
+		$latitude1 = $latitude*(M_PI/180);
342
+		$longitude1 = $longitude*(M_PI/180);
343
+		$brng = $bearing*(M_PI/180);
344 344
 		$d = $distance;
345 345
 
346 346
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
347
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
347
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
348 348
 
349
-		$latitude2 = $latitude2 * (180/M_PI);
350
-		$longitude2 = $longitude2 * (180/M_PI);
349
+		$latitude2 = $latitude2*(180/M_PI);
350
+		$longitude2 = $longitude2*(180/M_PI);
351 351
 
352
-		$flat = round ($latitude2,6);
353
-		$flong = round ($longitude2,6);
352
+		$flat = round($latitude2, 6);
353
+		$flong = round($longitude2, 6);
354 354
 /*
355 355
 		$dx = $distance*cos($bearing);
356 356
 		$dy = $distance*sin($bearing);
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 		$flong = $longitude + $dlong;
360 360
 		$flat = $latitude + $dlat;
361 361
 */
362
-		return array('latitude' => $flat,'longitude' => $flong);
362
+		return array('latitude' => $flat, 'longitude' => $flong);
363 363
 	}
364 364
 
365 365
 	/**
@@ -373,14 +373,14 @@  discard block
 block discarded – undo
373 373
 	 * @param integer $level GZIP compression level (default: 9)
374 374
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
375 375
 	 */
376
-	public function gzCompressFile($source, $level = 9){ 
377
-		$dest = $source . '.gz'; 
378
-		$mode = 'wb' . $level; 
376
+	public function gzCompressFile($source, $level = 9) { 
377
+		$dest = $source.'.gz'; 
378
+		$mode = 'wb'.$level; 
379 379
 		$error = false; 
380 380
 		if ($fp_out = gzopen($dest, $mode)) { 
381
-			if ($fp_in = fopen($source,'rb')) { 
381
+			if ($fp_in = fopen($source, 'rb')) { 
382 382
 				while (!feof($fp_in)) 
383
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
383
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
384 384
 				fclose($fp_in); 
385 385
 			} else {
386 386
 				$error = true; 
Please login to merge, or discard this patch.
Doc Comments   +9 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,6 +79,10 @@  discard block
 block discarded – undo
79 79
 		return strlen($headerLine); // Needed by curl
80 80
 	}
81 81
 
82
+	/**
83
+	 * @param string $url
84
+	 * @param string $file
85
+	 */
82 86
 	public static function download($url, $file, $referer = '') {
83 87
 		global $globalDebug;
84 88
 		$fp = fopen($file, 'w');
@@ -179,7 +183,7 @@  discard block
 block discarded – undo
179 183
 	* Check is distance realistic
180 184
 	* @param int $timeDifference the time between the reception of both messages
181 185
 	* @param float $distance distance covered
182
-	* @return whether distance is realistic
186
+	* @return boolean distance is realistic
183 187
 	*/
184 188
 	public function withinThreshold ($timeDifference, $distance) {
185 189
 		$x = abs($timeDifference);
@@ -202,6 +206,9 @@  discard block
 block discarded – undo
202 206
 	}
203 207
 
204 208
 
209
+	/**
210
+	 * @param string $latlong
211
+	 */
205 212
 	public function convertDec($dms,$latlong) {
206 213
 		if ($latlong == 'latitude') {
207 214
 			$deg = substr($dms, 0, 2);
@@ -303,7 +310,7 @@  discard block
 block discarded – undo
303 310
 	/**
304 311
 	* Returns list of available locales
305 312
 	*
306
-	* @return array
313
+	* @return string[]
307 314
 	 */
308 315
 	public function listLocaleDir()
309 316
 	{
Please login to merge, or discard this patch.
install/class.update_db.php 4 patches
Doc Comments   +42 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@  discard block
 block discarded – undo
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
 		$fp = fopen($file, 'w+');
15 18
 		$ch = curl_init();
@@ -24,6 +27,9 @@  discard block
 block discarded – undo
24 27
 		fclose($fp);
25 28
 	}
26 29
 
30
+	/**
31
+	 * @param string $in_file
32
+	 */
27 33
 	public static function gunzip($in_file,$out_file_name = '') {
28 34
 		//echo $in_file.' -> '.$out_file_name."\n";
29 35
 		$buffer_size = 4096; // read 4kb at a time
@@ -45,6 +51,9 @@  discard block
 block discarded – undo
45 51
 		}
46 52
 	}
47 53
 
54
+	/**
55
+	 * @param string $in_file
56
+	 */
48 57
 	public static function unzip($in_file) {
49 58
 		if ($in_file != '' && file_exists($in_file)) {
50 59
 			$path = pathinfo(realpath($in_file), PATHINFO_DIRNAME);
@@ -66,6 +75,9 @@  discard block
 block discarded – undo
66 75
 		}
67 76
 	}
68 77
 	
78
+	/**
79
+	 * @param string $database_file
80
+	 */
69 81
 	public static function retrieve_route_sqlite_to_dest($database_file) {
70 82
 		global $globalDebug, $globalTransaction;
71 83
 		//$query = 'TRUNCATE TABLE routes';
@@ -108,6 +120,10 @@  discard block
 block discarded – undo
108 120
 		}
109 121
                 return '';
110 122
 	}
123
+
124
+	/**
125
+	 * @param string $database_file
126
+	 */
111 127
 	public static function retrieve_route_oneworld($database_file) {
112 128
 		global $globalDebug, $globalTransaction;
113 129
 		//$query = 'TRUNCATE TABLE routes';
@@ -147,6 +163,9 @@  discard block
 block discarded – undo
147 163
                 return '';
148 164
 	}
149 165
 	
166
+	/**
167
+	 * @param string $database_file
168
+	 */
150 169
 	public static function retrieve_route_skyteam($database_file) {
151 170
 		global $globalDebug, $globalTransaction;
152 171
 		//$query = 'TRUNCATE TABLE routes';
@@ -186,6 +205,10 @@  discard block
 block discarded – undo
186 205
 		}
187 206
                 return '';
188 207
 	}
208
+
209
+	/**
210
+	 * @param string $database_file
211
+	 */
189 212
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
190 213
 		global $globalTransaction;
191 214
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -251,6 +274,9 @@  discard block
 block discarded – undo
251 274
 		return '';
252 275
 	}
253 276
 
277
+	/**
278
+	 * @param string $database_file
279
+	 */
254 280
 	public static function retrieve_modes_flarmnet($database_file) {
255 281
 		global $globalTransaction;
256 282
 		$Common = new Common();
@@ -321,6 +347,9 @@  discard block
 block discarded – undo
321 347
 		return '';
322 348
 	}
323 349
 
350
+	/**
351
+	 * @param string $database_file
352
+	 */
324 353
 	public static function retrieve_modes_ogn($database_file) {
325 354
 		global $globalTransaction;
326 355
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -389,6 +418,9 @@  discard block
 block discarded – undo
389 418
 		return '';
390 419
 	}
391 420
 
421
+	/**
422
+	 * @param string $database_file
423
+	 */
392 424
 	public static function retrieve_owner($database_file,$country = 'F') {
393 425
 		global $globalTransaction;
394 426
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -939,6 +971,10 @@  discard block
 block discarded – undo
939 971
 		return '';
940 972
         }
941 973
 
974
+	/**
975
+	 * @param string $filename
976
+	 * @param string $tletype
977
+	 */
942 978
 	public static function tle($filename,$tletype) {
943 979
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
944 980
 		global $tmp_dir, $globalTransaction;
@@ -1071,6 +1107,9 @@  discard block
 block discarded – undo
1071 1107
 
1072 1108
 	}
1073 1109
 */
1110
+	/**
1111
+	 * @param string $filename
1112
+	 */
1074 1113
 	public static function waypoints($filename) {
1075 1114
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1076 1115
 		global $tmp_dir, $globalTransaction;
@@ -1118,6 +1157,9 @@  discard block
 block discarded – undo
1118 1157
 		return '';
1119 1158
         }
1120 1159
 
1160
+	/**
1161
+	 * @param string $filename
1162
+	 */
1121 1163
 	public static function ivao_airlines($filename) {
1122 1164
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1123 1165
 		global $tmp_dir, $globalTransaction;
Please login to merge, or discard this patch.
Indentation   +405 added lines, -405 removed lines patch added patch discarded remove patch
@@ -75,38 +75,38 @@  discard block
 block discarded – undo
75 75
 		try {
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78
-                        $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
80
-                        return "error : ".$e->getMessage();
81
-                }
78
+						$sth->execute(array(':source' => $database_file));
79
+				} catch(PDOException $e) {
80
+						return "error : ".$e->getMessage();
81
+				}
82 82
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
84
-    		update_db::connect_sqlite($database_file);
83
+			if ($globalDebug) echo " - Add routes to DB -";
84
+			update_db::connect_sqlite($database_file);
85 85
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
86 86
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
87 87
 		try {
88
-                        $sth = update_db::$db_sqlite->prepare($query);
89
-                        $sth->execute();
90
-                } catch(PDOException $e) {
91
-                        return "error : ".$e->getMessage();
92
-                }
88
+						$sth = update_db::$db_sqlite->prepare($query);
89
+						$sth->execute();
90
+				} catch(PDOException $e) {
91
+						return "error : ".$e->getMessage();
92
+				}
93 93
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
94 94
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
95 95
 		$Connection = new Connection();
96 96
 		$sth_dest = $Connection->db->prepare($query_dest);
97 97
 		try {
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
99
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 100
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101 101
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 102
 				$sth_dest->execute($query_dest_values);
103
-            		}
103
+					}
104 104
 			if ($globalTransaction) $Connection->db->commit();
105 105
 		} catch(PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
109
-                return '';
109
+				return '';
110 110
 	}
111 111
 	public static function retrieve_route_oneworld($database_file) {
112 112
 		global $globalDebug, $globalTransaction;
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 		try {
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120
-                        $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
122
-                        return "error : ".$e->getMessage();
123
-                }
120
+						$sth->execute(array(':source' => 'oneworld'));
121
+				} catch(PDOException $e) {
122
+						return "error : ".$e->getMessage();
123
+				}
124 124
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
125
+			if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128 128
 		if ($fh = fopen($database_file,"r")) {
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 			if ($globalTransaction) $Connection->db->commit();
148 148
 		}
149
-                return '';
149
+				return '';
150 150
 	}
151 151
 	
152 152
 	public static function retrieve_route_skyteam($database_file) {
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 		try {
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161
-                        $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
163
-                        return "error : ".$e->getMessage();
164
-                }
161
+						$sth->execute(array(':source' => 'skyteam'));
162
+				} catch(PDOException $e) {
163
+						return "error : ".$e->getMessage();
164
+				}
165 165
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
166
+			if ($globalDebug) echo " - Add routes to DB -";
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
191 191
 		}
192
-                return '';
192
+				return '';
193 193
 	}
194 194
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
195 195
 		global $globalTransaction;
@@ -198,27 +198,27 @@  discard block
 block discarded – undo
198 198
 		try {
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201
-                        $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
203
-                        return "error : ".$e->getMessage();
204
-                }
201
+						$sth->execute(array(':source' => $database_file));
202
+				} catch(PDOException $e) {
203
+						return "error : ".$e->getMessage();
204
+				}
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
206 206
 		try {
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209
-                        $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
211
-                        return "error : ".$e->getMessage();
212
-                }
209
+						$sth->execute(array(':source' => $database_file));
210
+				} catch(PDOException $e) {
211
+						return "error : ".$e->getMessage();
212
+				}
213 213
 
214
-    		update_db::connect_sqlite($database_file);
214
+			update_db::connect_sqlite($database_file);
215 215
 		$query = 'select * from Aircraft';
216 216
 		try {
217
-                        $sth = update_db::$db_sqlite->prepare($query);
218
-                        $sth->execute();
219
-                } catch(PDOException $e) {
220
-                        return "error : ".$e->getMessage();
221
-                }
217
+						$sth = update_db::$db_sqlite->prepare($query);
218
+						$sth->execute();
219
+				} catch(PDOException $e) {
220
+						return "error : ".$e->getMessage();
221
+				}
222 222
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
223 223
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
224 224
 		
@@ -229,17 +229,17 @@  discard block
 block discarded – undo
229 229
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 230
 		try {
231 231
 			if ($globalTransaction) $Connection->db->beginTransaction();
232
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
232
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 233
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234 234
 				if ($values['UserString4'] == 'M') $type = 'military';
235 235
 				else $type = null;
236 236
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 237
 				$sth_dest->execute($query_dest_values);
238 238
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
239
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
-				    $sth_dest_owner->execute($query_dest_owner_values);
239
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+					$sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242
-            		}
242
+					}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244 244
 		} catch(PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 		try {
251 251
 			$Connection = new Connection();
252 252
 			$sth = $Connection->db->prepare($query);
253
-                        $sth->execute(array(':source' => $database_file));
254
-                } catch(PDOException $e) {
255
-                        return "error : ".$e->getMessage();
256
-                }
253
+						$sth->execute(array(':source' => $database_file));
254
+				} catch(PDOException $e) {
255
+						return "error : ".$e->getMessage();
256
+				}
257 257
 		return '';
258 258
 	}
259 259
 
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 		try {
266 266
 			$Connection = new Connection();
267 267
 			$sth = $Connection->db->prepare($query);
268
-                        $sth->execute(array(':source' => $database_file));
269
-                } catch(PDOException $e) {
270
-                        return "error : ".$e->getMessage();
271
-                }
268
+						$sth->execute(array(':source' => $database_file));
269
+				} catch(PDOException $e) {
270
+						return "error : ".$e->getMessage();
271
+				}
272 272
 		
273 273
 		if ($fh = fopen($database_file,"r")) {
274 274
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -278,26 +278,26 @@  discard block
 block discarded – undo
278 278
 			$sth_dest = $Connection->db->prepare($query_dest);
279 279
 			try {
280 280
 				if ($globalTransaction) $Connection->db->beginTransaction();
281
-            			while (!feof($fh)) {
282
-            				$values = array();
283
-            				$line = $Common->hex2str(fgets($fh,9999));
281
+						while (!feof($fh)) {
282
+							$values = array();
283
+							$line = $Common->hex2str(fgets($fh,9999));
284 284
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
285
-            				$values['ModeS'] = substr($line,0,6);
286
-            				$values['Registration'] = trim(substr($line,69,6));
287
-            				$aircraft_name = trim(substr($line,48,6));
288
-            				// Check if we can find ICAO, else set it to GLID
289
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
-            				$search_more = '';
291
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293
-            				$sth_search = $Connection->db->prepare($query_search);
285
+							$values['ModeS'] = substr($line,0,6);
286
+							$values['Registration'] = trim(substr($line,69,6));
287
+							$aircraft_name = trim(substr($line,48,6));
288
+							// Check if we can find ICAO, else set it to GLID
289
+							$aircraft_name_split = explode(' ',$aircraft_name);
290
+							$search_more = '';
291
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293
+							$sth_search = $Connection->db->prepare($query_search);
294 294
 					try {
295
-                                    		$sth_search->execute();
296
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
297
-	            				//if (count($result) > 0) {
298
-	            				if (isset($result['icao']) && $result['icao'] != '') {
299
-	            				    $values['ICAOTypeCode'] = $result['icao'];
300
-	            				} 
295
+											$sth_search->execute();
296
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
297
+								//if (count($result) > 0) {
298
+								if (isset($result['icao']) && $result['icao'] != '') {
299
+									$values['ICAOTypeCode'] = $result['icao'];
300
+								} 
301 301
 					} catch(PDOException $e) {
302 302
 						return "error : ".$e->getMessage();
303 303
 					}
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
 		try {
321 321
 			$Connection = new Connection();
322 322
 			$sth = $Connection->db->prepare($query);
323
-                        $sth->execute(array(':source' => $database_file));
324
-                } catch(PDOException $e) {
325
-                        return "error : ".$e->getMessage();
326
-                }
323
+						$sth->execute(array(':source' => $database_file));
324
+				} catch(PDOException $e) {
325
+						return "error : ".$e->getMessage();
326
+				}
327 327
 		return '';
328 328
 	}
329 329
 
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 		try {
335 335
 			$Connection = new Connection();
336 336
 			$sth = $Connection->db->prepare($query);
337
-                        $sth->execute(array(':source' => $database_file));
338
-                } catch(PDOException $e) {
339
-                        return "error : ".$e->getMessage();
340
-                }
337
+						$sth->execute(array(':source' => $database_file));
338
+				} catch(PDOException $e) {
339
+						return "error : ".$e->getMessage();
340
+				}
341 341
 		
342 342
 		if ($fh = fopen($database_file,"r")) {
343 343
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -348,24 +348,24 @@  discard block
 block discarded – undo
348 348
 			try {
349 349
 				if ($globalTransaction) $Connection->db->beginTransaction();
350 350
 				$tmp = fgetcsv($fh,9999,',',"'");
351
-            			while (!feof($fh)) {
352
-            				$line = fgetcsv($fh,9999,',',"'");
351
+						while (!feof($fh)) {
352
+							$line = fgetcsv($fh,9999,',',"'");
353 353
             				
354 354
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
355 355
 					//print_r($line);
356
-            				$values['ModeS'] = $line[1];
357
-            				$values['Registration'] = $line[3];
358
-            				$aircraft_name = $line[2];
359
-            				// Check if we can find ICAO, else set it to GLID
360
-            				$aircraft_name_split = explode(' ',$aircraft_name);
361
-            				$search_more = '';
362
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364
-            				$sth_search = $Connection->db->prepare($query_search);
356
+							$values['ModeS'] = $line[1];
357
+							$values['Registration'] = $line[3];
358
+							$aircraft_name = $line[2];
359
+							// Check if we can find ICAO, else set it to GLID
360
+							$aircraft_name_split = explode(' ',$aircraft_name);
361
+							$search_more = '';
362
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364
+							$sth_search = $Connection->db->prepare($query_search);
365 365
 					try {
366
-                                    		$sth_search->execute();
367
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
366
+											$sth_search->execute();
367
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
369 369
 					} catch(PDOException $e) {
370 370
 						return "error : ".$e->getMessage();
371 371
 					}
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
 		try {
389 389
 			$Connection = new Connection();
390 390
 			$sth = $Connection->db->prepare($query);
391
-                        $sth->execute(array(':source' => $database_file));
392
-                } catch(PDOException $e) {
393
-                        return "error : ".$e->getMessage();
394
-                }
391
+						$sth->execute(array(':source' => $database_file));
392
+				} catch(PDOException $e) {
393
+						return "error : ".$e->getMessage();
394
+				}
395 395
 		return '';
396 396
 	}
397 397
 
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
 		try {
403 403
 			$Connection = new Connection();
404 404
 			$sth = $Connection->db->prepare($query);
405
-                        $sth->execute(array(':source' => $database_file));
406
-                } catch(PDOException $e) {
407
-                        return "error : ".$e->getMessage();
408
-                }
405
+						$sth->execute(array(':source' => $database_file));
406
+				} catch(PDOException $e) {
407
+						return "error : ".$e->getMessage();
408
+				}
409 409
 		
410 410
 		if ($fh = fopen($database_file,"r")) {
411 411
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -416,95 +416,95 @@  discard block
 block discarded – undo
416 416
 			try {
417 417
 				if ($globalTransaction) $Connection->db->beginTransaction();
418 418
 				$tmp = fgetcsv($fh,9999,',','"');
419
-            			while (!feof($fh)) {
420
-            				$line = fgetcsv($fh,9999,',','"');
421
-            				$values = array();
422
-            				//print_r($line);
423
-            				if ($country == 'F') {
424
-            				    $values['registration'] = $line[0];
425
-            				    $values['base'] = $line[4];
426
-            				    $values['owner'] = $line[5];
427
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
428
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
429
-					    $values['cancel'] = $line[7];
419
+						while (!feof($fh)) {
420
+							$line = fgetcsv($fh,9999,',','"');
421
+							$values = array();
422
+							//print_r($line);
423
+							if ($country == 'F') {
424
+								$values['registration'] = $line[0];
425
+								$values['base'] = $line[4];
426
+								$values['owner'] = $line[5];
427
+								if ($line[6] == '') $values['date_first_reg'] = null;
428
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
429
+						$values['cancel'] = $line[7];
430 430
 					} elseif ($country == 'EI') {
431
-					    // TODO : add modeS & reg to aircraft_modes
432
-            				    $values['registration'] = $line[0];
433
-            				    $values['base'] = $line[3];
434
-            				    $values['owner'] = $line[2];
435
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
436
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
437
-					    $values['cancel'] = '';
431
+						// TODO : add modeS & reg to aircraft_modes
432
+								$values['registration'] = $line[0];
433
+								$values['base'] = $line[3];
434
+								$values['owner'] = $line[2];
435
+								if ($line[1] == '') $values['date_first_reg'] = null;
436
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
437
+						$values['cancel'] = '';
438 438
 					} elseif ($country == 'HB') {
439
-					    // TODO : add modeS & reg to aircraft_modes
440
-            				    $values['registration'] = $line[0];
441
-            				    $values['base'] = null;
442
-            				    $values['owner'] = $line[5];
443
-            				    $values['date_first_reg'] = null;
444
-					    $values['cancel'] = '';
439
+						// TODO : add modeS & reg to aircraft_modes
440
+								$values['registration'] = $line[0];
441
+								$values['base'] = null;
442
+								$values['owner'] = $line[5];
443
+								$values['date_first_reg'] = null;
444
+						$values['cancel'] = '';
445 445
 					} elseif ($country == 'OK') {
446
-					    // TODO : add modeS & reg to aircraft_modes
447
-            				    $values['registration'] = $line[3];
448
-            				    $values['base'] = null;
449
-            				    $values['owner'] = $line[5];
450
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
451
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
452
-					    $values['cancel'] = '';
446
+						// TODO : add modeS & reg to aircraft_modes
447
+								$values['registration'] = $line[3];
448
+								$values['base'] = null;
449
+								$values['owner'] = $line[5];
450
+								if ($line[18] == '') $values['date_first_reg'] = null;
451
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
452
+						$values['cancel'] = '';
453 453
 					} elseif ($country == 'VH') {
454
-					    // TODO : add modeS & reg to aircraft_modes
455
-            				    $values['registration'] = $line[0];
456
-            				    $values['base'] = null;
457
-            				    $values['owner'] = $line[12];
458
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
460
-
461
-					    $values['cancel'] = $line[39];
454
+						// TODO : add modeS & reg to aircraft_modes
455
+								$values['registration'] = $line[0];
456
+								$values['base'] = null;
457
+								$values['owner'] = $line[12];
458
+								if ($line[28] == '') $values['date_first_reg'] = null;
459
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
460
+
461
+						$values['cancel'] = $line[39];
462 462
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
463
-            				    $values['registration'] = $line[0];
464
-            				    $values['base'] = null;
465
-            				    $values['owner'] = $line[4];
466
-            				    $values['date_first_reg'] = null;
467
-					    $values['cancel'] = '';
463
+								$values['registration'] = $line[0];
464
+								$values['base'] = null;
465
+								$values['owner'] = $line[4];
466
+								$values['date_first_reg'] = null;
467
+						$values['cancel'] = '';
468 468
 					} elseif ($country == 'CC') {
469
-            				    $values['registration'] = $line[0];
470
-            				    $values['base'] = null;
471
-            				    $values['owner'] = $line[6];
472
-            				    $values['date_first_reg'] = null;
473
-					    $values['cancel'] = '';
469
+								$values['registration'] = $line[0];
470
+								$values['base'] = null;
471
+								$values['owner'] = $line[6];
472
+								$values['date_first_reg'] = null;
473
+						$values['cancel'] = '';
474 474
 					} elseif ($country == 'HJ') {
475
-            				    $values['registration'] = $line[0];
476
-            				    $values['base'] = null;
477
-            				    $values['owner'] = $line[8];
478
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
479
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
480
-					    $values['cancel'] = '';
475
+								$values['registration'] = $line[0];
476
+								$values['base'] = null;
477
+								$values['owner'] = $line[8];
478
+								if ($line[7] == '') $values['date_first_reg'] = null;
479
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
480
+						$values['cancel'] = '';
481 481
 					} elseif ($country == 'PP') {
482
-            				    $values['registration'] = $line[0];
483
-            				    $values['base'] = null;
484
-            				    $values['owner'] = $line[4];
485
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
486
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
487
-					    $values['cancel'] = $line[7];
482
+								$values['registration'] = $line[0];
483
+								$values['base'] = null;
484
+								$values['owner'] = $line[4];
485
+								if ($line[6] == '') $values['date_first_reg'] = null;
486
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
487
+						$values['cancel'] = $line[7];
488 488
 					} elseif ($country == 'E7') {
489
-            				    $values['registration'] = $line[0];
490
-            				    $values['base'] = null;
491
-            				    $values['owner'] = $line[4];
492
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
493
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
494
-					    $values['cancel'] = '';
489
+								$values['registration'] = $line[0];
490
+								$values['base'] = null;
491
+								$values['owner'] = $line[4];
492
+								if ($line[5] == '') $values['date_first_reg'] = null;
493
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
494
+						$values['cancel'] = '';
495 495
 					} elseif ($country == '8Q') {
496
-            				    $values['registration'] = $line[0];
497
-            				    $values['base'] = null;
498
-            				    $values['owner'] = $line[3];
499
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
500
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
501
-					    $values['cancel'] = '';
496
+								$values['registration'] = $line[0];
497
+								$values['base'] = null;
498
+								$values['owner'] = $line[3];
499
+								if ($line[7] == '') $values['date_first_reg'] = null;
500
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
501
+						$values['cancel'] = '';
502 502
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
503
-            				    $values['registration'] = $line[0];
504
-            				    $values['base'] = null;
505
-            				    $values['owner'] = $line[3];
506
-            				    $values['date_first_reg'] = null;
507
-					    $values['cancel'] = '';
503
+								$values['registration'] = $line[0];
504
+								$values['base'] = null;
505
+								$values['owner'] = $line[3];
506
+								$values['date_first_reg'] = null;
507
+						$values['cancel'] = '';
508 508
 					}
509 509
 					if ($values['cancel'] == '' && $values['registration'] != null) {
510 510
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -626,20 +626,20 @@  discard block
 block discarded – undo
626 626
 		try {
627 627
 			$Connection = new Connection();
628 628
 			$sth = $Connection->db->prepare($query);
629
-                        $sth->execute();
630
-                } catch(PDOException $e) {
631
-                        return "error : ".$e->getMessage();
632
-                }
629
+						$sth->execute();
630
+				} catch(PDOException $e) {
631
+						return "error : ".$e->getMessage();
632
+				}
633 633
 
634 634
 
635 635
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
636 636
 		try {
637 637
 			$Connection = new Connection();
638 638
 			$sth = $Connection->db->prepare($query);
639
-                        $sth->execute();
640
-                } catch(PDOException $e) {
641
-                        return "error : ".$e->getMessage();
642
-                }
639
+						$sth->execute();
640
+				} catch(PDOException $e) {
641
+						return "error : ".$e->getMessage();
642
+				}
643 643
 
644 644
 		$query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`)
645 645
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
@@ -705,10 +705,10 @@  discard block
 block discarded – undo
705 705
 		try {
706 706
 			$Connection = new Connection();
707 707
 			$sth = $Connection->db->prepare($query);
708
-                        $sth->execute();
709
-                } catch(PDOException $e) {
710
-                        return "error : ".$e->getMessage();
711
-                }
708
+						$sth->execute();
709
+				} catch(PDOException $e) {
710
+						return "error : ".$e->getMessage();
711
+				}
712 712
 
713 713
 
714 714
 		if ($globalDebug) echo "Insert Not available Airport...\n";
@@ -718,10 +718,10 @@  discard block
 block discarded – undo
718 718
 		try {
719 719
 			$Connection = new Connection();
720 720
 			$sth = $Connection->db->prepare($query);
721
-                        $sth->execute($query_values);
722
-                } catch(PDOException $e) {
723
-                        return "error : ".$e->getMessage();
724
-                }
721
+						$sth->execute($query_values);
722
+				} catch(PDOException $e) {
723
+						return "error : ".$e->getMessage();
724
+				}
725 725
 		$i++;
726 726
 /*
727 727
 		$query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)';
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 
836 836
 
837 837
 
838
-                return "success";
838
+				return "success";
839 839
 	}
840 840
 	
841 841
 	public static function translation() {
@@ -851,10 +851,10 @@  discard block
 block discarded – undo
851 851
 		try {
852 852
 			$Connection = new Connection();
853 853
 			$sth = $Connection->db->prepare($query);
854
-                        $sth->execute(array(':source' => 'translation.csv'));
855
-                } catch(PDOException $e) {
856
-                        return "error : ".$e->getMessage();
857
-                }
854
+						$sth->execute(array(':source' => 'translation.csv'));
855
+				} catch(PDOException $e) {
856
+						return "error : ".$e->getMessage();
857
+				}
858 858
 
859 859
 		
860 860
 		//update_db::unzip($out_file);
@@ -873,21 +873,21 @@  discard block
 block discarded – undo
873 873
 					$data = $row;
874 874
 					$operator = $data[2];
875 875
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
876
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
877
-                                                //echo substr($operator, 0, 2)."\n";;
878
-                                                if (count($airline_array) > 0) {
876
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
877
+												//echo substr($operator, 0, 2)."\n";;
878
+												if (count($airline_array) > 0) {
879 879
 							//print_r($airline_array);
880 880
 							$operator = $airline_array[0]['icao'].substr($operator,2);
881
-                                                }
882
-                                        }
881
+												}
882
+										}
883 883
 					
884 884
 					$operator_correct = $data[3];
885 885
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
886
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
887
-                                                if (count($airline_array) > 0) {
888
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
889
-                                            	}
890
-                                        }
886
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
887
+												if (count($airline_array) > 0) {
888
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
889
+												}
890
+										}
891 891
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
892 892
 					try {
893 893
 						$sth = $Connection->db->prepare($query);
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 			//$Connection->db->commit();
902 902
 		}
903 903
 		return '';
904
-        }
904
+		}
905 905
 	
906 906
 	public static function translation_fam() {
907 907
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -911,10 +911,10 @@  discard block
 block discarded – undo
911 911
 		try {
912 912
 			$Connection = new Connection();
913 913
 			$sth = $Connection->db->prepare($query);
914
-                        $sth->execute(array(':source' => 'website_fam'));
915
-                } catch(PDOException $e) {
916
-                        return "error : ".$e->getMessage();
917
-                }
914
+						$sth->execute(array(':source' => 'website_fam'));
915
+				} catch(PDOException $e) {
916
+						return "error : ".$e->getMessage();
917
+				}
918 918
 
919 919
 		
920 920
 		//update_db::unzip($out_file);
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 			//$Connection->db->commit();
944 944
 		}
945 945
 		return '';
946
-        }
946
+		}
947 947
 
948 948
 	/*
949 949
 	* This function use FAA public data.
@@ -955,19 +955,19 @@  discard block
 block discarded – undo
955 955
 		try {
956 956
 			$Connection = new Connection();
957 957
 			$sth = $Connection->db->prepare($query);
958
-                        $sth->execute(array(':source' => 'website_faa'));
959
-                } catch(PDOException $e) {
960
-                        return "error : ".$e->getMessage();
961
-                }
958
+						$sth->execute(array(':source' => 'website_faa'));
959
+				} catch(PDOException $e) {
960
+						return "error : ".$e->getMessage();
961
+				}
962 962
 
963 963
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
964 964
 		try {
965 965
 			$Connection = new Connection();
966 966
 			$sth = $Connection->db->prepare($query);
967
-                        $sth->execute(array(':source' => 'website_faa'));
968
-                } catch(PDOException $e) {
969
-                        return "error : ".$e->getMessage();
970
-                }
967
+						$sth->execute(array(':source' => 'website_faa'));
968
+				} catch(PDOException $e) {
969
+						return "error : ".$e->getMessage();
970
+				}
971 971
 
972 972
 		$delimiter = ",";
973 973
 		$mfr = array();
@@ -1043,17 +1043,17 @@  discard block
 block discarded – undo
1043 1043
 		}
1044 1044
 		print_r($mfr);
1045 1045
 		return '';
1046
-        }
1046
+		}
1047 1047
 	public static function modes_fam() {
1048 1048
 		global $tmp_dir, $globalTransaction;
1049 1049
 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";
1050 1050
 		try {
1051 1051
 			$Connection = new Connection();
1052 1052
 			$sth = $Connection->db->prepare($query);
1053
-                        $sth->execute(array(':source' => 'website_fam'));
1054
-                } catch(PDOException $e) {
1055
-                        return "error : ".$e->getMessage();
1056
-                }
1053
+						$sth->execute(array(':source' => 'website_fam'));
1054
+				} catch(PDOException $e) {
1055
+						return "error : ".$e->getMessage();
1056
+				}
1057 1057
 
1058 1058
 		
1059 1059
 		//update_db::unzip($out_file);
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 			if ($globalTransaction) $Connection->db->commit();
1083 1083
 		}
1084 1084
 		return '';
1085
-        }
1085
+		}
1086 1086
         
1087 1087
 	public static function owner_fam() {
1088 1088
 		global $tmp_dir, $globalTransaction;
@@ -1090,10 +1090,10 @@  discard block
 block discarded – undo
1090 1090
 		try {
1091 1091
 			$Connection = new Connection();
1092 1092
 			$sth = $Connection->db->prepare($query);
1093
-                        $sth->execute(array(':source' => 'website_fam'));
1094
-                } catch(PDOException $e) {
1095
-                        return "error : ".$e->getMessage();
1096
-                }
1093
+						$sth->execute(array(':source' => 'website_fam'));
1094
+				} catch(PDOException $e) {
1095
+						return "error : ".$e->getMessage();
1096
+				}
1097 1097
 
1098 1098
 		$delimiter = "\t";
1099 1099
 		$Connection = new Connection();
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 			if ($globalTransaction) $Connection->db->commit();
1120 1120
 		}
1121 1121
 		return '';
1122
-        }
1122
+		}
1123 1123
 
1124 1124
 	public static function routes_fam() {
1125 1125
 		global $tmp_dir, $globalTransaction;
@@ -1127,10 +1127,10 @@  discard block
 block discarded – undo
1127 1127
 		try {
1128 1128
 			$Connection = new Connection();
1129 1129
 			$sth = $Connection->db->prepare($query);
1130
-                        $sth->execute(array(':source' => 'website_fam'));
1131
-                } catch(PDOException $e) {
1132
-                        return "error : ".$e->getMessage();
1133
-                }
1130
+						$sth->execute(array(':source' => 'website_fam'));
1131
+				} catch(PDOException $e) {
1132
+						return "error : ".$e->getMessage();
1133
+				}
1134 1134
 
1135 1135
 		
1136 1136
 		//update_db::unzip($out_file);
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 			if ($globalTransaction) $Connection->db->commit();
1160 1160
 		}
1161 1161
 		return '';
1162
-        }
1162
+		}
1163 1163
 
1164 1164
 	public static function banned_fam() {
1165 1165
 		global $tmp_dir, $globalTransaction;
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 			if ($globalTransaction) $Connection->db->commit();
1194 1194
 		}
1195 1195
 		return '';
1196
-        }
1196
+		}
1197 1197
 
1198 1198
 	public static function tle($filename,$tletype) {
1199 1199
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1204,10 +1204,10 @@  discard block
 block discarded – undo
1204 1204
 		try {
1205 1205
 			$Connection = new Connection();
1206 1206
 			$sth = $Connection->db->prepare($query);
1207
-                        $sth->execute(array(':source' => $filename));
1208
-                } catch(PDOException $e) {
1209
-                        return "error : ".$e->getMessage();
1210
-                }
1207
+						$sth->execute(array(':source' => $filename));
1208
+				} catch(PDOException $e) {
1209
+						return "error : ".$e->getMessage();
1210
+				}
1211 1211
 		
1212 1212
 		$Connection = new Connection();
1213 1213
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1242,54 +1242,54 @@  discard block
 block discarded – undo
1242 1242
 			//$Connection->db->commit();
1243 1243
 		}
1244 1244
 		return '';
1245
-        }
1245
+		}
1246 1246
 
1247 1247
 	/**
1248
-        * Convert a HTML table to an array
1249
-        * @param String $data HTML page
1250
-        * @return Array array of the tables in HTML page
1251
-        */
1252
-        private static function table2array($data) {
1253
-                $html = str_get_html($data);
1254
-                $tabledata=array();
1255
-                foreach($html->find('tr') as $element)
1256
-                {
1257
-                        $td = array();
1258
-                        foreach( $element->find('th') as $row)
1259
-                        {
1260
-                                $td [] = trim($row->plaintext);
1261
-                        }
1262
-                        $td=array_filter($td);
1263
-                        $tabledata[] = $td;
1264
-
1265
-                        $td = array();
1266
-                        $tdi = array();
1267
-                        foreach( $element->find('td') as $row)
1268
-                        {
1269
-                                $td [] = trim($row->plaintext);
1270
-                                $tdi [] = trim($row->innertext);
1271
-                        }
1272
-                        $td=array_filter($td);
1273
-                        $tdi=array_filter($tdi);
1274
-                    //    $tabledata[]=array_merge($td,$tdi);
1275
-                        $tabledata[]=$td;
1276
-                }
1277
-                return(array_filter($tabledata));
1278
-        }
1279
-
1280
-       /**
1281
-        * Get data from form result
1282
-        * @param String $url form URL
1283
-        * @return String the result
1284
-        */
1285
-        private static function getData($url) {
1286
-                $ch = curl_init();
1287
-                curl_setopt($ch, CURLOPT_URL, $url);
1288
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1289
-                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1290
-                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');
1291
-                return curl_exec($ch);
1292
-        }
1248
+	 * Convert a HTML table to an array
1249
+	 * @param String $data HTML page
1250
+	 * @return Array array of the tables in HTML page
1251
+	 */
1252
+		private static function table2array($data) {
1253
+				$html = str_get_html($data);
1254
+				$tabledata=array();
1255
+				foreach($html->find('tr') as $element)
1256
+				{
1257
+						$td = array();
1258
+						foreach( $element->find('th') as $row)
1259
+						{
1260
+								$td [] = trim($row->plaintext);
1261
+						}
1262
+						$td=array_filter($td);
1263
+						$tabledata[] = $td;
1264
+
1265
+						$td = array();
1266
+						$tdi = array();
1267
+						foreach( $element->find('td') as $row)
1268
+						{
1269
+								$td [] = trim($row->plaintext);
1270
+								$tdi [] = trim($row->innertext);
1271
+						}
1272
+						$td=array_filter($td);
1273
+						$tdi=array_filter($tdi);
1274
+					//    $tabledata[]=array_merge($td,$tdi);
1275
+						$tabledata[]=$td;
1276
+				}
1277
+				return(array_filter($tabledata));
1278
+		}
1279
+
1280
+	   /**
1281
+	    * Get data from form result
1282
+	    * @param String $url form URL
1283
+	    * @return String the result
1284
+	    */
1285
+		private static function getData($url) {
1286
+				$ch = curl_init();
1287
+				curl_setopt($ch, CURLOPT_URL, $url);
1288
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1289
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1290
+				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');
1291
+				return curl_exec($ch);
1292
+		}
1293 1293
 /*
1294 1294
 	public static function waypoints() {
1295 1295
 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html');
@@ -1372,7 +1372,7 @@  discard block
 block discarded – undo
1372 1372
 			if ($globalTransaction) $Connection->db->commit();
1373 1373
 		}
1374 1374
 		return '';
1375
-        }
1375
+		}
1376 1376
 
1377 1377
 	public static function ivao_airlines($filename) {
1378 1378
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1382,10 +1382,10 @@  discard block
 block discarded – undo
1382 1382
 		try {
1383 1383
 			$Connection = new Connection();
1384 1384
 			$sth = $Connection->db->prepare($query);
1385
-                        $sth->execute();
1386
-                } catch(PDOException $e) {
1387
-                        return "error : ".$e->getMessage();
1388
-                }
1385
+						$sth->execute();
1386
+				} catch(PDOException $e) {
1387
+						return "error : ".$e->getMessage();
1388
+				}
1389 1389
 
1390 1390
 		$header = NULL;
1391 1391
 		$delimiter = ':';
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
 			if ($globalTransaction) $Connection->db->commit();
1410 1410
 		}
1411 1411
 		return '';
1412
-        }
1412
+		}
1413 1413
 	
1414 1414
 	public static function update_airspace() {
1415 1415
 		global $tmp_dir, $globalDBdriver;
@@ -1419,11 +1419,11 @@  discard block
 block discarded – undo
1419 1419
 			$query = 'DROP TABLE airspace';
1420 1420
 			try {
1421 1421
 				$sth = $Connection->db->prepare($query);
1422
-                    		$sth->execute();
1423
-	                } catch(PDOException $e) {
1422
+							$sth->execute();
1423
+					} catch(PDOException $e) {
1424 1424
 				return "error : ".$e->getMessage();
1425
-	                }
1426
-	        }
1425
+					}
1426
+			}
1427 1427
 
1428 1428
 
1429 1429
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1478,10 +1478,10 @@  discard block
 block discarded – undo
1478 1478
 			$query = 'DROP TABLE countries';
1479 1479
 			try {
1480 1480
 				$sth = $Connection->db->prepare($query);
1481
-            	        	$sth->execute();
1482
-	                } catch(PDOException $e) {
1483
-    	                	echo "error : ".$e->getMessage();
1484
-	                }
1481
+							$sth->execute();
1482
+					} catch(PDOException $e) {
1483
+							echo "error : ".$e->getMessage();
1484
+					}
1485 1485
 		}
1486 1486
 		if ($globalDBdriver == 'mysql') {
1487 1487
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -1956,11 +1956,11 @@  discard block
 block discarded – undo
1956 1956
 						$query = 'DROP TABLE airspace';
1957 1957
 						try {
1958 1958
 							$sth = $Connection->db->prepare($query);
1959
-    	    	    					$sth->execute();
1960
-			            		} catch(PDOException $e) {
1959
+										$sth->execute();
1960
+								} catch(PDOException $e) {
1961 1961
 							return "error : ".$e->getMessage();
1962
-		            			}
1963
-		    			}
1962
+								}
1963
+						}
1964 1964
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1965 1965
 					update_db::insert_airspace_version($airspace_md5);
1966 1966
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -2080,12 +2080,12 @@  discard block
 block discarded – undo
2080 2080
 		echo $data;
2081 2081
 		*/
2082 2082
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2083
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2084
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2085
-		    $result = fread($fh,100000000);
2086
-		    //echo $result;
2087
-		    //var_dump(str_get_html($result));
2088
-		    //print_r(self::table2array($result));
2083
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2084
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
2085
+			$result = fread($fh,100000000);
2086
+			//echo $result;
2087
+			//var_dump(str_get_html($result));
2088
+			//print_r(self::table2array($result));
2089 2089
 		}
2090 2090
 
2091 2091
 	}
@@ -2099,10 +2099,10 @@  discard block
 block discarded – undo
2099 2099
 		try {
2100 2100
 			$Connection = new Connection();
2101 2101
 			$sth = $Connection->db->prepare($query);
2102
-                        $sth->execute();
2103
-                } catch(PDOException $e) {
2104
-                        return "error : ".$e->getMessage();
2105
-                }
2102
+						$sth->execute();
2103
+				} catch(PDOException $e) {
2104
+						return "error : ".$e->getMessage();
2105
+				}
2106 2106
 
2107 2107
 		$error = '';
2108 2108
 		if ($globalDebug) echo "Notam : Download...";
@@ -2158,8 +2158,8 @@  discard block
 block discarded – undo
2158 2158
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2159 2159
 					$data['permanent'] = 0;
2160 2160
 				} else {
2161
-				    $data['date_end'] = NULL;
2162
-				    $data['permanent'] = 1;
2161
+					$data['date_end'] = NULL;
2162
+					$data['permanent'] = 1;
2163 2163
 				}
2164 2164
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2165 2165
 				$NOTAM = new NOTAM();
@@ -2218,13 +2218,13 @@  discard block
 block discarded – undo
2218 2218
 		try {
2219 2219
 			$Connection = new Connection();
2220 2220
 			$sth = $Connection->db->prepare($query);
2221
-                        $sth->execute();
2222
-                } catch(PDOException $e) {
2223
-                        return "error : ".$e->getMessage();
2224
-                }
2225
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2226
-                if ($row['nb'] > 0) return false;
2227
-                else return true;
2221
+						$sth->execute();
2222
+				} catch(PDOException $e) {
2223
+						return "error : ".$e->getMessage();
2224
+				}
2225
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2226
+				if ($row['nb'] > 0) return false;
2227
+				else return true;
2228 2228
 	}
2229 2229
 
2230 2230
 	public static function insert_last_update() {
@@ -2233,10 +2233,10 @@  discard block
 block discarded – undo
2233 2233
 		try {
2234 2234
 			$Connection = new Connection();
2235 2235
 			$sth = $Connection->db->prepare($query);
2236
-                        $sth->execute();
2237
-                } catch(PDOException $e) {
2238
-                        return "error : ".$e->getMessage();
2239
-                }
2236
+						$sth->execute();
2237
+				} catch(PDOException $e) {
2238
+						return "error : ".$e->getMessage();
2239
+				}
2240 2240
 	}
2241 2241
 
2242 2242
 	public static function check_airspace_version($version) {
@@ -2244,13 +2244,13 @@  discard block
 block discarded – undo
2244 2244
 		try {
2245 2245
 			$Connection = new Connection();
2246 2246
 			$sth = $Connection->db->prepare($query);
2247
-                        $sth->execute(array(':version' => $version));
2248
-                } catch(PDOException $e) {
2249
-                        return "error : ".$e->getMessage();
2250
-                }
2251
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2252
-                if ($row['nb'] > 0) return true;
2253
-                else return false;
2247
+						$sth->execute(array(':version' => $version));
2248
+				} catch(PDOException $e) {
2249
+						return "error : ".$e->getMessage();
2250
+				}
2251
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2252
+				if ($row['nb'] > 0) return true;
2253
+				else return false;
2254 2254
 	}
2255 2255
 
2256 2256
 
@@ -2260,10 +2260,10 @@  discard block
 block discarded – undo
2260 2260
 		try {
2261 2261
 			$Connection = new Connection();
2262 2262
 			$sth = $Connection->db->prepare($query);
2263
-                        $sth->execute(array(':version' => $version));
2264
-                } catch(PDOException $e) {
2265
-                        return "error : ".$e->getMessage();
2266
-                }
2263
+						$sth->execute(array(':version' => $version));
2264
+				} catch(PDOException $e) {
2265
+						return "error : ".$e->getMessage();
2266
+				}
2267 2267
 	}
2268 2268
 
2269 2269
 	public static function check_last_notam_update() {
@@ -2276,13 +2276,13 @@  discard block
 block discarded – undo
2276 2276
 		try {
2277 2277
 			$Connection = new Connection();
2278 2278
 			$sth = $Connection->db->prepare($query);
2279
-                        $sth->execute();
2280
-                } catch(PDOException $e) {
2281
-                        return "error : ".$e->getMessage();
2282
-                }
2283
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2284
-                if ($row['nb'] > 0) return false;
2285
-                else return true;
2279
+						$sth->execute();
2280
+				} catch(PDOException $e) {
2281
+						return "error : ".$e->getMessage();
2282
+				}
2283
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2284
+				if ($row['nb'] > 0) return false;
2285
+				else return true;
2286 2286
 	}
2287 2287
 
2288 2288
 	public static function insert_last_notam_update() {
@@ -2291,10 +2291,10 @@  discard block
 block discarded – undo
2291 2291
 		try {
2292 2292
 			$Connection = new Connection();
2293 2293
 			$sth = $Connection->db->prepare($query);
2294
-                        $sth->execute();
2295
-                } catch(PDOException $e) {
2296
-                        return "error : ".$e->getMessage();
2297
-                }
2294
+						$sth->execute();
2295
+				} catch(PDOException $e) {
2296
+						return "error : ".$e->getMessage();
2297
+				}
2298 2298
 	}
2299 2299
 	public static function check_last_airspace_update() {
2300 2300
 		global $globalDBdriver;
@@ -2306,13 +2306,13 @@  discard block
 block discarded – undo
2306 2306
 		try {
2307 2307
 			$Connection = new Connection();
2308 2308
 			$sth = $Connection->db->prepare($query);
2309
-                        $sth->execute();
2310
-                } catch(PDOException $e) {
2311
-                        return "error : ".$e->getMessage();
2312
-                }
2313
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2314
-                if ($row['nb'] > 0) return false;
2315
-                else return true;
2309
+						$sth->execute();
2310
+				} catch(PDOException $e) {
2311
+						return "error : ".$e->getMessage();
2312
+				}
2313
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2314
+				if ($row['nb'] > 0) return false;
2315
+				else return true;
2316 2316
 	}
2317 2317
 
2318 2318
 	public static function insert_last_airspace_update() {
@@ -2321,10 +2321,10 @@  discard block
 block discarded – undo
2321 2321
 		try {
2322 2322
 			$Connection = new Connection();
2323 2323
 			$sth = $Connection->db->prepare($query);
2324
-                        $sth->execute();
2325
-                } catch(PDOException $e) {
2326
-                        return "error : ".$e->getMessage();
2327
-                }
2324
+						$sth->execute();
2325
+				} catch(PDOException $e) {
2326
+						return "error : ".$e->getMessage();
2327
+				}
2328 2328
 	}
2329 2329
 
2330 2330
 	public static function check_last_owner_update() {
@@ -2337,13 +2337,13 @@  discard block
 block discarded – undo
2337 2337
 		try {
2338 2338
 			$Connection = new Connection();
2339 2339
 			$sth = $Connection->db->prepare($query);
2340
-                        $sth->execute();
2341
-                } catch(PDOException $e) {
2342
-                        return "error : ".$e->getMessage();
2343
-                }
2344
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2345
-                if ($row['nb'] > 0) return false;
2346
-                else return true;
2340
+						$sth->execute();
2341
+				} catch(PDOException $e) {
2342
+						return "error : ".$e->getMessage();
2343
+				}
2344
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2345
+				if ($row['nb'] > 0) return false;
2346
+				else return true;
2347 2347
 	}
2348 2348
 
2349 2349
 	public static function insert_last_owner_update() {
@@ -2352,10 +2352,10 @@  discard block
 block discarded – undo
2352 2352
 		try {
2353 2353
 			$Connection = new Connection();
2354 2354
 			$sth = $Connection->db->prepare($query);
2355
-                        $sth->execute();
2356
-                } catch(PDOException $e) {
2357
-                        return "error : ".$e->getMessage();
2358
-                }
2355
+						$sth->execute();
2356
+				} catch(PDOException $e) {
2357
+						return "error : ".$e->getMessage();
2358
+				}
2359 2359
 	}
2360 2360
 	public static function check_last_schedules_update() {
2361 2361
 		global $globalDBdriver;
@@ -2367,13 +2367,13 @@  discard block
 block discarded – undo
2367 2367
 		try {
2368 2368
 			$Connection = new Connection();
2369 2369
 			$sth = $Connection->db->prepare($query);
2370
-                        $sth->execute();
2371
-                } catch(PDOException $e) {
2372
-                        return "error : ".$e->getMessage();
2373
-                }
2374
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2375
-                if ($row['nb'] > 0) return false;
2376
-                else return true;
2370
+						$sth->execute();
2371
+				} catch(PDOException $e) {
2372
+						return "error : ".$e->getMessage();
2373
+				}
2374
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2375
+				if ($row['nb'] > 0) return false;
2376
+				else return true;
2377 2377
 	}
2378 2378
 
2379 2379
 	public static function insert_last_schedules_update() {
@@ -2382,10 +2382,10 @@  discard block
 block discarded – undo
2382 2382
 		try {
2383 2383
 			$Connection = new Connection();
2384 2384
 			$sth = $Connection->db->prepare($query);
2385
-                        $sth->execute();
2386
-                } catch(PDOException $e) {
2387
-                        return "error : ".$e->getMessage();
2388
-                }
2385
+						$sth->execute();
2386
+				} catch(PDOException $e) {
2387
+						return "error : ".$e->getMessage();
2388
+				}
2389 2389
 	}
2390 2390
 	public static function check_last_tle_update() {
2391 2391
 		global $globalDBdriver;
@@ -2397,13 +2397,13 @@  discard block
 block discarded – undo
2397 2397
 		try {
2398 2398
 			$Connection = new Connection();
2399 2399
 			$sth = $Connection->db->prepare($query);
2400
-                        $sth->execute();
2401
-                } catch(PDOException $e) {
2402
-                        return "error : ".$e->getMessage();
2403
-                }
2404
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2405
-                if ($row['nb'] > 0) return false;
2406
-                else return true;
2400
+						$sth->execute();
2401
+				} catch(PDOException $e) {
2402
+						return "error : ".$e->getMessage();
2403
+				}
2404
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2405
+				if ($row['nb'] > 0) return false;
2406
+				else return true;
2407 2407
 	}
2408 2408
 
2409 2409
 	public static function insert_last_tle_update() {
@@ -2412,10 +2412,10 @@  discard block
 block discarded – undo
2412 2412
 		try {
2413 2413
 			$Connection = new Connection();
2414 2414
 			$sth = $Connection->db->prepare($query);
2415
-                        $sth->execute();
2416
-                } catch(PDOException $e) {
2417
-                        return "error : ".$e->getMessage();
2418
-                }
2415
+						$sth->execute();
2416
+				} catch(PDOException $e) {
2417
+						return "error : ".$e->getMessage();
2418
+				}
2419 2419
 	}
2420 2420
 	public static function delete_duplicatemodes() {
2421 2421
 		global $globalDBdriver;
@@ -2427,10 +2427,10 @@  discard block
 block discarded – undo
2427 2427
 		try {
2428 2428
 			$Connection = new Connection();
2429 2429
 			$sth = $Connection->db->prepare($query);
2430
-                        $sth->execute();
2431
-                } catch(PDOException $e) {
2432
-                        return "error : ".$e->getMessage();
2433
-                }
2430
+						$sth->execute();
2431
+				} catch(PDOException $e) {
2432
+						return "error : ".$e->getMessage();
2433
+				}
2434 2434
 	}
2435 2435
 	public static function delete_duplicateowner() {
2436 2436
 		global $globalDBdriver;
@@ -2442,10 +2442,10 @@  discard block
 block discarded – undo
2442 2442
 		try {
2443 2443
 			$Connection = new Connection();
2444 2444
 			$sth = $Connection->db->prepare($query);
2445
-                        $sth->execute();
2446
-                } catch(PDOException $e) {
2447
-                        return "error : ".$e->getMessage();
2448
-                }
2445
+						$sth->execute();
2446
+				} catch(PDOException $e) {
2447
+						return "error : ".$e->getMessage();
2448
+				}
2449 2449
 	}
2450 2450
 	
2451 2451
 	public static function update_all() {
Please login to merge, or discard this patch.
Braces   +846 added lines, -293 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 		curl_setopt($ch, CURLOPT_URL, $url);
17 17
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
18 18
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
19
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
19
+		if ($referer != '') {
20
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
21
+		}
20 22
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
21 23
 		curl_setopt($ch, CURLOPT_FILE, $fp);
22 24
 		curl_exec($ch);
@@ -27,12 +29,16 @@  discard block
 block discarded – undo
27 29
 	public static function gunzip($in_file,$out_file_name = '') {
28 30
 		//echo $in_file.' -> '.$out_file_name."\n";
29 31
 		$buffer_size = 4096; // read 4kb at a time
30
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32
+		if ($out_file_name == '') {
33
+			$out_file_name = str_replace('.gz', '', $in_file);
34
+		}
31 35
 		if ($in_file != '' && file_exists($in_file)) {
32 36
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
35
-			else {
37
+			if (function_exists('gzopen')) {
38
+				$file = gzopen($in_file,'rb');
39
+			} elseif (function_exists('gzopen64')) {
40
+				$file = gzopen64($in_file,'rb');
41
+			} else {
36 42
 				echo 'gzopen not available';
37 43
 				die;
38 44
 			}
@@ -53,8 +59,12 @@  discard block
 block discarded – undo
53 59
 			if ($res === TRUE) {
54 60
 				$zip->extractTo($path);
55 61
 				$zip->close();
56
-			} else return false;
57
-		} else return false;
62
+			} else {
63
+				return false;
64
+			}
65
+		} else {
66
+			return false;
67
+		}
58 68
 	}
59 69
 	
60 70
 	public static function connect_sqlite($database) {
@@ -69,7 +79,9 @@  discard block
 block discarded – undo
69 79
 	public static function retrieve_route_sqlite_to_dest($database_file) {
70 80
 		global $globalDebug, $globalTransaction;
71 81
 		//$query = 'TRUNCATE TABLE routes';
72
-		if ($globalDebug) echo " - Delete previous routes from DB -";
82
+		if ($globalDebug) {
83
+			echo " - Delete previous routes from DB -";
84
+		}
73 85
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
74 86
 		$Connection = new Connection();
75 87
 		try {
@@ -80,7 +92,9 @@  discard block
 block discarded – undo
80 92
                         return "error : ".$e->getMessage();
81 93
                 }
82 94
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
95
+    		if ($globalDebug) {
96
+    			echo " - Add routes to DB -";
97
+    		}
84 98
     		update_db::connect_sqlite($database_file);
85 99
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
86 100
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -95,15 +109,21 @@  discard block
 block discarded – undo
95 109
 		$Connection = new Connection();
96 110
 		$sth_dest = $Connection->db->prepare($query_dest);
97 111
 		try {
98
-			if ($globalTransaction) $Connection->db->beginTransaction();
112
+			if ($globalTransaction) {
113
+				$Connection->db->beginTransaction();
114
+			}
99 115
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 116
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101 117
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$sth_dest->execute($query_dest_values);
103 119
             		}
104
-			if ($globalTransaction) $Connection->db->commit();
120
+			if ($globalTransaction) {
121
+				$Connection->db->commit();
122
+			}
105 123
 		} catch(PDOException $e) {
106
-			if ($globalTransaction) $Connection->db->rollBack(); 
124
+			if ($globalTransaction) {
125
+				$Connection->db->rollBack();
126
+			}
107 127
 			return "error : ".$e->getMessage();
108 128
 		}
109 129
                 return '';
@@ -111,7 +131,9 @@  discard block
 block discarded – undo
111 131
 	public static function retrieve_route_oneworld($database_file) {
112 132
 		global $globalDebug, $globalTransaction;
113 133
 		//$query = 'TRUNCATE TABLE routes';
114
-		if ($globalDebug) echo " - Delete previous routes from DB -";
134
+		if ($globalDebug) {
135
+			echo " - Delete previous routes from DB -";
136
+		}
115 137
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
116 138
 		$Connection = new Connection();
117 139
 		try {
@@ -122,14 +144,18 @@  discard block
 block discarded – undo
122 144
                         return "error : ".$e->getMessage();
123 145
                 }
124 146
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
147
+    		if ($globalDebug) {
148
+    			echo " - Add routes to DB -";
149
+    		}
126 150
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 151
 		$Spotter = new Spotter();
128 152
 		if ($fh = fopen($database_file,"r")) {
129 153
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
130 154
 			$Connection = new Connection();
131 155
 			$sth_dest = $Connection->db->prepare($query_dest);
132
-			if ($globalTransaction) $Connection->db->beginTransaction();
156
+			if ($globalTransaction) {
157
+				$Connection->db->beginTransaction();
158
+			}
133 159
 			while (!feof($fh)) {
134 160
 				$line = fgetcsv($fh,9999,',');
135 161
 				if ($line[0] != '') {
@@ -138,13 +164,17 @@  discard block
 block discarded – undo
138 164
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139 165
 							$sth_dest->execute($query_dest_values);
140 166
 						} catch(PDOException $e) {
141
-							if ($globalTransaction) $Connection->db->rollBack(); 
167
+							if ($globalTransaction) {
168
+								$Connection->db->rollBack();
169
+							}
142 170
 							return "error : ".$e->getMessage();
143 171
 						}
144 172
 					}
145 173
 				}
146 174
 			}
147
-			if ($globalTransaction) $Connection->db->commit();
175
+			if ($globalTransaction) {
176
+				$Connection->db->commit();
177
+			}
148 178
 		}
149 179
                 return '';
150 180
 	}
@@ -152,7 +182,9 @@  discard block
 block discarded – undo
152 182
 	public static function retrieve_route_skyteam($database_file) {
153 183
 		global $globalDebug, $globalTransaction;
154 184
 		//$query = 'TRUNCATE TABLE routes';
155
-		if ($globalDebug) echo " - Delete previous routes from DB -";
185
+		if ($globalDebug) {
186
+			echo " - Delete previous routes from DB -";
187
+		}
156 188
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
157 189
 		$Connection = new Connection();
158 190
 		try {
@@ -163,7 +195,9 @@  discard block
 block discarded – undo
163 195
                         return "error : ".$e->getMessage();
164 196
                 }
165 197
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
198
+    		if ($globalDebug) {
199
+    			echo " - Add routes to DB -";
200
+    		}
167 201
 
168 202
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 203
 		$Spotter = new Spotter();
@@ -172,7 +206,9 @@  discard block
 block discarded – undo
172 206
 			$Connection = new Connection();
173 207
 			$sth_dest = $Connection->db->prepare($query_dest);
174 208
 			try {
175
-				if ($globalTransaction) $Connection->db->beginTransaction();
209
+				if ($globalTransaction) {
210
+					$Connection->db->beginTransaction();
211
+				}
176 212
 				while (!feof($fh)) {
177 213
 					$line = fgetcsv($fh,9999,',');
178 214
 					if ($line[0] != '') {
@@ -183,9 +219,13 @@  discard block
 block discarded – undo
183 219
 						}
184 220
 					}
185 221
 				}
186
-				if ($globalTransaction) $Connection->db->commit();
222
+				if ($globalTransaction) {
223
+					$Connection->db->commit();
224
+				}
187 225
 			} catch(PDOException $e) {
188
-				if ($globalTransaction) $Connection->db->rollBack(); 
226
+				if ($globalTransaction) {
227
+					$Connection->db->rollBack();
228
+				}
189 229
 				return "error : ".$e->getMessage();
190 230
 			}
191 231
 		}
@@ -228,11 +268,16 @@  discard block
 block discarded – undo
228 268
 		$sth_dest = $Connection->db->prepare($query_dest);
229 269
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 270
 		try {
231
-			if ($globalTransaction) $Connection->db->beginTransaction();
271
+			if ($globalTransaction) {
272
+				$Connection->db->beginTransaction();
273
+			}
232 274
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 275
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234
-				if ($values['UserString4'] == 'M') $type = 'military';
235
-				else $type = null;
276
+				if ($values['UserString4'] == 'M') {
277
+					$type = 'military';
278
+				} else {
279
+					$type = null;
280
+				}
236 281
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 282
 				$sth_dest->execute($query_dest_values);
238 283
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -240,7 +285,9 @@  discard block
 block discarded – undo
240 285
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 286
 				}
242 287
             		}
243
-			if ($globalTransaction) $Connection->db->commit();
288
+			if ($globalTransaction) {
289
+				$Connection->db->commit();
290
+			}
244 291
 		} catch(PDOException $e) {
245 292
 			return "error : ".$e->getMessage();
246 293
 		}
@@ -277,7 +324,9 @@  discard block
 block discarded – undo
277 324
 			$Connection = new Connection();
278 325
 			$sth_dest = $Connection->db->prepare($query_dest);
279 326
 			try {
280
-				if ($globalTransaction) $Connection->db->beginTransaction();
327
+				if ($globalTransaction) {
328
+					$Connection->db->beginTransaction();
329
+				}
281 330
             			while (!feof($fh)) {
282 331
             				$values = array();
283 332
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -288,7 +337,9 @@  discard block
 block discarded – undo
288 337
             				// Check if we can find ICAO, else set it to GLID
289 338
             				$aircraft_name_split = explode(' ',$aircraft_name);
290 339
             				$search_more = '';
291
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
340
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
341
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
342
+            				}
292 343
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293 344
             				$sth_search = $Connection->db->prepare($query_search);
294 345
 					try {
@@ -301,7 +352,9 @@  discard block
 block discarded – undo
301 352
 					} catch(PDOException $e) {
302 353
 						return "error : ".$e->getMessage();
303 354
 					}
304
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
355
+					if (!isset($values['ICAOTypeCode'])) {
356
+						$values['ICAOTypeCode'] = 'GLID';
357
+					}
305 358
 					// Add data to db
306 359
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
307 360
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -310,7 +363,9 @@  discard block
 block discarded – undo
310 363
 						$sth_dest->execute($query_dest_values);
311 364
 					}
312 365
 				}
313
-				if ($globalTransaction) $Connection->db->commit();
366
+				if ($globalTransaction) {
367
+					$Connection->db->commit();
368
+				}
314 369
 			} catch(PDOException $e) {
315 370
 				return "error : ".$e->getMessage();
316 371
 			}
@@ -346,7 +401,9 @@  discard block
 block discarded – undo
346 401
 			$Connection = new Connection();
347 402
 			$sth_dest = $Connection->db->prepare($query_dest);
348 403
 			try {
349
-				if ($globalTransaction) $Connection->db->beginTransaction();
404
+				if ($globalTransaction) {
405
+					$Connection->db->beginTransaction();
406
+				}
350 407
 				$tmp = fgetcsv($fh,9999,',',"'");
351 408
             			while (!feof($fh)) {
352 409
             				$line = fgetcsv($fh,9999,',',"'");
@@ -359,13 +416,17 @@  discard block
 block discarded – undo
359 416
             				// Check if we can find ICAO, else set it to GLID
360 417
             				$aircraft_name_split = explode(' ',$aircraft_name);
361 418
             				$search_more = '';
362
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
419
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
420
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
421
+            				}
363 422
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364 423
             				$sth_search = $Connection->db->prepare($query_search);
365 424
 					try {
366 425
                                     		$sth_search->execute();
367 426
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
427
+	            				if (isset($result['icao']) && $result['icao'] != '') {
428
+	            					$values['ICAOTypeCode'] = $result['icao'];
429
+	            				}
369 430
 					} catch(PDOException $e) {
370 431
 						return "error : ".$e->getMessage();
371 432
 					}
@@ -378,7 +439,9 @@  discard block
 block discarded – undo
378 439
 						$sth_dest->execute($query_dest_values);
379 440
 					}
380 441
 				}
381
-				if ($globalTransaction) $Connection->db->commit();
442
+				if ($globalTransaction) {
443
+					$Connection->db->commit();
444
+				}
382 445
 			} catch(PDOException $e) {
383 446
 				return "error : ".$e->getMessage();
384 447
 			}
@@ -414,7 +477,9 @@  discard block
 block discarded – undo
414 477
 			$Connection = new Connection();
415 478
 			$sth_dest = $Connection->db->prepare($query_dest);
416 479
 			try {
417
-				if ($globalTransaction) $Connection->db->beginTransaction();
480
+				if ($globalTransaction) {
481
+					$Connection->db->beginTransaction();
482
+				}
418 483
 				$tmp = fgetcsv($fh,9999,',','"');
419 484
             			while (!feof($fh)) {
420 485
             				$line = fgetcsv($fh,9999,',','"');
@@ -424,16 +489,22 @@  discard block
 block discarded – undo
424 489
             				    $values['registration'] = $line[0];
425 490
             				    $values['base'] = $line[4];
426 491
             				    $values['owner'] = $line[5];
427
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
428
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
492
+            				    if ($line[6] == '') {
493
+            				    	$values['date_first_reg'] = null;
494
+            				    } else {
495
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
496
+					    }
429 497
 					    $values['cancel'] = $line[7];
430 498
 					} elseif ($country == 'EI') {
431 499
 					    // TODO : add modeS & reg to aircraft_modes
432 500
             				    $values['registration'] = $line[0];
433 501
             				    $values['base'] = $line[3];
434 502
             				    $values['owner'] = $line[2];
435
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
436
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
503
+            				    if ($line[1] == '') {
504
+            				    	$values['date_first_reg'] = null;
505
+            				    } else {
506
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
507
+					    }
437 508
 					    $values['cancel'] = '';
438 509
 					} elseif ($country == 'HB') {
439 510
 					    // TODO : add modeS & reg to aircraft_modes
@@ -447,16 +518,22 @@  discard block
 block discarded – undo
447 518
             				    $values['registration'] = $line[3];
448 519
             				    $values['base'] = null;
449 520
             				    $values['owner'] = $line[5];
450
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
451
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
521
+            				    if ($line[18] == '') {
522
+            				    	$values['date_first_reg'] = null;
523
+            				    } else {
524
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
525
+					    }
452 526
 					    $values['cancel'] = '';
453 527
 					} elseif ($country == 'VH') {
454 528
 					    // TODO : add modeS & reg to aircraft_modes
455 529
             				    $values['registration'] = $line[0];
456 530
             				    $values['base'] = null;
457 531
             				    $values['owner'] = $line[12];
458
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
532
+            				    if ($line[28] == '') {
533
+            				    	$values['date_first_reg'] = null;
534
+            				    } else {
535
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
536
+					    }
460 537
 
461 538
 					    $values['cancel'] = $line[39];
462 539
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -475,29 +552,41 @@  discard block
 block discarded – undo
475 552
             				    $values['registration'] = $line[0];
476 553
             				    $values['base'] = null;
477 554
             				    $values['owner'] = $line[8];
478
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
479
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
555
+            				    if ($line[7] == '') {
556
+            				    	$values['date_first_reg'] = null;
557
+            				    } else {
558
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
559
+					    }
480 560
 					    $values['cancel'] = '';
481 561
 					} elseif ($country == 'PP') {
482 562
             				    $values['registration'] = $line[0];
483 563
             				    $values['base'] = null;
484 564
             				    $values['owner'] = $line[4];
485
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
486
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
565
+            				    if ($line[6] == '') {
566
+            				    	$values['date_first_reg'] = null;
567
+            				    } else {
568
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
569
+					    }
487 570
 					    $values['cancel'] = $line[7];
488 571
 					} elseif ($country == 'E7') {
489 572
             				    $values['registration'] = $line[0];
490 573
             				    $values['base'] = null;
491 574
             				    $values['owner'] = $line[4];
492
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
493
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
575
+            				    if ($line[5] == '') {
576
+            				    	$values['date_first_reg'] = null;
577
+            				    } else {
578
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
579
+					    }
494 580
 					    $values['cancel'] = '';
495 581
 					} elseif ($country == '8Q') {
496 582
             				    $values['registration'] = $line[0];
497 583
             				    $values['base'] = null;
498 584
             				    $values['owner'] = $line[3];
499
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
500
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
585
+            				    if ($line[7] == '') {
586
+            				    	$values['date_first_reg'] = null;
587
+            				    } else {
588
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
589
+					    }
501 590
 					    $values['cancel'] = '';
502 591
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
503 592
             				    $values['registration'] = $line[0];
@@ -511,7 +600,9 @@  discard block
 block discarded – undo
511 600
 						$sth_dest->execute($query_dest_values);
512 601
 					}
513 602
 				}
514
-				if ($globalTransaction) $Connection->db->commit();
603
+				if ($globalTransaction) {
604
+					$Connection->db->commit();
605
+				}
515 606
 			} catch(PDOException $e) {
516 607
 				return "error : ".$e->getMessage();
517 608
 			}
@@ -645,25 +736,45 @@  discard block
 block discarded – undo
645 736
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
646 737
 		$Connection = new Connection();
647 738
 		$sth_dest = $Connection->db->prepare($query_dest);
648
-		if ($globalTransaction) $Connection->db->beginTransaction();
739
+		if ($globalTransaction) {
740
+			$Connection->db->beginTransaction();
741
+		}
649 742
   
650 743
 		$i = 0;
651 744
 		while($row = sparql_fetch_array($result))
652 745
 		{
653 746
 			if ($i >= 1) {
654 747
 			//print_r($row);
655
-			if (!isset($row['iata'])) $row['iata'] = '';
656
-			if (!isset($row['icao'])) $row['icao'] = '';
657
-			if (!isset($row['type'])) $row['type'] = '';
658
-			if (!isset($row['altitude'])) $row['altitude'] = '';
748
+			if (!isset($row['iata'])) {
749
+				$row['iata'] = '';
750
+			}
751
+			if (!isset($row['icao'])) {
752
+				$row['icao'] = '';
753
+			}
754
+			if (!isset($row['type'])) {
755
+				$row['type'] = '';
756
+			}
757
+			if (!isset($row['altitude'])) {
758
+				$row['altitude'] = '';
759
+			}
659 760
 			if (isset($row['city_bis'])) {
660 761
 				$row['city'] = $row['city_bis'];
661 762
 			}
662
-			if (!isset($row['city'])) $row['city'] = '';
663
-			if (!isset($row['country'])) $row['country'] = '';
664
-			if (!isset($row['homepage'])) $row['homepage'] = '';
665
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
666
-			if (!isset($row['name'])) continue;
763
+			if (!isset($row['city'])) {
764
+				$row['city'] = '';
765
+			}
766
+			if (!isset($row['country'])) {
767
+				$row['country'] = '';
768
+			}
769
+			if (!isset($row['homepage'])) {
770
+				$row['homepage'] = '';
771
+			}
772
+			if (!isset($row['wikipedia_page'])) {
773
+				$row['wikipedia_page'] = '';
774
+			}
775
+			if (!isset($row['name'])) {
776
+				continue;
777
+			}
667 778
 			if (!isset($row['image'])) {
668 779
 				$row['image'] = '';
669 780
 				$row['image_thumb'] = '';
@@ -699,7 +810,9 @@  discard block
 block discarded – undo
699 810
 
700 811
 			$i++;
701 812
 		}
702
-		if ($globalTransaction) $Connection->db->commit();
813
+		if ($globalTransaction) {
814
+			$Connection->db->commit();
815
+		}
703 816
 		echo "Delete duplicate rows...\n";
704 817
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
705 818
 		try {
@@ -711,7 +824,9 @@  discard block
 block discarded – undo
711 824
                 }
712 825
 
713 826
 
714
-		if ($globalDebug) echo "Insert Not available Airport...\n";
827
+		if ($globalDebug) {
828
+			echo "Insert Not available Airport...\n";
829
+		}
715 830
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
716 831
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
717 832
 		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
@@ -738,7 +853,9 @@  discard block
 block discarded – undo
738 853
 		$delimiter = ',';
739 854
 		$out_file = $tmp_dir.'airports.csv';
740 855
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
741
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
856
+		if (!file_exists($out_file) || !is_readable($out_file)) {
857
+			return FALSE;
858
+		}
742 859
 		echo "Add data from ourairports.com...\n";
743 860
 
744 861
 		$header = NULL;
@@ -748,8 +865,9 @@  discard block
 block discarded – undo
748 865
 			//$Connection->db->beginTransaction();
749 866
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
750 867
 			{
751
-				if(!$header) $header = $row;
752
-				else {
868
+				if(!$header) {
869
+					$header = $row;
870
+				} else {
753 871
 					$data = array();
754 872
 					$data = array_combine($header, $row);
755 873
 					try {
@@ -787,7 +905,9 @@  discard block
 block discarded – undo
787 905
 		echo "Download data from another free database...\n";
788 906
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
789 907
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
790
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
908
+		if (!file_exists($out_file) || !is_readable($out_file)) {
909
+			return FALSE;
910
+		}
791 911
 		update_db::unzip($out_file);
792 912
 		$header = NULL;
793 913
 		echo "Add data from another free database...\n";
@@ -798,8 +918,9 @@  discard block
 block discarded – undo
798 918
 			//$Connection->db->beginTransaction();
799 919
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
800 920
 			{
801
-				if(!$header) $header = $row;
802
-				else {
921
+				if(!$header) {
922
+					$header = $row;
923
+				} else {
803 924
 					$data = $row;
804 925
 
805 926
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -975,7 +1096,9 @@  discard block
 block discarded – undo
975 1096
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
976 1097
 		{
977 1098
 			$i = 0;
978
-			if ($globalTransaction) $Connection->db->beginTransaction();
1099
+			if ($globalTransaction) {
1100
+				$Connection->db->beginTransaction();
1101
+			}
979 1102
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
980 1103
 			{
981 1104
 				if ($i > 0) {
@@ -988,7 +1111,9 @@  discard block
 block discarded – undo
988 1111
 					}
989 1112
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
990 1113
 					if (!empty($result_search)) {
991
-						if ($globalDebug) echo '.';
1114
+						if ($globalDebug) {
1115
+							echo '.';
1116
+						}
992 1117
 							//if ($globalDBdriver == 'mysql') {
993 1118
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
994 1119
 							//} else {
@@ -1010,8 +1135,12 @@  discard block
 block discarded – undo
1010 1135
 						}
1011 1136
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1012 1137
 						if (!empty($result_search_mfr)) {
1013
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1014
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1138
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1139
+								$data[16] = $data[23];
1140
+							}
1141
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1142
+								$data[16] = $data[15];
1143
+							}
1015 1144
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1016 1145
 							try {
1017 1146
 								$sthf = $Connection->db->prepare($queryf);
@@ -1022,7 +1151,9 @@  discard block
 block discarded – undo
1022 1151
 						}
1023 1152
 					}
1024 1153
 					if (strtotime($data[29]) > time()) {
1025
-						if ($globalDebug) echo 'i';
1154
+						if ($globalDebug) {
1155
+							echo 'i';
1156
+						}
1026 1157
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1027 1158
 						try {
1028 1159
 							$sth = $Connection->db->prepare($query);
@@ -1033,13 +1164,19 @@  discard block
 block discarded – undo
1033 1164
 					}
1034 1165
 				}
1035 1166
 				if ($i % 90 == 0) {
1036
-					if ($globalTransaction) $Connection->db->commit();
1037
-					if ($globalTransaction) $Connection->db->beginTransaction();
1167
+					if ($globalTransaction) {
1168
+						$Connection->db->commit();
1169
+					}
1170
+					if ($globalTransaction) {
1171
+						$Connection->db->beginTransaction();
1172
+					}
1038 1173
 				}
1039 1174
 				$i++;
1040 1175
 			}
1041 1176
 			fclose($handle);
1042
-			if ($globalTransaction) $Connection->db->commit();
1177
+			if ($globalTransaction) {
1178
+				$Connection->db->commit();
1179
+			}
1043 1180
 		}
1044 1181
 		print_r($mfr);
1045 1182
 		return '';
@@ -1064,7 +1201,9 @@  discard block
 block discarded – undo
1064 1201
 			$i = 0;
1065 1202
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1066 1203
 			//$Connection->db->beginTransaction();
1067
-			if ($globalTransaction) $Connection->db->beginTransaction();
1204
+			if ($globalTransaction) {
1205
+				$Connection->db->beginTransaction();
1206
+			}
1068 1207
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1069 1208
 			{
1070 1209
 				if ($i > 0) {
@@ -1079,7 +1218,9 @@  discard block
 block discarded – undo
1079 1218
 				$i++;
1080 1219
 			}
1081 1220
 			fclose($handle);
1082
-			if ($globalTransaction) $Connection->db->commit();
1221
+			if ($globalTransaction) {
1222
+				$Connection->db->commit();
1223
+			}
1083 1224
 		}
1084 1225
 		return '';
1085 1226
         }
@@ -1100,7 +1241,9 @@  discard block
 block discarded – undo
1100 1241
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1101 1242
 		{
1102 1243
 			$i = 0;
1103
-			if ($globalTransaction) $Connection->db->beginTransaction();
1244
+			if ($globalTransaction) {
1245
+				$Connection->db->beginTransaction();
1246
+			}
1104 1247
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1105 1248
 			{
1106 1249
 				if ($i > 0) {
@@ -1116,7 +1259,9 @@  discard block
 block discarded – undo
1116 1259
 				$i++;
1117 1260
 			}
1118 1261
 			fclose($handle);
1119
-			if ($globalTransaction) $Connection->db->commit();
1262
+			if ($globalTransaction) {
1263
+				$Connection->db->commit();
1264
+			}
1120 1265
 		}
1121 1266
 		return '';
1122 1267
         }
@@ -1141,7 +1286,9 @@  discard block
 block discarded – undo
1141 1286
 			$i = 0;
1142 1287
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1143 1288
 			//$Connection->db->beginTransaction();
1144
-			if ($globalTransaction) $Connection->db->beginTransaction();
1289
+			if ($globalTransaction) {
1290
+				$Connection->db->beginTransaction();
1291
+			}
1145 1292
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1146 1293
 			{
1147 1294
 				if ($i > 0) {
@@ -1156,7 +1303,9 @@  discard block
 block discarded – undo
1156 1303
 				$i++;
1157 1304
 			}
1158 1305
 			fclose($handle);
1159
-			if ($globalTransaction) $Connection->db->commit();
1306
+			if ($globalTransaction) {
1307
+				$Connection->db->commit();
1308
+			}
1160 1309
 		}
1161 1310
 		return '';
1162 1311
         }
@@ -1175,7 +1324,9 @@  discard block
 block discarded – undo
1175 1324
 		$Connection = new Connection();
1176 1325
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1177 1326
 		{
1178
-			if ($globalTransaction) $Connection->db->beginTransaction();
1327
+			if ($globalTransaction) {
1328
+				$Connection->db->beginTransaction();
1329
+			}
1179 1330
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1180 1331
 			{
1181 1332
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1190,7 +1341,9 @@  discard block
 block discarded – undo
1190 1341
 				}
1191 1342
 			}
1192 1343
 			fclose($handle);
1193
-			if ($globalTransaction) $Connection->db->commit();
1344
+			if ($globalTransaction) {
1345
+				$Connection->db->commit();
1346
+			}
1194 1347
 		}
1195 1348
 		return '';
1196 1349
         }
@@ -1341,7 +1494,9 @@  discard block
 block discarded – undo
1341 1494
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1342 1495
 		{
1343 1496
 			$i = 0;
1344
-			if ($globalTransaction) $Connection->db->beginTransaction();
1497
+			if ($globalTransaction) {
1498
+				$Connection->db->beginTransaction();
1499
+			}
1345 1500
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1346 1501
 			{
1347 1502
 				$i++;
@@ -1369,7 +1524,9 @@  discard block
 block discarded – undo
1369 1524
 				}
1370 1525
 			}
1371 1526
 			fclose($handle);
1372
-			if ($globalTransaction) $Connection->db->commit();
1527
+			if ($globalTransaction) {
1528
+				$Connection->db->commit();
1529
+			}
1373 1530
 		}
1374 1531
 		return '';
1375 1532
         }
@@ -1392,7 +1549,9 @@  discard block
 block discarded – undo
1392 1549
 		$Connection = new Connection();
1393 1550
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1394 1551
 		{
1395
-			if ($globalTransaction) $Connection->db->beginTransaction();
1552
+			if ($globalTransaction) {
1553
+				$Connection->db->beginTransaction();
1554
+			}
1396 1555
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1397 1556
 			{
1398 1557
 				if(count($row) > 1) {
@@ -1406,7 +1565,9 @@  discard block
 block discarded – undo
1406 1565
 				}
1407 1566
 			}
1408 1567
 			fclose($handle);
1409
-			if ($globalTransaction) $Connection->db->commit();
1568
+			if ($globalTransaction) {
1569
+				$Connection->db->commit();
1570
+			}
1410 1571
 		}
1411 1572
 		return '';
1412 1573
         }
@@ -1426,8 +1587,9 @@  discard block
 block discarded – undo
1426 1587
 	        }
1427 1588
 
1428 1589
 
1429
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1430
-		else {
1590
+		if ($globalDBdriver == 'mysql') {
1591
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1592
+		} else {
1431 1593
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1432 1594
 			$query = "CREATE EXTENSION postgis";
1433 1595
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1446,20 +1608,30 @@  discard block
 block discarded – undo
1446 1608
 		global $tmp_dir, $globalDebug;
1447 1609
 		include_once('class.create_db.php');
1448 1610
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1449
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1611
+		if ($globalDebug) {
1612
+			echo "NOTAM from FlightAirMap website : Download...";
1613
+		}
1450 1614
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1451 1615
 		$error = '';
1452 1616
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1453
-			if ($globalDebug) echo "Gunzip...";
1617
+			if ($globalDebug) {
1618
+				echo "Gunzip...";
1619
+			}
1454 1620
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1455
-			if ($globalDebug) echo "Add to DB...";
1621
+			if ($globalDebug) {
1622
+				echo "Add to DB...";
1623
+			}
1456 1624
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1457 1625
 			$NOTAM = new NOTAM();
1458 1626
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1459
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1627
+		} else {
1628
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1629
+		}
1460 1630
 		if ($error != '') {
1461 1631
 			return $error;
1462
-		} elseif ($globalDebug) echo "Done\n";
1632
+		} elseif ($globalDebug) {
1633
+			echo "Done\n";
1634
+		}
1463 1635
 		return '';
1464 1636
 	}
1465 1637
 
@@ -1513,67 +1685,111 @@  discard block
 block discarded – undo
1513 1685
 		//if ($globalDebug) echo "IVAO : Download...";
1514 1686
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1515 1687
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1516
-			if ($globalDebug) echo "Unzip...";
1688
+			if ($globalDebug) {
1689
+				echo "Unzip...";
1690
+			}
1517 1691
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1518
-			if ($globalDebug) echo "Add to DB...";
1692
+			if ($globalDebug) {
1693
+				echo "Add to DB...";
1694
+			}
1519 1695
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1520
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1696
+			if ($globalDebug) {
1697
+				echo "Copy airlines logos to airlines images directory...";
1698
+			}
1521 1699
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1522
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1523
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1524
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1700
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1701
+					$error = "Failed to copy airlines logo.";
1702
+				}
1703
+			} else {
1704
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1705
+			}
1706
+		} else {
1707
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1708
+		}
1525 1709
 		if ($error != '') {
1526 1710
 			return $error;
1527
-		} elseif ($globalDebug) echo "Done\n";
1711
+		} elseif ($globalDebug) {
1712
+			echo "Done\n";
1713
+		}
1528 1714
 		return '';
1529 1715
 	}
1530 1716
 
1531 1717
 	public static function update_routes() {
1532 1718
 		global $tmp_dir, $globalDebug;
1533 1719
 		$error = '';
1534
-		if ($globalDebug) echo "Routes : Download...";
1720
+		if ($globalDebug) {
1721
+			echo "Routes : Download...";
1722
+		}
1535 1723
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1536 1724
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1537
-			if ($globalDebug) echo "Gunzip...";
1725
+			if ($globalDebug) {
1726
+				echo "Gunzip...";
1727
+			}
1538 1728
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1539
-			if ($globalDebug) echo "Add to DB...";
1729
+			if ($globalDebug) {
1730
+				echo "Add to DB...";
1731
+			}
1540 1732
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1541
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1733
+		} else {
1734
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1735
+		}
1542 1736
 		if ($error != '') {
1543 1737
 			return $error;
1544
-		} elseif ($globalDebug) echo "Done\n";
1738
+		} elseif ($globalDebug) {
1739
+			echo "Done\n";
1740
+		}
1545 1741
 		return '';
1546 1742
 	}
1547 1743
 	public static function update_oneworld() {
1548 1744
 		global $tmp_dir, $globalDebug;
1549 1745
 		$error = '';
1550
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1746
+		if ($globalDebug) {
1747
+			echo "Schedules Oneworld : Download...";
1748
+		}
1551 1749
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1552 1750
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1553
-			if ($globalDebug) echo "Gunzip...";
1751
+			if ($globalDebug) {
1752
+				echo "Gunzip...";
1753
+			}
1554 1754
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1555
-			if ($globalDebug) echo "Add to DB...";
1755
+			if ($globalDebug) {
1756
+				echo "Add to DB...";
1757
+			}
1556 1758
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1557
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1759
+		} else {
1760
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1761
+		}
1558 1762
 		if ($error != '') {
1559 1763
 			return $error;
1560
-		} elseif ($globalDebug) echo "Done\n";
1764
+		} elseif ($globalDebug) {
1765
+			echo "Done\n";
1766
+		}
1561 1767
 		return '';
1562 1768
 	}
1563 1769
 	public static function update_skyteam() {
1564 1770
 		global $tmp_dir, $globalDebug;
1565 1771
 		$error = '';
1566
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1772
+		if ($globalDebug) {
1773
+			echo "Schedules Skyteam : Download...";
1774
+		}
1567 1775
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1568 1776
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1569
-			if ($globalDebug) echo "Gunzip...";
1777
+			if ($globalDebug) {
1778
+				echo "Gunzip...";
1779
+			}
1570 1780
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1571
-			if ($globalDebug) echo "Add to DB...";
1781
+			if ($globalDebug) {
1782
+				echo "Add to DB...";
1783
+			}
1572 1784
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1573
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1785
+		} else {
1786
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1787
+		}
1574 1788
 		if ($error != '') {
1575 1789
 			return $error;
1576
-		} elseif ($globalDebug) echo "Done\n";
1790
+		} elseif ($globalDebug) {
1791
+			echo "Done\n";
1792
+		}
1577 1793
 		return '';
1578 1794
 	}
1579 1795
 	public static function update_ModeS() {
@@ -1590,341 +1806,587 @@  discard block
 block discarded – undo
1590 1806
 			exit;
1591 1807
 		} elseif ($globalDebug) echo "Done\n";
1592 1808
 */
1593
-		if ($globalDebug) echo "Modes : Download...";
1594
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1809
+		if ($globalDebug) {
1810
+			echo "Modes : Download...";
1811
+		}
1812
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1595 1813
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1596 1814
 
1597 1815
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1598 1816
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1599
-			if ($globalDebug) echo "Unzip...";
1600
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1817
+			if ($globalDebug) {
1818
+				echo "Unzip...";
1819
+			}
1820
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1601 1821
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1602
-			if ($globalDebug) echo "Add to DB...";
1822
+			if ($globalDebug) {
1823
+				echo "Add to DB...";
1824
+			}
1603 1825
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1604 1826
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1605
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1827
+		} else {
1828
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1829
+		}
1606 1830
 		if ($error != '') {
1607 1831
 			return $error;
1608
-		} elseif ($globalDebug) echo "Done\n";
1832
+		} elseif ($globalDebug) {
1833
+			echo "Done\n";
1834
+		}
1609 1835
 		return '';
1610 1836
 	}
1611 1837
 
1612 1838
 	public static function update_ModeS_faa() {
1613 1839
 		global $tmp_dir, $globalDebug;
1614
-		if ($globalDebug) echo "Modes FAA: Download...";
1840
+		if ($globalDebug) {
1841
+			echo "Modes FAA: Download...";
1842
+		}
1615 1843
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1616 1844
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1617
-			if ($globalDebug) echo "Unzip...";
1845
+			if ($globalDebug) {
1846
+				echo "Unzip...";
1847
+			}
1618 1848
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
1619
-			if ($globalDebug) echo "Add to DB...";
1849
+			if ($globalDebug) {
1850
+				echo "Add to DB...";
1851
+			}
1620 1852
 			$error = update_db::modes_faa();
1621
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1853
+		} else {
1854
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1855
+		}
1622 1856
 		if ($error != '') {
1623 1857
 			return $error;
1624
-		} elseif ($globalDebug) echo "Done\n";
1858
+		} elseif ($globalDebug) {
1859
+			echo "Done\n";
1860
+		}
1625 1861
 		return '';
1626 1862
 	}
1627 1863
 
1628 1864
 	public static function update_ModeS_flarm() {
1629 1865
 		global $tmp_dir, $globalDebug;
1630
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1866
+		if ($globalDebug) {
1867
+			echo "Modes Flarmnet: Download...";
1868
+		}
1631 1869
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1632 1870
 		if (file_exists($tmp_dir.'data.fln')) {
1633
-			if ($globalDebug) echo "Add to DB...";
1871
+			if ($globalDebug) {
1872
+				echo "Add to DB...";
1873
+			}
1634 1874
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1635
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1875
+		} else {
1876
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1877
+		}
1636 1878
 		if ($error != '') {
1637 1879
 			return $error;
1638
-		} elseif ($globalDebug) echo "Done\n";
1880
+		} elseif ($globalDebug) {
1881
+			echo "Done\n";
1882
+		}
1639 1883
 		return '';
1640 1884
 	}
1641 1885
 
1642 1886
 	public static function update_ModeS_ogn() {
1643 1887
 		global $tmp_dir, $globalDebug;
1644
-		if ($globalDebug) echo "Modes OGN: Download...";
1888
+		if ($globalDebug) {
1889
+			echo "Modes OGN: Download...";
1890
+		}
1645 1891
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1646 1892
 		if (file_exists($tmp_dir.'ogn.csv')) {
1647
-			if ($globalDebug) echo "Add to DB...";
1893
+			if ($globalDebug) {
1894
+				echo "Add to DB...";
1895
+			}
1648 1896
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1649
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1897
+		} else {
1898
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1899
+		}
1650 1900
 		if ($error != '') {
1651 1901
 			return $error;
1652
-		} elseif ($globalDebug) echo "Done\n";
1902
+		} elseif ($globalDebug) {
1903
+			echo "Done\n";
1904
+		}
1653 1905
 		return '';
1654 1906
 	}
1655 1907
 
1656 1908
 	public static function update_owner() {
1657 1909
 		global $tmp_dir, $globalDebug;
1658 1910
 		
1659
-		if ($globalDebug) echo "Owner France: Download...";
1911
+		if ($globalDebug) {
1912
+			echo "Owner France: Download...";
1913
+		}
1660 1914
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1661 1915
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1662
-			if ($globalDebug) echo "Add to DB...";
1916
+			if ($globalDebug) {
1917
+				echo "Add to DB...";
1918
+			}
1663 1919
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1664
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1920
+		} else {
1921
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1922
+		}
1665 1923
 		if ($error != '') {
1666 1924
 			return $error;
1667
-		} elseif ($globalDebug) echo "Done\n";
1925
+		} elseif ($globalDebug) {
1926
+			echo "Done\n";
1927
+		}
1668 1928
 		
1669
-		if ($globalDebug) echo "Owner Ireland: Download...";
1929
+		if ($globalDebug) {
1930
+			echo "Owner Ireland: Download...";
1931
+		}
1670 1932
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1671 1933
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1672
-			if ($globalDebug) echo "Add to DB...";
1934
+			if ($globalDebug) {
1935
+				echo "Add to DB...";
1936
+			}
1673 1937
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1674
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1938
+		} else {
1939
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1940
+		}
1675 1941
 		if ($error != '') {
1676 1942
 			return $error;
1677
-		} elseif ($globalDebug) echo "Done\n";
1678
-		if ($globalDebug) echo "Owner Switzerland: Download...";
1943
+		} elseif ($globalDebug) {
1944
+			echo "Done\n";
1945
+		}
1946
+		if ($globalDebug) {
1947
+			echo "Owner Switzerland: Download...";
1948
+		}
1679 1949
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1680 1950
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1681
-			if ($globalDebug) echo "Add to DB...";
1951
+			if ($globalDebug) {
1952
+				echo "Add to DB...";
1953
+			}
1682 1954
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1683
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1955
+		} else {
1956
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1957
+		}
1684 1958
 		if ($error != '') {
1685 1959
 			return $error;
1686
-		} elseif ($globalDebug) echo "Done\n";
1687
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
1960
+		} elseif ($globalDebug) {
1961
+			echo "Done\n";
1962
+		}
1963
+		if ($globalDebug) {
1964
+			echo "Owner Czech Republic: Download...";
1965
+		}
1688 1966
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1689 1967
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1690
-			if ($globalDebug) echo "Add to DB...";
1968
+			if ($globalDebug) {
1969
+				echo "Add to DB...";
1970
+			}
1691 1971
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1692
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1972
+		} else {
1973
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1974
+		}
1693 1975
 		if ($error != '') {
1694 1976
 			return $error;
1695
-		} elseif ($globalDebug) echo "Done\n";
1696
-		if ($globalDebug) echo "Owner Australia: Download...";
1977
+		} elseif ($globalDebug) {
1978
+			echo "Done\n";
1979
+		}
1980
+		if ($globalDebug) {
1981
+			echo "Owner Australia: Download...";
1982
+		}
1697 1983
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1698 1984
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1699
-			if ($globalDebug) echo "Add to DB...";
1985
+			if ($globalDebug) {
1986
+				echo "Add to DB...";
1987
+			}
1700 1988
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1701
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1989
+		} else {
1990
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1991
+		}
1702 1992
 		if ($error != '') {
1703 1993
 			return $error;
1704
-		} elseif ($globalDebug) echo "Done\n";
1705
-		if ($globalDebug) echo "Owner Austria: Download...";
1994
+		} elseif ($globalDebug) {
1995
+			echo "Done\n";
1996
+		}
1997
+		if ($globalDebug) {
1998
+			echo "Owner Austria: Download...";
1999
+		}
1706 2000
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1707 2001
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1708
-			if ($globalDebug) echo "Add to DB...";
2002
+			if ($globalDebug) {
2003
+				echo "Add to DB...";
2004
+			}
1709 2005
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1710
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2006
+		} else {
2007
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2008
+		}
1711 2009
 		if ($error != '') {
1712 2010
 			return $error;
1713
-		} elseif ($globalDebug) echo "Done\n";
1714
-		if ($globalDebug) echo "Owner Chile: Download...";
2011
+		} elseif ($globalDebug) {
2012
+			echo "Done\n";
2013
+		}
2014
+		if ($globalDebug) {
2015
+			echo "Owner Chile: Download...";
2016
+		}
1715 2017
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1716 2018
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1717
-			if ($globalDebug) echo "Add to DB...";
2019
+			if ($globalDebug) {
2020
+				echo "Add to DB...";
2021
+			}
1718 2022
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1719
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2023
+		} else {
2024
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2025
+		}
1720 2026
 		if ($error != '') {
1721 2027
 			return $error;
1722
-		} elseif ($globalDebug) echo "Done\n";
1723
-		if ($globalDebug) echo "Owner Colombia: Download...";
2028
+		} elseif ($globalDebug) {
2029
+			echo "Done\n";
2030
+		}
2031
+		if ($globalDebug) {
2032
+			echo "Owner Colombia: Download...";
2033
+		}
1724 2034
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1725 2035
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1726
-			if ($globalDebug) echo "Add to DB...";
2036
+			if ($globalDebug) {
2037
+				echo "Add to DB...";
2038
+			}
1727 2039
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1728
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2040
+		} else {
2041
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2042
+		}
1729 2043
 		if ($error != '') {
1730 2044
 			return $error;
1731
-		} elseif ($globalDebug) echo "Done\n";
1732
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2045
+		} elseif ($globalDebug) {
2046
+			echo "Done\n";
2047
+		}
2048
+		if ($globalDebug) {
2049
+			echo "Owner Bosnia Herzegobina: Download...";
2050
+		}
1733 2051
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1734 2052
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1735
-			if ($globalDebug) echo "Add to DB...";
2053
+			if ($globalDebug) {
2054
+				echo "Add to DB...";
2055
+			}
1736 2056
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1737
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2057
+		} else {
2058
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2059
+		}
1738 2060
 		if ($error != '') {
1739 2061
 			return $error;
1740
-		} elseif ($globalDebug) echo "Done\n";
1741
-		if ($globalDebug) echo "Owner Brazil: Download...";
2062
+		} elseif ($globalDebug) {
2063
+			echo "Done\n";
2064
+		}
2065
+		if ($globalDebug) {
2066
+			echo "Owner Brazil: Download...";
2067
+		}
1742 2068
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1743 2069
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1744
-			if ($globalDebug) echo "Add to DB...";
2070
+			if ($globalDebug) {
2071
+				echo "Add to DB...";
2072
+			}
1745 2073
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1746
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2074
+		} else {
2075
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2076
+		}
1747 2077
 		if ($error != '') {
1748 2078
 			return $error;
1749
-		} elseif ($globalDebug) echo "Done\n";
1750
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2079
+		} elseif ($globalDebug) {
2080
+			echo "Done\n";
2081
+		}
2082
+		if ($globalDebug) {
2083
+			echo "Owner Cayman Islands: Download...";
2084
+		}
1751 2085
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1752 2086
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1753
-			if ($globalDebug) echo "Add to DB...";
2087
+			if ($globalDebug) {
2088
+				echo "Add to DB...";
2089
+			}
1754 2090
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1755
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2091
+		} else {
2092
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2093
+		}
1756 2094
 		if ($error != '') {
1757 2095
 			return $error;
1758
-		} elseif ($globalDebug) echo "Done\n";
1759
-		if ($globalDebug) echo "Owner Croatia: Download...";
2096
+		} elseif ($globalDebug) {
2097
+			echo "Done\n";
2098
+		}
2099
+		if ($globalDebug) {
2100
+			echo "Owner Croatia: Download...";
2101
+		}
1760 2102
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1761 2103
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1762
-			if ($globalDebug) echo "Add to DB...";
2104
+			if ($globalDebug) {
2105
+				echo "Add to DB...";
2106
+			}
1763 2107
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1764
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2108
+		} else {
2109
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2110
+		}
1765 2111
 		if ($error != '') {
1766 2112
 			return $error;
1767
-		} elseif ($globalDebug) echo "Done\n";
1768
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2113
+		} elseif ($globalDebug) {
2114
+			echo "Done\n";
2115
+		}
2116
+		if ($globalDebug) {
2117
+			echo "Owner Luxembourg: Download...";
2118
+		}
1769 2119
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1770 2120
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1771
-			if ($globalDebug) echo "Add to DB...";
2121
+			if ($globalDebug) {
2122
+				echo "Add to DB...";
2123
+			}
1772 2124
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1773
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2125
+		} else {
2126
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2127
+		}
1774 2128
 		if ($error != '') {
1775 2129
 			return $error;
1776
-		} elseif ($globalDebug) echo "Done\n";
1777
-		if ($globalDebug) echo "Owner Maldives: Download...";
2130
+		} elseif ($globalDebug) {
2131
+			echo "Done\n";
2132
+		}
2133
+		if ($globalDebug) {
2134
+			echo "Owner Maldives: Download...";
2135
+		}
1778 2136
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1779 2137
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1780
-			if ($globalDebug) echo "Add to DB...";
2138
+			if ($globalDebug) {
2139
+				echo "Add to DB...";
2140
+			}
1781 2141
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1782
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2142
+		} else {
2143
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2144
+		}
1783 2145
 		if ($error != '') {
1784 2146
 			return $error;
1785
-		} elseif ($globalDebug) echo "Done\n";
1786
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2147
+		} elseif ($globalDebug) {
2148
+			echo "Done\n";
2149
+		}
2150
+		if ($globalDebug) {
2151
+			echo "Owner New Zealand: Download...";
2152
+		}
1787 2153
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1788 2154
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1789
-			if ($globalDebug) echo "Add to DB...";
2155
+			if ($globalDebug) {
2156
+				echo "Add to DB...";
2157
+			}
1790 2158
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1791
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2159
+		} else {
2160
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2161
+		}
1792 2162
 		if ($error != '') {
1793 2163
 			return $error;
1794
-		} elseif ($globalDebug) echo "Done\n";
1795
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2164
+		} elseif ($globalDebug) {
2165
+			echo "Done\n";
2166
+		}
2167
+		if ($globalDebug) {
2168
+			echo "Owner Papua New Guinea: Download...";
2169
+		}
1796 2170
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1797 2171
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1798
-			if ($globalDebug) echo "Add to DB...";
2172
+			if ($globalDebug) {
2173
+				echo "Add to DB...";
2174
+			}
1799 2175
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1800
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2176
+		} else {
2177
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2178
+		}
1801 2179
 		if ($error != '') {
1802 2180
 			return $error;
1803
-		} elseif ($globalDebug) echo "Done\n";
1804
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2181
+		} elseif ($globalDebug) {
2182
+			echo "Done\n";
2183
+		}
2184
+		if ($globalDebug) {
2185
+			echo "Owner Slovakia: Download...";
2186
+		}
1805 2187
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1806 2188
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1807
-			if ($globalDebug) echo "Add to DB...";
2189
+			if ($globalDebug) {
2190
+				echo "Add to DB...";
2191
+			}
1808 2192
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1809
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2193
+		} else {
2194
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2195
+		}
1810 2196
 		if ($error != '') {
1811 2197
 			return $error;
1812
-		} elseif ($globalDebug) echo "Done\n";
1813
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2198
+		} elseif ($globalDebug) {
2199
+			echo "Done\n";
2200
+		}
2201
+		if ($globalDebug) {
2202
+			echo "Owner Ecuador: Download...";
2203
+		}
1814 2204
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1815 2205
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1816
-			if ($globalDebug) echo "Add to DB...";
2206
+			if ($globalDebug) {
2207
+				echo "Add to DB...";
2208
+			}
1817 2209
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1818
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2210
+		} else {
2211
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2212
+		}
1819 2213
 		if ($error != '') {
1820 2214
 			return $error;
1821
-		} elseif ($globalDebug) echo "Done\n";
1822
-		if ($globalDebug) echo "Owner Iceland: Download...";
2215
+		} elseif ($globalDebug) {
2216
+			echo "Done\n";
2217
+		}
2218
+		if ($globalDebug) {
2219
+			echo "Owner Iceland: Download...";
2220
+		}
1823 2221
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1824 2222
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1825
-			if ($globalDebug) echo "Add to DB...";
2223
+			if ($globalDebug) {
2224
+				echo "Add to DB...";
2225
+			}
1826 2226
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1827
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2227
+		} else {
2228
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2229
+		}
1828 2230
 		if ($error != '') {
1829 2231
 			return $error;
1830
-		} elseif ($globalDebug) echo "Done\n";
2232
+		} elseif ($globalDebug) {
2233
+			echo "Done\n";
2234
+		}
1831 2235
 		return '';
1832 2236
 	}
1833 2237
 
1834 2238
 	public static function update_translation() {
1835 2239
 		global $tmp_dir, $globalDebug;
1836 2240
 		$error = '';
1837
-		if ($globalDebug) echo "Translation : Download...";
2241
+		if ($globalDebug) {
2242
+			echo "Translation : Download...";
2243
+		}
1838 2244
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1839 2245
 		if (file_exists($tmp_dir.'translation.zip')) {
1840
-			if ($globalDebug) echo "Unzip...";
2246
+			if ($globalDebug) {
2247
+				echo "Unzip...";
2248
+			}
1841 2249
 			update_db::unzip($tmp_dir.'translation.zip');
1842
-			if ($globalDebug) echo "Add to DB...";
2250
+			if ($globalDebug) {
2251
+				echo "Add to DB...";
2252
+			}
1843 2253
 			$error = update_db::translation();
1844
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2254
+		} else {
2255
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2256
+		}
1845 2257
 		if ($error != '') {
1846 2258
 			return $error;
1847
-		} elseif ($globalDebug) echo "Done\n";
2259
+		} elseif ($globalDebug) {
2260
+			echo "Done\n";
2261
+		}
1848 2262
 		return '';
1849 2263
 	}
1850 2264
 
1851 2265
 	public static function update_translation_fam() {
1852 2266
 		global $tmp_dir, $globalDebug;
1853
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2267
+		if ($globalDebug) {
2268
+			echo "Translation from FlightAirMap website : Download...";
2269
+		}
1854 2270
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1855 2271
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1856
-			if ($globalDebug) echo "Gunzip...";
2272
+			if ($globalDebug) {
2273
+				echo "Gunzip...";
2274
+			}
1857 2275
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1858
-			if ($globalDebug) echo "Add to DB...";
2276
+			if ($globalDebug) {
2277
+				echo "Add to DB...";
2278
+			}
1859 2279
 			$error = update_db::translation_fam();
1860
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2280
+		} else {
2281
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2282
+		}
1861 2283
 		if ($error != '') {
1862 2284
 			return $error;
1863
-		} elseif ($globalDebug) echo "Done\n";
2285
+		} elseif ($globalDebug) {
2286
+			echo "Done\n";
2287
+		}
1864 2288
 		return '';
1865 2289
 	}
1866 2290
 	public static function update_ModeS_fam() {
1867 2291
 		global $tmp_dir, $globalDebug;
1868
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2292
+		if ($globalDebug) {
2293
+			echo "ModeS from FlightAirMap website : Download...";
2294
+		}
1869 2295
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1870 2296
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1871
-			if ($globalDebug) echo "Gunzip...";
2297
+			if ($globalDebug) {
2298
+				echo "Gunzip...";
2299
+			}
1872 2300
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
1873
-			if ($globalDebug) echo "Add to DB...";
2301
+			if ($globalDebug) {
2302
+				echo "Add to DB...";
2303
+			}
1874 2304
 			$error = update_db::modes_fam();
1875
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2305
+		} else {
2306
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2307
+		}
1876 2308
 		if ($error != '') {
1877 2309
 			return $error;
1878
-		} elseif ($globalDebug) echo "Done\n";
2310
+		} elseif ($globalDebug) {
2311
+			echo "Done\n";
2312
+		}
1879 2313
 		return '';
1880 2314
 	}
1881 2315
 	public static function update_owner_fam() {
1882 2316
 		global $tmp_dir, $globalDebug, $globalOwner;
1883
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2317
+		if ($globalDebug) {
2318
+			echo "owner from FlightAirMap website : Download...";
2319
+		}
1884 2320
 		if ($globalOwner === TRUE) {
1885 2321
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1886 2322
 		} else {
1887 2323
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1888 2324
 		}
1889 2325
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1890
-			if ($globalDebug) echo "Gunzip...";
2326
+			if ($globalDebug) {
2327
+				echo "Gunzip...";
2328
+			}
1891 2329
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
1892
-			if ($globalDebug) echo "Add to DB...";
2330
+			if ($globalDebug) {
2331
+				echo "Add to DB...";
2332
+			}
1893 2333
 			$error = update_db::owner_fam();
1894
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2334
+		} else {
2335
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2336
+		}
1895 2337
 		if ($error != '') {
1896 2338
 			return $error;
1897
-		} elseif ($globalDebug) echo "Done\n";
2339
+		} elseif ($globalDebug) {
2340
+			echo "Done\n";
2341
+		}
1898 2342
 		return '';
1899 2343
 	}
1900 2344
 	public static function update_routes_fam() {
1901 2345
 		global $tmp_dir, $globalDebug;
1902
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2346
+		if ($globalDebug) {
2347
+			echo "Routes from FlightAirMap website : Download...";
2348
+		}
1903 2349
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1904 2350
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1905
-			if ($globalDebug) echo "Gunzip...";
2351
+			if ($globalDebug) {
2352
+				echo "Gunzip...";
2353
+			}
1906 2354
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
1907
-			if ($globalDebug) echo "Add to DB...";
2355
+			if ($globalDebug) {
2356
+				echo "Add to DB...";
2357
+			}
1908 2358
 			$error = update_db::routes_fam();
1909
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2359
+		} else {
2360
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2361
+		}
1910 2362
 		if ($error != '') {
1911 2363
 			return $error;
1912
-		} elseif ($globalDebug) echo "Done\n";
2364
+		} elseif ($globalDebug) {
2365
+			echo "Done\n";
2366
+		}
1913 2367
 		return '';
1914 2368
 	}
1915 2369
 	public static function update_banned_fam() {
1916 2370
 		global $tmp_dir, $globalDebug;
1917
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2371
+		if ($globalDebug) {
2372
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2373
+		}
1918 2374
 		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv');
1919 2375
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
1920 2376
 			//if ($globalDebug) echo "Gunzip...";
1921 2377
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
1922
-			if ($globalDebug) echo "Add to DB...";
2378
+			if ($globalDebug) {
2379
+				echo "Add to DB...";
2380
+			}
1923 2381
 			$error = update_db::banned_fam();
1924
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2382
+		} else {
2383
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2384
+		}
1925 2385
 		if ($error != '') {
1926 2386
 			return $error;
1927
-		} elseif ($globalDebug) echo "Done\n";
2387
+		} elseif ($globalDebug) {
2388
+			echo "Done\n";
2389
+		}
1928 2390
 		return '';
1929 2391
 	}
1930 2392
 
@@ -1932,7 +2394,9 @@  discard block
 block discarded – undo
1932 2394
 		global $tmp_dir, $globalDebug, $globalDBdriver;
1933 2395
 		include_once('class.create_db.php');
1934 2396
 		$error = '';
1935
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2397
+		if ($globalDebug) {
2398
+			echo "Airspace from FlightAirMap website : Download...";
2399
+		}
1936 2400
 		if ($globalDBdriver == 'mysql') {
1937 2401
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1938 2402
 		} else {
@@ -1948,9 +2412,13 @@  discard block
 block discarded – undo
1948 2412
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1949 2413
 				}
1950 2414
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1951
-					if ($globalDebug) echo "Gunzip...";
2415
+					if ($globalDebug) {
2416
+						echo "Gunzip...";
2417
+					}
1952 2418
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
1953
-					if ($globalDebug) echo "Add to DB...";
2419
+					if ($globalDebug) {
2420
+						echo "Add to DB...";
2421
+					}
1954 2422
 					$Connection = new Connection();
1955 2423
 					if ($Connection->tableExists('airspace')) {
1956 2424
 						$query = 'DROP TABLE airspace';
@@ -1963,31 +2431,47 @@  discard block
 block discarded – undo
1963 2431
 		    			}
1964 2432
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
1965 2433
 					update_db::insert_airspace_version($airspace_md5);
1966
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2434
+				} else {
2435
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2436
+				}
1967 2437
 			}
1968
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2438
+		} else {
2439
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2440
+		}
1969 2441
 		if ($error != '') {
1970 2442
 			return $error;
1971
-		} elseif ($globalDebug) echo "Done\n";
2443
+		} elseif ($globalDebug) {
2444
+			echo "Done\n";
2445
+		}
1972 2446
 		return '';
1973 2447
 	}
1974 2448
 
1975 2449
 	public static function update_tle() {
1976 2450
 		global $tmp_dir, $globalDebug;
1977
-		if ($globalDebug) echo "Download TLE : Download...";
2451
+		if ($globalDebug) {
2452
+			echo "Download TLE : Download...";
2453
+		}
1978 2454
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
1979 2455
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
1980 2456
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1981 2457
 		foreach ($alltle as $filename) {
1982
-			if ($globalDebug) echo "downloading ".$filename.'...';
2458
+			if ($globalDebug) {
2459
+				echo "downloading ".$filename.'...';
2460
+			}
1983 2461
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1984 2462
 			if (file_exists($tmp_dir.$filename)) {
1985
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2463
+				if ($globalDebug) {
2464
+					echo "Add to DB ".$filename."...";
2465
+				}
1986 2466
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1987
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2467
+			} else {
2468
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2469
+			}
1988 2470
 			if ($error != '') {
1989 2471
 				echo $error."\n";
1990
-			} elseif ($globalDebug) echo "Done\n";
2472
+			} elseif ($globalDebug) {
2473
+				echo "Done\n";
2474
+			}
1991 2475
 		}
1992 2476
 		return '';
1993 2477
 	}
@@ -1995,10 +2479,14 @@  discard block
 block discarded – undo
1995 2479
 	public static function update_models() {
1996 2480
 		global $tmp_dir, $globalDebug;
1997 2481
 		$error = '';
1998
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2482
+		if ($globalDebug) {
2483
+			echo "Models from FlightAirMap website : Download...";
2484
+		}
1999 2485
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2000 2486
 		if (file_exists($tmp_dir.'models.md5sum')) {
2001
-			if ($globalDebug) echo "Check files...\n";
2487
+			if ($globalDebug) {
2488
+				echo "Check files...\n";
2489
+			}
2002 2490
 			$newmodelsdb = array();
2003 2491
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2004 2492
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2017,25 +2505,35 @@  discard block
 block discarded – undo
2017 2505
 			}
2018 2506
 			$diff = array_diff($newmodelsdb,$modelsdb);
2019 2507
 			foreach ($diff as $key => $value) {
2020
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2508
+				if ($globalDebug) {
2509
+					echo 'Downloading model '.$key.' ...'."\n";
2510
+				}
2021 2511
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2022 2512
 				
2023 2513
 			}
2024 2514
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2025
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2515
+		} else {
2516
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2517
+		}
2026 2518
 		if ($error != '') {
2027 2519
 			return $error;
2028
-		} elseif ($globalDebug) echo "Done\n";
2520
+		} elseif ($globalDebug) {
2521
+			echo "Done\n";
2522
+		}
2029 2523
 		return '';
2030 2524
 	}
2031 2525
 
2032 2526
 	public static function update_space_models() {
2033 2527
 		global $tmp_dir, $globalDebug;
2034 2528
 		$error = '';
2035
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2529
+		if ($globalDebug) {
2530
+			echo "Space models from FlightAirMap website : Download...";
2531
+		}
2036 2532
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2037 2533
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2038
-			if ($globalDebug) echo "Check files...\n";
2534
+			if ($globalDebug) {
2535
+				echo "Check files...\n";
2536
+			}
2039 2537
 			$newmodelsdb = array();
2040 2538
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2041 2539
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2054,15 +2552,21 @@  discard block
 block discarded – undo
2054 2552
 			}
2055 2553
 			$diff = array_diff($newmodelsdb,$modelsdb);
2056 2554
 			foreach ($diff as $key => $value) {
2057
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2555
+				if ($globalDebug) {
2556
+					echo 'Downloading space model '.$key.' ...'."\n";
2557
+				}
2058 2558
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2059 2559
 				
2060 2560
 			}
2061 2561
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2062
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2562
+		} else {
2563
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2564
+		}
2063 2565
 		if ($error != '') {
2064 2566
 			return $error;
2065
-		} elseif ($globalDebug) echo "Done\n";
2567
+		} elseif ($globalDebug) {
2568
+			echo "Done\n";
2569
+		}
2066 2570
 		return '';
2067 2571
 	}
2068 2572
 
@@ -2105,7 +2609,9 @@  discard block
 block discarded – undo
2105 2609
                 }
2106 2610
 
2107 2611
 		$error = '';
2108
-		if ($globalDebug) echo "Notam : Download...";
2612
+		if ($globalDebug) {
2613
+			echo "Notam : Download...";
2614
+		}
2109 2615
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2110 2616
 		if (file_exists($tmp_dir.'notam.rss')) {
2111 2617
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2120,14 +2626,30 @@  discard block
 block discarded – undo
2120 2626
 				$data['fir'] = $q[0];
2121 2627
 				$data['code'] = $q[1];
2122 2628
 				$ifrvfr = $q[2];
2123
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2124
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2125
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2126
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2127
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2128
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2129
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2130
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2629
+				if ($ifrvfr == 'IV') {
2630
+					$data['rules'] = 'IFR/VFR';
2631
+				}
2632
+				if ($ifrvfr == 'I') {
2633
+					$data['rules'] = 'IFR';
2634
+				}
2635
+				if ($ifrvfr == 'V') {
2636
+					$data['rules'] = 'VFR';
2637
+				}
2638
+				if ($q[4] == 'A') {
2639
+					$data['scope'] = 'Airport warning';
2640
+				}
2641
+				if ($q[4] == 'E') {
2642
+					$data['scope'] = 'Enroute warning';
2643
+				}
2644
+				if ($q[4] == 'W') {
2645
+					$data['scope'] = 'Navigation warning';
2646
+				}
2647
+				if ($q[4] == 'AE') {
2648
+					$data['scope'] = 'Airport/Enroute warning';
2649
+				}
2650
+				if ($q[4] == 'AW') {
2651
+					$data['scope'] = 'Airport/Navigation warning';
2652
+				}
2131 2653
 				//$data['scope'] = $q[4];
2132 2654
 				$data['lower_limit'] = $q[5];
2133 2655
 				$data['upper_limit'] = $q[6];
@@ -2135,8 +2657,12 @@  discard block
 block discarded – undo
2135 2657
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2136 2658
 				$latitude = $Common->convertDec($las,'latitude');
2137 2659
 				$longitude = $Common->convertDec($lns,'longitude');
2138
-				if ($lac == 'S') $latitude = '-'.$latitude;
2139
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2660
+				if ($lac == 'S') {
2661
+					$latitude = '-'.$latitude;
2662
+				}
2663
+				if ($lnc == 'W') {
2664
+					$longitude = '-'.$longitude;
2665
+				}
2140 2666
 				$data['center_latitude'] = $latitude;
2141 2667
 				$data['center_longitude'] = $longitude;
2142 2668
 				$data['radius'] = intval($radius);
@@ -2166,10 +2692,14 @@  discard block
 block discarded – undo
2166 2692
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2167 2693
 				unset($data);
2168 2694
 			} 
2169
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2695
+		} else {
2696
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2697
+		}
2170 2698
 		if ($error != '') {
2171 2699
 			return $error;
2172
-		} elseif ($globalDebug) echo "Done\n";
2700
+		} elseif ($globalDebug) {
2701
+			echo "Done\n";
2702
+		}
2173 2703
 		return '';
2174 2704
 	}
2175 2705
 	
@@ -2194,7 +2724,9 @@  discard block
 block discarded – undo
2194 2724
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2195 2725
 		$airspace_json = json_decode($airspace_lst,true);
2196 2726
 		foreach ($airspace_json['records'] as $airspace) {
2197
-			if ($globalDebug) echo $airspace['name']."...\n";
2727
+			if ($globalDebug) {
2728
+				echo $airspace['name']."...\n";
2729
+			}
2198 2730
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2199 2731
 			if (file_exists($tmp_dir.$airspace['name'])) {
2200 2732
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2223,8 +2755,11 @@  discard block
 block discarded – undo
2223 2755
                         return "error : ".$e->getMessage();
2224 2756
                 }
2225 2757
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2226
-                if ($row['nb'] > 0) return false;
2227
-                else return true;
2758
+                if ($row['nb'] > 0) {
2759
+                	return false;
2760
+                } else {
2761
+                	return true;
2762
+                }
2228 2763
 	}
2229 2764
 
2230 2765
 	public static function insert_last_update() {
@@ -2249,8 +2784,11 @@  discard block
 block discarded – undo
2249 2784
                         return "error : ".$e->getMessage();
2250 2785
                 }
2251 2786
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2252
-                if ($row['nb'] > 0) return true;
2253
-                else return false;
2787
+                if ($row['nb'] > 0) {
2788
+                	return true;
2789
+                } else {
2790
+                	return false;
2791
+                }
2254 2792
 	}
2255 2793
 
2256 2794
 
@@ -2281,8 +2819,11 @@  discard block
 block discarded – undo
2281 2819
                         return "error : ".$e->getMessage();
2282 2820
                 }
2283 2821
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2284
-                if ($row['nb'] > 0) return false;
2285
-                else return true;
2822
+                if ($row['nb'] > 0) {
2823
+                	return false;
2824
+                } else {
2825
+                	return true;
2826
+                }
2286 2827
 	}
2287 2828
 
2288 2829
 	public static function insert_last_notam_update() {
@@ -2311,8 +2852,11 @@  discard block
 block discarded – undo
2311 2852
                         return "error : ".$e->getMessage();
2312 2853
                 }
2313 2854
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2314
-                if ($row['nb'] > 0) return false;
2315
-                else return true;
2855
+                if ($row['nb'] > 0) {
2856
+                	return false;
2857
+                } else {
2858
+                	return true;
2859
+                }
2316 2860
 	}
2317 2861
 
2318 2862
 	public static function insert_last_airspace_update() {
@@ -2342,8 +2886,11 @@  discard block
 block discarded – undo
2342 2886
                         return "error : ".$e->getMessage();
2343 2887
                 }
2344 2888
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2345
-                if ($row['nb'] > 0) return false;
2346
-                else return true;
2889
+                if ($row['nb'] > 0) {
2890
+                	return false;
2891
+                } else {
2892
+                	return true;
2893
+                }
2347 2894
 	}
2348 2895
 
2349 2896
 	public static function insert_last_owner_update() {
@@ -2372,8 +2919,11 @@  discard block
 block discarded – undo
2372 2919
                         return "error : ".$e->getMessage();
2373 2920
                 }
2374 2921
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2375
-                if ($row['nb'] > 0) return false;
2376
-                else return true;
2922
+                if ($row['nb'] > 0) {
2923
+                	return false;
2924
+                } else {
2925
+                	return true;
2926
+                }
2377 2927
 	}
2378 2928
 
2379 2929
 	public static function insert_last_schedules_update() {
@@ -2402,8 +2952,11 @@  discard block
 block discarded – undo
2402 2952
                         return "error : ".$e->getMessage();
2403 2953
                 }
2404 2954
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2405
-                if ($row['nb'] > 0) return false;
2406
-                else return true;
2955
+                if ($row['nb'] > 0) {
2956
+                	return false;
2957
+                } else {
2958
+                	return true;
2959
+                }
2407 2960
 	}
2408 2961
 
2409 2962
 	public static function insert_last_tle_update() {
Please login to merge, or discard this patch.
Spacing   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
 		fclose($fp);
25 25
 	}
26 26
 
27
-	public static function gunzip($in_file,$out_file_name = '') {
27
+	public static function gunzip($in_file, $out_file_name = '') {
28 28
 		//echo $in_file.' -> '.$out_file_name."\n";
29 29
 		$buffer_size = 4096; // read 4kb at a time
30 30
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
31 31
 		if ($in_file != '' && file_exists($in_file)) {
32 32
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
33
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
34
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
35 35
 			else {
36 36
 				echo 'gzopen not available';
37 37
 				die;
38 38
 			}
39 39
 			$out_file = fopen($out_file_name, 'wb'); 
40
-			while(!gzeof($file)) {
40
+			while (!gzeof($file)) {
41 41
 				fwrite($out_file, gzread($file, $buffer_size));
42 42
 			}  
43 43
 			fclose($out_file);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		try {
62 62
 			self::$db_sqlite = new PDO('sqlite:'.$database);
63 63
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
64
-		} catch(PDOException $e) {
64
+		} catch (PDOException $e) {
65 65
 			return "error : ".$e->getMessage();
66 66
 		}
67 67
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78 78
                         $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
79
+                } catch (PDOException $e) {
80 80
                         return "error : ".$e->getMessage();
81 81
                 }
82 82
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		try {
88 88
                         $sth = update_db::$db_sqlite->prepare($query);
89 89
                         $sth->execute();
90
-                } catch(PDOException $e) {
90
+                } catch (PDOException $e) {
91 91
                         return "error : ".$e->getMessage();
92 92
                 }
93 93
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99 99
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 100
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
102 102
 				$sth_dest->execute($query_dest_values);
103 103
             		}
104 104
 			if ($globalTransaction) $Connection->db->commit();
105
-		} catch(PDOException $e) {
105
+		} catch (PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
@@ -118,26 +118,26 @@  discard block
 block discarded – undo
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120 120
                         $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
121
+                } catch (PDOException $e) {
122 122
                         return "error : ".$e->getMessage();
123 123
                 }
124 124
 
125 125
     		if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128
-		if ($fh = fopen($database_file,"r")) {
128
+		if ($fh = fopen($database_file, "r")) {
129 129
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
130 130
 			$Connection = new Connection();
131 131
 			$sth_dest = $Connection->db->prepare($query_dest);
132 132
 			if ($globalTransaction) $Connection->db->beginTransaction();
133 133
 			while (!feof($fh)) {
134
-				$line = fgetcsv($fh,9999,',');
134
+				$line = fgetcsv($fh, 9999, ',');
135 135
 				if ($line[0] != '') {
136 136
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
137 137
 						try {
138
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
138
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
139 139
 							$sth_dest->execute($query_dest_values);
140
-						} catch(PDOException $e) {
140
+						} catch (PDOException $e) {
141 141
 							if ($globalTransaction) $Connection->db->rollBack(); 
142 142
 							return "error : ".$e->getMessage();
143 143
 						}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161 161
                         $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
162
+                } catch (PDOException $e) {
163 163
                         return "error : ".$e->getMessage();
164 164
                 }
165 165
 
@@ -167,24 +167,24 @@  discard block
 block discarded – undo
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
170
-		if ($fh = fopen($database_file,"r")) {
170
+		if ($fh = fopen($database_file, "r")) {
171 171
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
172 172
 			$Connection = new Connection();
173 173
 			$sth_dest = $Connection->db->prepare($query_dest);
174 174
 			try {
175 175
 				if ($globalTransaction) $Connection->db->beginTransaction();
176 176
 				while (!feof($fh)) {
177
-					$line = fgetcsv($fh,9999,',');
177
+					$line = fgetcsv($fh, 9999, ',');
178 178
 					if ($line[0] != '') {
179
-						$datebe = explode('  -  ',$line[2]);
179
+						$datebe = explode('  -  ', $line[2]);
180 180
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
181
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
181
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
182 182
 							$sth_dest->execute($query_dest_values);
183 183
 						}
184 184
 					}
185 185
 				}
186 186
 				if ($globalTransaction) $Connection->db->commit();
187
-			} catch(PDOException $e) {
187
+			} catch (PDOException $e) {
188 188
 				if ($globalTransaction) $Connection->db->rollBack(); 
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201 201
                         $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
202
+                } catch (PDOException $e) {
203 203
                         return "error : ".$e->getMessage();
204 204
                 }
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209 209
                         $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
210
+                } catch (PDOException $e) {
211 211
                         return "error : ".$e->getMessage();
212 212
                 }
213 213
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		try {
217 217
                         $sth = update_db::$db_sqlite->prepare($query);
218 218
                         $sth->execute();
219
-                } catch(PDOException $e) {
219
+                } catch (PDOException $e) {
220 220
                         return "error : ".$e->getMessage();
221 221
                 }
222 222
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234 234
 				if ($values['UserString4'] == 'M') $type = 'military';
235 235
 				else $type = null;
236
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
236
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
237 237
 				$sth_dest->execute($query_dest_values);
238 238
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
239
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
239
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
240 240
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242 242
             		}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244
-		} catch(PDOException $e) {
244
+		} catch (PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
246 246
 		}
247 247
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 			$Connection = new Connection();
252 252
 			$sth = $Connection->db->prepare($query);
253 253
                         $sth->execute(array(':source' => $database_file));
254
-                } catch(PDOException $e) {
254
+                } catch (PDOException $e) {
255 255
                         return "error : ".$e->getMessage();
256 256
                 }
257 257
 		return '';
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 			$Connection = new Connection();
267 267
 			$sth = $Connection->db->prepare($query);
268 268
                         $sth->execute(array(':source' => $database_file));
269
-                } catch(PDOException $e) {
269
+                } catch (PDOException $e) {
270 270
                         return "error : ".$e->getMessage();
271 271
                 }
272 272
 		
273
-		if ($fh = fopen($database_file,"r")) {
273
+		if ($fh = fopen($database_file, "r")) {
274 274
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
275 275
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)';
276 276
 		
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
 				if ($globalTransaction) $Connection->db->beginTransaction();
281 281
             			while (!feof($fh)) {
282 282
             				$values = array();
283
-            				$line = $Common->hex2str(fgets($fh,9999));
283
+            				$line = $Common->hex2str(fgets($fh, 9999));
284 284
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
285
-            				$values['ModeS'] = substr($line,0,6);
286
-            				$values['Registration'] = trim(substr($line,69,6));
287
-            				$aircraft_name = trim(substr($line,48,6));
285
+            				$values['ModeS'] = substr($line, 0, 6);
286
+            				$values['Registration'] = trim(substr($line, 69, 6));
287
+            				$aircraft_name = trim(substr($line, 48, 6));
288 288
             				// Check if we can find ICAO, else set it to GLID
289
-            				$aircraft_name_split = explode(' ',$aircraft_name);
289
+            				$aircraft_name_split = explode(' ', $aircraft_name);
290 290
             				$search_more = '';
291 291
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292 292
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -298,20 +298,20 @@  discard block
 block discarded – undo
298 298
 	            				if (isset($result['icao']) && $result['icao'] != '') {
299 299
 	            				    $values['ICAOTypeCode'] = $result['icao'];
300 300
 	            				} 
301
-					} catch(PDOException $e) {
301
+					} catch (PDOException $e) {
302 302
 						return "error : ".$e->getMessage();
303 303
 					}
304 304
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
305 305
 					// Add data to db
306 306
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
307 307
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
308
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
308
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
309 309
 						//print_r($query_dest_values);
310 310
 						$sth_dest->execute($query_dest_values);
311 311
 					}
312 312
 				}
313 313
 				if ($globalTransaction) $Connection->db->commit();
314
-			} catch(PDOException $e) {
314
+			} catch (PDOException $e) {
315 315
 				return "error : ".$e->getMessage();
316 316
 			}
317 317
 		}
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			$Connection = new Connection();
322 322
 			$sth = $Connection->db->prepare($query);
323 323
                         $sth->execute(array(':source' => $database_file));
324
-                } catch(PDOException $e) {
324
+                } catch (PDOException $e) {
325 325
                         return "error : ".$e->getMessage();
326 326
                 }
327 327
 		return '';
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 			$Connection = new Connection();
336 336
 			$sth = $Connection->db->prepare($query);
337 337
                         $sth->execute(array(':source' => $database_file));
338
-                } catch(PDOException $e) {
338
+                } catch (PDOException $e) {
339 339
                         return "error : ".$e->getMessage();
340 340
                 }
341 341
 		
342
-		if ($fh = fopen($database_file,"r")) {
342
+		if ($fh = fopen($database_file, "r")) {
343 343
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
344 344
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source)';
345 345
 		
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 			$sth_dest = $Connection->db->prepare($query_dest);
348 348
 			try {
349 349
 				if ($globalTransaction) $Connection->db->beginTransaction();
350
-				$tmp = fgetcsv($fh,9999,',',"'");
350
+				$tmp = fgetcsv($fh, 9999, ',', "'");
351 351
             			while (!feof($fh)) {
352
-            				$line = fgetcsv($fh,9999,',',"'");
352
+            				$line = fgetcsv($fh, 9999, ',', "'");
353 353
             				
354 354
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
355 355
 					//print_r($line);
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
             				$values['Registration'] = $line[3];
358 358
             				$aircraft_name = $line[2];
359 359
             				// Check if we can find ICAO, else set it to GLID
360
-            				$aircraft_name_split = explode(' ',$aircraft_name);
360
+            				$aircraft_name_split = explode(' ', $aircraft_name);
361 361
             				$search_more = '';
362 362
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363 363
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
                                     		$sth_search->execute();
367 367
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368 368
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
369
-					} catch(PDOException $e) {
369
+					} catch (PDOException $e) {
370 370
 						return "error : ".$e->getMessage();
371 371
 					}
372 372
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
373 373
 					// Add data to db
374 374
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
375 375
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
376
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
376
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
377 377
 						//print_r($query_dest_values);
378 378
 						$sth_dest->execute($query_dest_values);
379 379
 					}
380 380
 				}
381 381
 				if ($globalTransaction) $Connection->db->commit();
382
-			} catch(PDOException $e) {
382
+			} catch (PDOException $e) {
383 383
 				return "error : ".$e->getMessage();
384 384
 			}
385 385
 		}
@@ -389,13 +389,13 @@  discard block
 block discarded – undo
389 389
 			$Connection = new Connection();
390 390
 			$sth = $Connection->db->prepare($query);
391 391
                         $sth->execute(array(':source' => $database_file));
392
-                } catch(PDOException $e) {
392
+                } catch (PDOException $e) {
393 393
                         return "error : ".$e->getMessage();
394 394
                 }
395 395
 		return '';
396 396
 	}
397 397
 
398
-	public static function retrieve_owner($database_file,$country = 'F') {
398
+	public static function retrieve_owner($database_file, $country = 'F') {
399 399
 		global $globalTransaction;
400 400
 		//$query = 'TRUNCATE TABLE aircraft_modes';
401 401
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -403,11 +403,11 @@  discard block
 block discarded – undo
403 403
 			$Connection = new Connection();
404 404
 			$sth = $Connection->db->prepare($query);
405 405
                         $sth->execute(array(':source' => $database_file));
406
-                } catch(PDOException $e) {
406
+                } catch (PDOException $e) {
407 407
                         return "error : ".$e->getMessage();
408 408
                 }
409 409
 		
410
-		if ($fh = fopen($database_file,"r")) {
410
+		if ($fh = fopen($database_file, "r")) {
411 411
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
412 412
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
413 413
 		
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
 			$sth_dest = $Connection->db->prepare($query_dest);
416 416
 			try {
417 417
 				if ($globalTransaction) $Connection->db->beginTransaction();
418
-				$tmp = fgetcsv($fh,9999,',','"');
418
+				$tmp = fgetcsv($fh, 9999, ',', '"');
419 419
             			while (!feof($fh)) {
420
-            				$line = fgetcsv($fh,9999,',','"');
420
+            				$line = fgetcsv($fh, 9999, ',', '"');
421 421
             				$values = array();
422 422
             				//print_r($line);
423 423
             				if ($country == 'F') {
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
             				    $values['base'] = $line[4];
426 426
             				    $values['owner'] = $line[5];
427 427
             				    if ($line[6] == '') $values['date_first_reg'] = null;
428
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
428
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
429 429
 					    $values['cancel'] = $line[7];
430 430
 					} elseif ($country == 'EI') {
431 431
 					    // TODO : add modeS & reg to aircraft_modes
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
             				    $values['base'] = $line[3];
434 434
             				    $values['owner'] = $line[2];
435 435
             				    if ($line[1] == '') $values['date_first_reg'] = null;
436
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
436
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
437 437
 					    $values['cancel'] = '';
438 438
 					} elseif ($country == 'HB') {
439 439
 					    // TODO : add modeS & reg to aircraft_modes
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
             				    $values['base'] = null;
449 449
             				    $values['owner'] = $line[5];
450 450
             				    if ($line[18] == '') $values['date_first_reg'] = null;
451
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
451
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
452 452
 					    $values['cancel'] = '';
453 453
 					} elseif ($country == 'VH') {
454 454
 					    // TODO : add modeS & reg to aircraft_modes
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
             				    $values['base'] = null;
457 457
             				    $values['owner'] = $line[12];
458 458
             				    if ($line[28] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
459
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
460 460
 
461 461
 					    $values['cancel'] = $line[39];
462 462
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -476,28 +476,28 @@  discard block
 block discarded – undo
476 476
             				    $values['base'] = null;
477 477
             				    $values['owner'] = $line[8];
478 478
             				    if ($line[7] == '') $values['date_first_reg'] = null;
479
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
479
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
480 480
 					    $values['cancel'] = '';
481 481
 					} elseif ($country == 'PP') {
482 482
             				    $values['registration'] = $line[0];
483 483
             				    $values['base'] = null;
484 484
             				    $values['owner'] = $line[4];
485 485
             				    if ($line[6] == '') $values['date_first_reg'] = null;
486
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
486
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
487 487
 					    $values['cancel'] = $line[7];
488 488
 					} elseif ($country == 'E7') {
489 489
             				    $values['registration'] = $line[0];
490 490
             				    $values['base'] = null;
491 491
             				    $values['owner'] = $line[4];
492 492
             				    if ($line[5] == '') $values['date_first_reg'] = null;
493
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
493
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
494 494
 					    $values['cancel'] = '';
495 495
 					} elseif ($country == '8Q') {
496 496
             				    $values['registration'] = $line[0];
497 497
             				    $values['base'] = null;
498 498
             				    $values['owner'] = $line[3];
499 499
             				    if ($line[7] == '') $values['date_first_reg'] = null;
500
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
500
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
501 501
 					    $values['cancel'] = '';
502 502
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
503 503
             				    $values['registration'] = $line[0];
@@ -507,12 +507,12 @@  discard block
 block discarded – undo
507 507
 					    $values['cancel'] = '';
508 508
 					}
509 509
 					if ($values['cancel'] == '' && $values['registration'] != null) {
510
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
510
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
511 511
 						$sth_dest->execute($query_dest_values);
512 512
 					}
513 513
 				}
514 514
 				if ($globalTransaction) $Connection->db->commit();
515
-			} catch(PDOException $e) {
515
+			} catch (PDOException $e) {
516 516
 				return "error : ".$e->getMessage();
517 517
 			}
518 518
 		}
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 			$Connection = new Connection();
628 628
 			$sth = $Connection->db->prepare($query);
629 629
                         $sth->execute();
630
-                } catch(PDOException $e) {
630
+                } catch (PDOException $e) {
631 631
                         return "error : ".$e->getMessage();
632 632
                 }
633 633
 
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 			$Connection = new Connection();
638 638
 			$sth = $Connection->db->prepare($query);
639 639
                         $sth->execute();
640
-                } catch(PDOException $e) {
640
+                } catch (PDOException $e) {
641 641
                         return "error : ".$e->getMessage();
642 642
                 }
643 643
 
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 		if ($globalTransaction) $Connection->db->beginTransaction();
649 649
   
650 650
 		$i = 0;
651
-		while($row = sparql_fetch_array($result))
651
+		while ($row = sparql_fetch_array($result))
652 652
 		{
653 653
 			if ($i >= 1) {
654 654
 			//print_r($row);
@@ -668,31 +668,31 @@  discard block
 block discarded – undo
668 668
 				$row['image'] = '';
669 669
 				$row['image_thumb'] = '';
670 670
 			} else {
671
-				$image = str_replace(' ','_',$row['image']);
671
+				$image = str_replace(' ', '_', $row['image']);
672 672
 				$digest = md5($image);
673
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
674
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
675
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
676
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
673
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
674
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
675
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
676
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
677 677
 			}
678 678
 			
679
-			$country = explode('-',$row['country']);
679
+			$country = explode('-', $row['country']);
680 680
 			$row['country'] = $country[0];
681 681
 			
682 682
 			$row['type'] = trim($row['type']);
683
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
683
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
684 684
 				$row['type'] = 'Military';
685 685
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
686 686
 				$row['type'] = 'small_airport';
687 687
 			}
688 688
 			
689
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
690
-			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
689
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
690
+			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
691 691
 			//print_r($query_dest_values);
692 692
 			
693 693
 			try {
694 694
 				$sth_dest->execute($query_dest_values);
695
-			} catch(PDOException $e) {
695
+			} catch (PDOException $e) {
696 696
 				return "error : ".$e->getMessage();
697 697
 			}
698 698
 			}
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 			$Connection = new Connection();
707 707
 			$sth = $Connection->db->prepare($query);
708 708
                         $sth->execute();
709
-                } catch(PDOException $e) {
709
+                } catch (PDOException $e) {
710 710
                         return "error : ".$e->getMessage();
711 711
                 }
712 712
 
@@ -714,12 +714,12 @@  discard block
 block discarded – undo
714 714
 		if ($globalDebug) echo "Insert Not available Airport...\n";
715 715
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
716 716
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
717
-		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
717
+		$query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => '');
718 718
 		try {
719 719
 			$Connection = new Connection();
720 720
 			$sth = $Connection->db->prepare($query);
721 721
                         $sth->execute($query_values);
722
-                } catch(PDOException $e) {
722
+                } catch (PDOException $e) {
723 723
                         return "error : ".$e->getMessage();
724 724
                 }
725 725
 		$i++;
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 		echo "Download data from ourairports.com...\n";
738 738
 		$delimiter = ',';
739 739
 		$out_file = $tmp_dir.'airports.csv';
740
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
740
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
741 741
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
742 742
 		echo "Add data from ourairports.com...\n";
743 743
 
@@ -748,32 +748,32 @@  discard block
 block discarded – undo
748 748
 			//$Connection->db->beginTransaction();
749 749
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
750 750
 			{
751
-				if(!$header) $header = $row;
751
+				if (!$header) $header = $row;
752 752
 				else {
753 753
 					$data = array();
754 754
 					$data = array_combine($header, $row);
755 755
 					try {
756 756
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao');
757 757
 						$sth->execute(array(':icao' => $data['gps_code']));
758
-					} catch(PDOException $e) {
758
+					} catch (PDOException $e) {
759 759
 						return "error : ".$e->getMessage();
760 760
 					}
761 761
 					if ($sth->fetchColumn() > 0) {
762 762
 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
763 763
 						try {
764 764
 							$sth = $Connection->db->prepare($query);
765
-							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type']));
766
-						} catch(PDOException $e) {
765
+							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type']));
766
+						} catch (PDOException $e) {
767 767
 							return "error : ".$e->getMessage();
768 768
 						}
769 769
 					} else {
770 770
 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)
771 771
 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
772
-						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
772
+						$query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
773 773
 						try {
774 774
 							$sth = $Connection->db->prepare($query);
775 775
 							$sth->execute($query_values);
776
-						} catch(PDOException $e) {
776
+						} catch (PDOException $e) {
777 777
 							return "error : ".$e->getMessage();
778 778
 						}
779 779
 						$i++;
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 
787 787
 		echo "Download data from another free database...\n";
788 788
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
789
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
789
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
790 790
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
791 791
 		update_db::unzip($out_file);
792 792
 		$header = NULL;
@@ -798,15 +798,15 @@  discard block
 block discarded – undo
798 798
 			//$Connection->db->beginTransaction();
799 799
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
800 800
 			{
801
-				if(!$header) $header = $row;
801
+				if (!$header) $header = $row;
802 802
 				else {
803 803
 					$data = $row;
804 804
 
805 805
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
806 806
 					try {
807 807
 						$sth = $Connection->db->prepare($query);
808
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
809
-					} catch(PDOException $e) {
808
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
809
+					} catch (PDOException $e) {
810 810
 						return "error : ".$e->getMessage();
811 811
 					}
812 812
 				}
@@ -820,15 +820,15 @@  discard block
 block discarded – undo
820 820
 		try {
821 821
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'");
822 822
 			$sth->execute();
823
-		} catch(PDOException $e) {
823
+		} catch (PDOException $e) {
824 824
 			return "error : ".$e->getMessage();
825 825
 		}
826 826
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
827 827
 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
828 828
 			try {
829 829
 				$sth2 = $Connection->db->prepare($query2);
830
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
831
-			} catch(PDOException $e) {
830
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
831
+			} catch (PDOException $e) {
832 832
 				return "error : ".$e->getMessage();
833 833
 			}
834 834
 		}
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 			$Connection = new Connection();
853 853
 			$sth = $Connection->db->prepare($query);
854 854
                         $sth->execute(array(':source' => 'translation.csv'));
855
-                } catch(PDOException $e) {
855
+                } catch (PDOException $e) {
856 856
                         return "error : ".$e->getMessage();
857 857
                 }
858 858
 
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
870 870
 			{
871 871
 				$i++;
872
-				if($i > 12) {
872
+				if ($i > 12) {
873 873
 					$data = $row;
874 874
 					$operator = $data[2];
875 875
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
                                                 //echo substr($operator, 0, 2)."\n";;
878 878
                                                 if (count($airline_array) > 0) {
879 879
 							//print_r($airline_array);
880
-							$operator = $airline_array[0]['icao'].substr($operator,2);
880
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
881 881
                                                 }
882 882
                                         }
883 883
 					
@@ -885,14 +885,14 @@  discard block
 block discarded – undo
885 885
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
886 886
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
887 887
                                                 if (count($airline_array) > 0) {
888
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
888
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
889 889
                                             	}
890 890
                                         }
891 891
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
892 892
 					try {
893 893
 						$sth = $Connection->db->prepare($query);
894
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
895
-					} catch(PDOException $e) {
894
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
895
+					} catch (PDOException $e) {
896 896
 						return "error : ".$e->getMessage();
897 897
 					}
898 898
 				}
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 			$Connection = new Connection();
913 913
 			$sth = $Connection->db->prepare($query);
914 914
                         $sth->execute(array(':source' => 'website_fam'));
915
-                } catch(PDOException $e) {
915
+                } catch (PDOException $e) {
916 916
                         return "error : ".$e->getMessage();
917 917
                 }
918 918
 
@@ -932,8 +932,8 @@  discard block
 block discarded – undo
932 932
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
933 933
 					try {
934 934
 						$sth = $Connection->db->prepare($query);
935
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
936
-					} catch(PDOException $e) {
935
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
936
+					} catch (PDOException $e) {
937 937
 						return "error : ".$e->getMessage();
938 938
 					}
939 939
 				}
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
 			$Connection = new Connection();
957 957
 			$sth = $Connection->db->prepare($query);
958 958
                         $sth->execute(array(':source' => 'website_faa'));
959
-                } catch(PDOException $e) {
959
+                } catch (PDOException $e) {
960 960
                         return "error : ".$e->getMessage();
961 961
                 }
962 962
 
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 			$Connection = new Connection();
966 966
 			$sth = $Connection->db->prepare($query);
967 967
                         $sth->execute(array(':source' => 'website_faa'));
968
-                } catch(PDOException $e) {
968
+                } catch (PDOException $e) {
969 969
                         return "error : ".$e->getMessage();
970 970
                 }
971 971
 
@@ -982,8 +982,8 @@  discard block
 block discarded – undo
982 982
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
983 983
 					try {
984 984
 						$sths = $Connection->db->prepare($query_search);
985
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
986
-					} catch(PDOException $e) {
985
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
986
+					} catch (PDOException $e) {
987 987
 						return "error s : ".$e->getMessage();
988 988
 					}
989 989
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
 							//}
997 997
 						try {
998 998
 							$sthi = $Connection->db->prepare($queryi);
999
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1000
-						} catch(PDOException $e) {
999
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1000
+						} catch (PDOException $e) {
1001 1001
 							return "error u : ".$e->getMessage();
1002 1002
 						}
1003 1003
 					} else {
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 						try {
1006 1006
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1007 1007
 							$sthsm->execute(array(':mfr' => $data[2]));
1008
-						} catch(PDOException $e) {
1008
+						} catch (PDOException $e) {
1009 1009
 							return "error mfr : ".$e->getMessage();
1010 1010
 						}
1011 1011
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1015,8 +1015,8 @@  discard block
 block discarded – undo
1015 1015
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1016 1016
 							try {
1017 1017
 								$sthf = $Connection->db->prepare($queryf);
1018
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1019
-							} catch(PDOException $e) {
1018
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1019
+							} catch (PDOException $e) {
1020 1020
 								return "error f : ".$e->getMessage();
1021 1021
 							}
1022 1022
 						}
@@ -1026,13 +1026,13 @@  discard block
 block discarded – undo
1026 1026
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1027 1027
 						try {
1028 1028
 							$sth = $Connection->db->prepare($query);
1029
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1030
-						} catch(PDOException $e) {
1029
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1030
+						} catch (PDOException $e) {
1031 1031
 							return "error i : ".$e->getMessage();
1032 1032
 						}
1033 1033
 					}
1034 1034
 				}
1035
-				if ($i % 90 == 0) {
1035
+				if ($i%90 == 0) {
1036 1036
 					if ($globalTransaction) $Connection->db->commit();
1037 1037
 					if ($globalTransaction) $Connection->db->beginTransaction();
1038 1038
 				}
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 			$Connection = new Connection();
1052 1052
 			$sth = $Connection->db->prepare($query);
1053 1053
                         $sth->execute(array(':source' => 'website_fam'));
1054
-                } catch(PDOException $e) {
1054
+                } catch (PDOException $e) {
1055 1055
                         return "error : ".$e->getMessage();
1056 1056
                 }
1057 1057
 
@@ -1071,8 +1071,8 @@  discard block
 block discarded – undo
1071 1071
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1072 1072
 					try {
1073 1073
 						$sth = $Connection->db->prepare($query);
1074
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1075
-					} catch(PDOException $e) {
1074
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1075
+					} catch (PDOException $e) {
1076 1076
 						return "error : ".$e->getMessage();
1077 1077
 					}
1078 1078
 				}
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 			$Connection = new Connection();
1092 1092
 			$sth = $Connection->db->prepare($query);
1093 1093
                         $sth->execute(array(':source' => 'website_fam'));
1094
-                } catch(PDOException $e) {
1094
+                } catch (PDOException $e) {
1095 1095
                         return "error : ".$e->getMessage();
1096 1096
                 }
1097 1097
 
@@ -1107,8 +1107,8 @@  discard block
 block discarded – undo
1107 1107
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1108 1108
 					try {
1109 1109
 						$sth = $Connection->db->prepare($query);
1110
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1111
-					} catch(PDOException $e) {
1110
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1111
+					} catch (PDOException $e) {
1112 1112
 						print_r($data);
1113 1113
 						return "error : ".$e->getMessage();
1114 1114
 					}
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 			$Connection = new Connection();
1129 1129
 			$sth = $Connection->db->prepare($query);
1130 1130
                         $sth->execute(array(':source' => 'website_fam'));
1131
-                } catch(PDOException $e) {
1131
+                } catch (PDOException $e) {
1132 1132
                         return "error : ".$e->getMessage();
1133 1133
                 }
1134 1134
 
@@ -1148,8 +1148,8 @@  discard block
 block discarded – undo
1148 1148
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1149 1149
 					try {
1150 1150
 						$sth = $Connection->db->prepare($query);
1151
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1152
-					} catch(PDOException $e) {
1151
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1152
+					} catch (PDOException $e) {
1153 1153
 						return "error : ".$e->getMessage();
1154 1154
 					}
1155 1155
 				}
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 			$Connection = new Connection();
1169 1169
 			$sth = $Connection->db->prepare($query);
1170 1170
 			$sth->execute();
1171
-		} catch(PDOException $e) {
1171
+		} catch (PDOException $e) {
1172 1172
 			return "error : ".$e->getMessage();
1173 1173
 		}
1174 1174
 
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
 					try {
1185 1185
 						$sth = $Connection->db->prepare($query);
1186 1186
 						$sth->execute(array(':icao' => $icao));
1187
-					} catch(PDOException $e) {
1187
+					} catch (PDOException $e) {
1188 1188
 						return "error : ".$e->getMessage();
1189 1189
 					}
1190 1190
 				}
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
 		return '';
1196 1196
         }
1197 1197
 
1198
-	public static function tle($filename,$tletype) {
1198
+	public static function tle($filename, $tletype) {
1199 1199
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1200 1200
 		global $tmp_dir, $globalTransaction;
1201 1201
 		//$Spotter = new Spotter();
@@ -1205,7 +1205,7 @@  discard block
 block discarded – undo
1205 1205
 			$Connection = new Connection();
1206 1206
 			$sth = $Connection->db->prepare($query);
1207 1207
                         $sth->execute(array(':source' => $filename));
1208
-                } catch(PDOException $e) {
1208
+                } catch (PDOException $e) {
1209 1209
                         return "error : ".$e->getMessage();
1210 1210
                 }
1211 1211
 		
@@ -1230,8 +1230,8 @@  discard block
 block discarded – undo
1230 1230
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1231 1231
 					try {
1232 1232
 						$sth = $Connection->db->prepare($query);
1233
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1234
-					} catch(PDOException $e) {
1233
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1234
+					} catch (PDOException $e) {
1235 1235
 						return "error : ".$e->getMessage();
1236 1236
 					}
1237 1237
 
@@ -1251,28 +1251,28 @@  discard block
 block discarded – undo
1251 1251
         */
1252 1252
         private static function table2array($data) {
1253 1253
                 $html = str_get_html($data);
1254
-                $tabledata=array();
1255
-                foreach($html->find('tr') as $element)
1254
+                $tabledata = array();
1255
+                foreach ($html->find('tr') as $element)
1256 1256
                 {
1257 1257
                         $td = array();
1258
-                        foreach( $element->find('th') as $row)
1258
+                        foreach ($element->find('th') as $row)
1259 1259
                         {
1260 1260
                                 $td [] = trim($row->plaintext);
1261 1261
                         }
1262
-                        $td=array_filter($td);
1262
+                        $td = array_filter($td);
1263 1263
                         $tabledata[] = $td;
1264 1264
 
1265 1265
                         $td = array();
1266 1266
                         $tdi = array();
1267
-                        foreach( $element->find('td') as $row)
1267
+                        foreach ($element->find('td') as $row)
1268 1268
                         {
1269 1269
                                 $td [] = trim($row->plaintext);
1270 1270
                                 $tdi [] = trim($row->innertext);
1271 1271
                         }
1272
-                        $td=array_filter($td);
1273
-                        $tdi=array_filter($tdi);
1272
+                        $td = array_filter($td);
1273
+                        $tdi = array_filter($tdi);
1274 1274
                     //    $tabledata[]=array_merge($td,$tdi);
1275
-                        $tabledata[]=$td;
1275
+                        $tabledata[] = $td;
1276 1276
                 }
1277 1277
                 return(array_filter($tabledata));
1278 1278
         }
@@ -1345,13 +1345,13 @@  discard block
 block discarded – undo
1345 1345
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1346 1346
 			{
1347 1347
 				$i++;
1348
-				if($i > 3 && count($row) > 2) {
1348
+				if ($i > 3 && count($row) > 2) {
1349 1349
 					$data = array_values(array_filter($row));
1350 1350
 					$cntdata = count($data);
1351 1351
 					if ($cntdata > 10) {
1352 1352
 						$value = $data[9];
1353 1353
 						
1354
-						for ($i =10;$i < $cntdata;$i++) {
1354
+						for ($i = 10; $i < $cntdata; $i++) {
1355 1355
 							$value .= ' '.$data[$i];
1356 1356
 						}
1357 1357
 						$data[9] = $value;
@@ -1361,8 +1361,8 @@  discard block
 block discarded – undo
1361 1361
 						$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)';
1362 1362
 						try {
1363 1363
 							$sth = $Connection->db->prepare($query);
1364
-							$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]));
1365
-						} catch(PDOException $e) {
1364
+							$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]));
1365
+						} catch (PDOException $e) {
1366 1366
 							return "error : ".$e->getMessage();
1367 1367
 						}
1368 1368
 					}
@@ -1383,7 +1383,7 @@  discard block
 block discarded – undo
1383 1383
 			$Connection = new Connection();
1384 1384
 			$sth = $Connection->db->prepare($query);
1385 1385
                         $sth->execute();
1386
-                } catch(PDOException $e) {
1386
+                } catch (PDOException $e) {
1387 1387
                         return "error : ".$e->getMessage();
1388 1388
                 }
1389 1389
 
@@ -1395,12 +1395,12 @@  discard block
 block discarded – undo
1395 1395
 			if ($globalTransaction) $Connection->db->beginTransaction();
1396 1396
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1397 1397
 			{
1398
-				if(count($row) > 1) {
1398
+				if (count($row) > 1) {
1399 1399
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1400 1400
 					try {
1401 1401
 						$sth = $Connection->db->prepare($query);
1402
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1403
-					} catch(PDOException $e) {
1402
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1403
+					} catch (PDOException $e) {
1404 1404
 						return "error : ".$e->getMessage();
1405 1405
 					}
1406 1406
 				}
@@ -1420,21 +1420,21 @@  discard block
 block discarded – undo
1420 1420
 			try {
1421 1421
 				$sth = $Connection->db->prepare($query);
1422 1422
                     		$sth->execute();
1423
-	                } catch(PDOException $e) {
1423
+	                } catch (PDOException $e) {
1424 1424
 				return "error : ".$e->getMessage();
1425 1425
 	                }
1426 1426
 	        }
1427 1427
 
1428 1428
 
1429
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1429
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1430 1430
 		else {
1431
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1431
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1432 1432
 			$query = "CREATE EXTENSION postgis";
1433
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1433
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1434 1434
 			try {
1435 1435
 				$sth = $Connection->db->prepare($query);
1436 1436
 				$sth->execute();
1437
-			} catch(PDOException $e) {
1437
+			} catch (PDOException $e) {
1438 1438
 				return "error : ".$e->getMessage();
1439 1439
 			}
1440 1440
 		}
@@ -1447,7 +1447,7 @@  discard block
 block discarded – undo
1447 1447
 		include_once('class.create_db.php');
1448 1448
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1449 1449
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1450
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1450
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1451 1451
 		$error = '';
1452 1452
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1453 1453
 			if ($globalDebug) echo "Gunzip...";
@@ -1479,14 +1479,14 @@  discard block
 block discarded – undo
1479 1479
 			try {
1480 1480
 				$sth = $Connection->db->prepare($query);
1481 1481
             	        	$sth->execute();
1482
-	                } catch(PDOException $e) {
1482
+	                } catch (PDOException $e) {
1483 1483
     	                	echo "error : ".$e->getMessage();
1484 1484
 	                }
1485 1485
 		}
1486 1486
 		if ($globalDBdriver == 'mysql') {
1487
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1487
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1488 1488
 		} else {
1489
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1489
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1490 1490
 		}
1491 1491
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1492 1492
 		return $error;
@@ -1499,7 +1499,7 @@  discard block
 block discarded – undo
1499 1499
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1500 1500
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1501 1501
 //		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');
1502
-		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');
1502
+		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');
1503 1503
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1504 1504
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1505 1505
 		return $error;
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1520 1520
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1521 1521
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1522
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1522
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1523 1523
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1524 1524
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1525 1525
 		if ($error != '') {
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
 		global $tmp_dir, $globalDebug;
1533 1533
 		$error = '';
1534 1534
 		if ($globalDebug) echo "Routes : Download...";
1535
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1535
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1536 1536
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1537 1537
 			if ($globalDebug) echo "Gunzip...";
1538 1538
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
 		global $tmp_dir, $globalDebug;
1549 1549
 		$error = '';
1550 1550
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1551
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1551
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1552 1552
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1553 1553
 			if ($globalDebug) echo "Gunzip...";
1554 1554
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1564,7 +1564,7 @@  discard block
 block discarded – undo
1564 1564
 		global $tmp_dir, $globalDebug;
1565 1565
 		$error = '';
1566 1566
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1567
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1567
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1568 1568
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1569 1569
 			if ($globalDebug) echo "Gunzip...";
1570 1570
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1592,7 +1592,7 @@  discard block
 block discarded – undo
1592 1592
 */
1593 1593
 		if ($globalDebug) echo "Modes : Download...";
1594 1594
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1595
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1595
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1596 1596
 
1597 1597
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1598 1598
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1612,7 +1612,7 @@  discard block
 block discarded – undo
1612 1612
 	public static function update_ModeS_faa() {
1613 1613
 		global $tmp_dir, $globalDebug;
1614 1614
 		if ($globalDebug) echo "Modes FAA: Download...";
1615
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1615
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
1616 1616
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1617 1617
 			if ($globalDebug) echo "Unzip...";
1618 1618
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
 	public static function update_ModeS_flarm() {
1629 1629
 		global $tmp_dir, $globalDebug;
1630 1630
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1631
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1631
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1632 1632
 		if (file_exists($tmp_dir.'data.fln')) {
1633 1633
 			if ($globalDebug) echo "Add to DB...";
1634 1634
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1642,7 +1642,7 @@  discard block
 block discarded – undo
1642 1642
 	public static function update_ModeS_ogn() {
1643 1643
 		global $tmp_dir, $globalDebug;
1644 1644
 		if ($globalDebug) echo "Modes OGN: Download...";
1645
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1645
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1646 1646
 		if (file_exists($tmp_dir.'ogn.csv')) {
1647 1647
 			if ($globalDebug) echo "Add to DB...";
1648 1648
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1657,173 +1657,173 @@  discard block
 block discarded – undo
1657 1657
 		global $tmp_dir, $globalDebug;
1658 1658
 		
1659 1659
 		if ($globalDebug) echo "Owner France: Download...";
1660
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1660
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1661 1661
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1662 1662
 			if ($globalDebug) echo "Add to DB...";
1663
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1663
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1664 1664
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1665 1665
 		if ($error != '') {
1666 1666
 			return $error;
1667 1667
 		} elseif ($globalDebug) echo "Done\n";
1668 1668
 		
1669 1669
 		if ($globalDebug) echo "Owner Ireland: Download...";
1670
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1670
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1671 1671
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1672 1672
 			if ($globalDebug) echo "Add to DB...";
1673
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1673
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1674 1674
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1675 1675
 		if ($error != '') {
1676 1676
 			return $error;
1677 1677
 		} elseif ($globalDebug) echo "Done\n";
1678 1678
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1679
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1679
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1680 1680
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1681 1681
 			if ($globalDebug) echo "Add to DB...";
1682
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1682
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1683 1683
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1684 1684
 		if ($error != '') {
1685 1685
 			return $error;
1686 1686
 		} elseif ($globalDebug) echo "Done\n";
1687 1687
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1688
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1688
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1689 1689
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1690 1690
 			if ($globalDebug) echo "Add to DB...";
1691
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1691
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1692 1692
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1693 1693
 		if ($error != '') {
1694 1694
 			return $error;
1695 1695
 		} elseif ($globalDebug) echo "Done\n";
1696 1696
 		if ($globalDebug) echo "Owner Australia: Download...";
1697
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1697
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1698 1698
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1699 1699
 			if ($globalDebug) echo "Add to DB...";
1700
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1700
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1701 1701
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1702 1702
 		if ($error != '') {
1703 1703
 			return $error;
1704 1704
 		} elseif ($globalDebug) echo "Done\n";
1705 1705
 		if ($globalDebug) echo "Owner Austria: Download...";
1706
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1706
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1707 1707
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1708 1708
 			if ($globalDebug) echo "Add to DB...";
1709
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1709
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1710 1710
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1711 1711
 		if ($error != '') {
1712 1712
 			return $error;
1713 1713
 		} elseif ($globalDebug) echo "Done\n";
1714 1714
 		if ($globalDebug) echo "Owner Chile: Download...";
1715
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1715
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1716 1716
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1717 1717
 			if ($globalDebug) echo "Add to DB...";
1718
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1718
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1719 1719
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1720 1720
 		if ($error != '') {
1721 1721
 			return $error;
1722 1722
 		} elseif ($globalDebug) echo "Done\n";
1723 1723
 		if ($globalDebug) echo "Owner Colombia: Download...";
1724
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1724
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1725 1725
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1726 1726
 			if ($globalDebug) echo "Add to DB...";
1727
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1727
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1728 1728
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1729 1729
 		if ($error != '') {
1730 1730
 			return $error;
1731 1731
 		} elseif ($globalDebug) echo "Done\n";
1732 1732
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1733
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1733
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1734 1734
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1735 1735
 			if ($globalDebug) echo "Add to DB...";
1736
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1736
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1737 1737
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1738 1738
 		if ($error != '') {
1739 1739
 			return $error;
1740 1740
 		} elseif ($globalDebug) echo "Done\n";
1741 1741
 		if ($globalDebug) echo "Owner Brazil: Download...";
1742
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1742
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1743 1743
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1744 1744
 			if ($globalDebug) echo "Add to DB...";
1745
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1745
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1746 1746
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1747 1747
 		if ($error != '') {
1748 1748
 			return $error;
1749 1749
 		} elseif ($globalDebug) echo "Done\n";
1750 1750
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1751
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1751
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1752 1752
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1753 1753
 			if ($globalDebug) echo "Add to DB...";
1754
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1754
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1755 1755
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1756 1756
 		if ($error != '') {
1757 1757
 			return $error;
1758 1758
 		} elseif ($globalDebug) echo "Done\n";
1759 1759
 		if ($globalDebug) echo "Owner Croatia: Download...";
1760
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1760
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1761 1761
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1762 1762
 			if ($globalDebug) echo "Add to DB...";
1763
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1763
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1764 1764
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1765 1765
 		if ($error != '') {
1766 1766
 			return $error;
1767 1767
 		} elseif ($globalDebug) echo "Done\n";
1768 1768
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1769
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1769
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1770 1770
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1771 1771
 			if ($globalDebug) echo "Add to DB...";
1772
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1772
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1773 1773
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1774 1774
 		if ($error != '') {
1775 1775
 			return $error;
1776 1776
 		} elseif ($globalDebug) echo "Done\n";
1777 1777
 		if ($globalDebug) echo "Owner Maldives: Download...";
1778
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1778
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1779 1779
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1780 1780
 			if ($globalDebug) echo "Add to DB...";
1781
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1781
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1782 1782
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1783 1783
 		if ($error != '') {
1784 1784
 			return $error;
1785 1785
 		} elseif ($globalDebug) echo "Done\n";
1786 1786
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1787
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1787
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1788 1788
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1789 1789
 			if ($globalDebug) echo "Add to DB...";
1790
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1790
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1791 1791
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1792 1792
 		if ($error != '') {
1793 1793
 			return $error;
1794 1794
 		} elseif ($globalDebug) echo "Done\n";
1795 1795
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1796
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1796
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1797 1797
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1798 1798
 			if ($globalDebug) echo "Add to DB...";
1799
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1799
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1800 1800
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1801 1801
 		if ($error != '') {
1802 1802
 			return $error;
1803 1803
 		} elseif ($globalDebug) echo "Done\n";
1804 1804
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1805
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1805
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1806 1806
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1807 1807
 			if ($globalDebug) echo "Add to DB...";
1808
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1808
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1809 1809
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1810 1810
 		if ($error != '') {
1811 1811
 			return $error;
1812 1812
 		} elseif ($globalDebug) echo "Done\n";
1813 1813
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1814
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1814
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1815 1815
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1816 1816
 			if ($globalDebug) echo "Add to DB...";
1817
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1817
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1818 1818
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1819 1819
 		if ($error != '') {
1820 1820
 			return $error;
1821 1821
 		} elseif ($globalDebug) echo "Done\n";
1822 1822
 		if ($globalDebug) echo "Owner Iceland: Download...";
1823
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1823
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1824 1824
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1825 1825
 			if ($globalDebug) echo "Add to DB...";
1826
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1826
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1827 1827
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1828 1828
 		if ($error != '') {
1829 1829
 			return $error;
@@ -1835,7 +1835,7 @@  discard block
 block discarded – undo
1835 1835
 		global $tmp_dir, $globalDebug;
1836 1836
 		$error = '';
1837 1837
 		if ($globalDebug) echo "Translation : Download...";
1838
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1838
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1839 1839
 		if (file_exists($tmp_dir.'translation.zip')) {
1840 1840
 			if ($globalDebug) echo "Unzip...";
1841 1841
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
 	public static function update_translation_fam() {
1852 1852
 		global $tmp_dir, $globalDebug;
1853 1853
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1854
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1854
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1855 1855
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1856 1856
 			if ($globalDebug) echo "Gunzip...";
1857 1857
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1866,7 +1866,7 @@  discard block
 block discarded – undo
1866 1866
 	public static function update_ModeS_fam() {
1867 1867
 		global $tmp_dir, $globalDebug;
1868 1868
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
1869
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1869
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
1870 1870
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1871 1871
 			if ($globalDebug) echo "Gunzip...";
1872 1872
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -1882,9 +1882,9 @@  discard block
 block discarded – undo
1882 1882
 		global $tmp_dir, $globalDebug, $globalOwner;
1883 1883
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
1884 1884
 		if ($globalOwner === TRUE) {
1885
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1885
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
1886 1886
 		} else {
1887
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1887
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
1888 1888
 		}
1889 1889
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1890 1890
 			if ($globalDebug) echo "Gunzip...";
@@ -1900,7 +1900,7 @@  discard block
 block discarded – undo
1900 1900
 	public static function update_routes_fam() {
1901 1901
 		global $tmp_dir, $globalDebug;
1902 1902
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
1903
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1903
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
1904 1904
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1905 1905
 			if ($globalDebug) echo "Gunzip...";
1906 1906
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -1915,7 +1915,7 @@  discard block
 block discarded – undo
1915 1915
 	public static function update_banned_fam() {
1916 1916
 		global $tmp_dir, $globalDebug;
1917 1917
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
1918
-		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv');
1918
+		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv', $tmp_dir.'ban_eu.csv');
1919 1919
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
1920 1920
 			//if ($globalDebug) echo "Gunzip...";
1921 1921
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -1934,18 +1934,18 @@  discard block
 block discarded – undo
1934 1934
 		$error = '';
1935 1935
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
1936 1936
 		if ($globalDBdriver == 'mysql') {
1937
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1937
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
1938 1938
 		} else {
1939
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
1939
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
1940 1940
 		}
1941 1941
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
1942
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
1942
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
1943 1943
 			$airspace_md5 = $airspace_md5_file[0];
1944 1944
 			if (!update_db::check_airspace_version($airspace_md5)) {
1945 1945
 				if ($globalDBdriver == 'mysql') {
1946
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
1946
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
1947 1947
 				} else {
1948
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
1948
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
1949 1949
 				}
1950 1950
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
1951 1951
 					if ($globalDebug) echo "Gunzip...";
@@ -1957,7 +1957,7 @@  discard block
 block discarded – undo
1957 1957
 						try {
1958 1958
 							$sth = $Connection->db->prepare($query);
1959 1959
     	    	    					$sth->execute();
1960
-			            		} catch(PDOException $e) {
1960
+			            		} catch (PDOException $e) {
1961 1961
 							return "error : ".$e->getMessage();
1962 1962
 		            			}
1963 1963
 		    			}
@@ -1975,15 +1975,15 @@  discard block
 block discarded – undo
1975 1975
 	public static function update_tle() {
1976 1976
 		global $tmp_dir, $globalDebug;
1977 1977
 		if ($globalDebug) echo "Download TLE : Download...";
1978
-		$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',
1979
-		'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',
1980
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
1978
+		$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',
1979
+		'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',
1980
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
1981 1981
 		foreach ($alltle as $filename) {
1982 1982
 			if ($globalDebug) echo "downloading ".$filename.'...';
1983
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
1983
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
1984 1984
 			if (file_exists($tmp_dir.$filename)) {
1985 1985
 				if ($globalDebug) echo "Add to DB ".$filename."...";
1986
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
1986
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
1987 1987
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
1988 1988
 			if ($error != '') {
1989 1989
 				echo $error."\n";
@@ -1996,32 +1996,32 @@  discard block
 block discarded – undo
1996 1996
 		global $tmp_dir, $globalDebug;
1997 1997
 		$error = '';
1998 1998
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
1999
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
1999
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2000 2000
 		if (file_exists($tmp_dir.'models.md5sum')) {
2001 2001
 			if ($globalDebug) echo "Check files...\n";
2002 2002
 			$newmodelsdb = array();
2003
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2004
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2003
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2004
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2005 2005
 					$model = trim($row[2]);
2006 2006
 					$newmodelsdb[$model] = trim($row[0]);
2007 2007
 				}
2008 2008
 			}
2009 2009
 			$modelsdb = array();
2010 2010
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2011
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2012
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2011
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2012
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2013 2013
 						$model = trim($row[2]);
2014 2014
 						$modelsdb[$model] = trim($row[0]);
2015 2015
 					}
2016 2016
 				}
2017 2017
 			}
2018
-			$diff = array_diff($newmodelsdb,$modelsdb);
2018
+			$diff = array_diff($newmodelsdb, $modelsdb);
2019 2019
 			foreach ($diff as $key => $value) {
2020 2020
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2021
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2021
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2022 2022
 				
2023 2023
 			}
2024
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2024
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2025 2025
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2026 2026
 		if ($error != '') {
2027 2027
 			return $error;
@@ -2033,32 +2033,32 @@  discard block
 block discarded – undo
2033 2033
 		global $tmp_dir, $globalDebug;
2034 2034
 		$error = '';
2035 2035
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2036
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2036
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2037 2037
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2038 2038
 			if ($globalDebug) echo "Check files...\n";
2039 2039
 			$newmodelsdb = array();
2040
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2041
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2040
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2041
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2042 2042
 					$model = trim($row[2]);
2043 2043
 					$newmodelsdb[$model] = trim($row[0]);
2044 2044
 				}
2045 2045
 			}
2046 2046
 			$modelsdb = array();
2047 2047
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2048
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2049
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2048
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2049
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2050 2050
 						$model = trim($row[2]);
2051 2051
 						$modelsdb[$model] = trim($row[0]);
2052 2052
 					}
2053 2053
 				}
2054 2054
 			}
2055
-			$diff = array_diff($newmodelsdb,$modelsdb);
2055
+			$diff = array_diff($newmodelsdb, $modelsdb);
2056 2056
 			foreach ($diff as $key => $value) {
2057 2057
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2058
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2058
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2059 2059
 				
2060 2060
 			}
2061
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2061
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2062 2062
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2063 2063
 		if ($error != '') {
2064 2064
 			return $error;
@@ -2081,8 +2081,8 @@  discard block
 block discarded – undo
2081 2081
 		*/
2082 2082
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2083 2083
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2084
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2085
-		    $result = fread($fh,100000000);
2084
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2085
+		    $result = fread($fh, 100000000);
2086 2086
 		    //echo $result;
2087 2087
 		    //var_dump(str_get_html($result));
2088 2088
 		    //print_r(self::table2array($result));
@@ -2100,23 +2100,23 @@  discard block
 block discarded – undo
2100 2100
 			$Connection = new Connection();
2101 2101
 			$sth = $Connection->db->prepare($query);
2102 2102
                         $sth->execute();
2103
-                } catch(PDOException $e) {
2103
+                } catch (PDOException $e) {
2104 2104
                         return "error : ".$e->getMessage();
2105 2105
                 }
2106 2106
 
2107 2107
 		$error = '';
2108 2108
 		if ($globalDebug) echo "Notam : Download...";
2109
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2109
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2110 2110
 		if (file_exists($tmp_dir.'notam.rss')) {
2111
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2111
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2112 2112
 			foreach ($notams['channel']['item'] as $notam) {
2113
-				$title = explode(':',$notam['title']);
2113
+				$title = explode(':', $notam['title']);
2114 2114
 				$data['ref'] = trim($title[0]);
2115 2115
 				unset($title[0]);
2116
-				$data['title'] = trim(implode(':',$title));
2117
-				$description = strip_tags($notam['description'],'<pre>');
2118
-				preg_match(':^(.*?)<pre>:',$description,$match);
2119
-				$q = explode('/',$match[1]);
2116
+				$data['title'] = trim(implode(':', $title));
2117
+				$description = strip_tags($notam['description'], '<pre>');
2118
+				preg_match(':^(.*?)<pre>:', $description, $match);
2119
+				$q = explode('/', $match[1]);
2120 2120
 				$data['fir'] = $q[0];
2121 2121
 				$data['code'] = $q[1];
2122 2122
 				$ifrvfr = $q[2];
@@ -2132,30 +2132,30 @@  discard block
 block discarded – undo
2132 2132
 				$data['lower_limit'] = $q[5];
2133 2133
 				$data['upper_limit'] = $q[6];
2134 2134
 				$latlonrad = $q[7];
2135
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2136
-				$latitude = $Common->convertDec($las,'latitude');
2137
-				$longitude = $Common->convertDec($lns,'longitude');
2135
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2136
+				$latitude = $Common->convertDec($las, 'latitude');
2137
+				$longitude = $Common->convertDec($lns, 'longitude');
2138 2138
 				if ($lac == 'S') $latitude = '-'.$latitude;
2139 2139
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2140 2140
 				$data['center_latitude'] = $latitude;
2141 2141
 				$data['center_longitude'] = $longitude;
2142 2142
 				$data['radius'] = intval($radius);
2143 2143
 				
2144
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2144
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2145 2145
 				$data['text'] = $match[1];
2146
-				preg_match(':</pre>(.*?)$:',$description,$match);
2146
+				preg_match(':</pre>(.*?)$:', $description, $match);
2147 2147
 				$fromto = $match[1];
2148
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2148
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2149 2149
 				$fromall = trim($match[1]);
2150
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2150
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2151 2151
 				$from = trim($match[1]);
2152
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2153
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2152
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2153
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2154 2154
 				$toall = trim($match[1]);
2155
-				if (!preg_match(':Permanent:',$toall)) {
2156
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2155
+				if (!preg_match(':Permanent:', $toall)) {
2156
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2157 2157
 					$to = trim($match[1]);
2158
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2158
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2159 2159
 					$data['permanent'] = 0;
2160 2160
 				} else {
2161 2161
 				    $data['date_end'] = NULL;
@@ -2163,7 +2163,7 @@  discard block
 block discarded – undo
2163 2163
 				}
2164 2164
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2165 2165
 				$NOTAM = new NOTAM();
2166
-				$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']);
2166
+				$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']);
2167 2167
 				unset($data);
2168 2168
 			} 
2169 2169
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2186,16 +2186,16 @@  discard block
 block discarded – undo
2186 2186
 				$Connection = new Connection();
2187 2187
 				$sth = $Connection->db->prepare($query);
2188 2188
 				$sth->execute();
2189
-			} catch(PDOException $e) {
2189
+			} catch (PDOException $e) {
2190 2190
 				return "error : ".$e->getMessage();
2191 2191
 			}
2192 2192
 		}
2193 2193
 		$Common = new Common();
2194 2194
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2195
-		$airspace_json = json_decode($airspace_lst,true);
2195
+		$airspace_json = json_decode($airspace_lst, true);
2196 2196
 		foreach ($airspace_json['records'] as $airspace) {
2197 2197
 			if ($globalDebug) echo $airspace['name']."...\n";
2198
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2198
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2199 2199
 			if (file_exists($tmp_dir.$airspace['name'])) {
2200 2200
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2201 2201
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2217,7 +2217,7 @@  discard block
 block discarded – undo
2217 2217
 				$Connection = new Connection();
2218 2218
 				$sth = $Connection->db->prepare($query);
2219 2219
 				$sth->execute(array(':new' => $new, ':old' => $old));
2220
-			} catch(PDOException $e) {
2220
+			} catch (PDOException $e) {
2221 2221
 				return "error : ".$e->getMessage();
2222 2222
 			}
2223 2223
 		}
@@ -2234,7 +2234,7 @@  discard block
 block discarded – undo
2234 2234
 			$Connection = new Connection();
2235 2235
 			$sth = $Connection->db->prepare($query);
2236 2236
                         $sth->execute();
2237
-                } catch(PDOException $e) {
2237
+                } catch (PDOException $e) {
2238 2238
                         return "error : ".$e->getMessage();
2239 2239
                 }
2240 2240
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2249,7 +2249,7 @@  discard block
 block discarded – undo
2249 2249
 			$Connection = new Connection();
2250 2250
 			$sth = $Connection->db->prepare($query);
2251 2251
                         $sth->execute();
2252
-                } catch(PDOException $e) {
2252
+                } catch (PDOException $e) {
2253 2253
                         return "error : ".$e->getMessage();
2254 2254
                 }
2255 2255
 	}
@@ -2260,7 +2260,7 @@  discard block
 block discarded – undo
2260 2260
 			$Connection = new Connection();
2261 2261
 			$sth = $Connection->db->prepare($query);
2262 2262
                         $sth->execute(array(':version' => $version));
2263
-                } catch(PDOException $e) {
2263
+                } catch (PDOException $e) {
2264 2264
                         return "error : ".$e->getMessage();
2265 2265
                 }
2266 2266
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2276,7 +2276,7 @@  discard block
 block discarded – undo
2276 2276
 			$Connection = new Connection();
2277 2277
 			$sth = $Connection->db->prepare($query);
2278 2278
                         $sth->execute(array(':version' => $version));
2279
-                } catch(PDOException $e) {
2279
+                } catch (PDOException $e) {
2280 2280
                         return "error : ".$e->getMessage();
2281 2281
                 }
2282 2282
 	}
@@ -2292,7 +2292,7 @@  discard block
 block discarded – undo
2292 2292
 			$Connection = new Connection();
2293 2293
 			$sth = $Connection->db->prepare($query);
2294 2294
                         $sth->execute();
2295
-                } catch(PDOException $e) {
2295
+                } catch (PDOException $e) {
2296 2296
                         return "error : ".$e->getMessage();
2297 2297
                 }
2298 2298
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2307,7 +2307,7 @@  discard block
 block discarded – undo
2307 2307
 			$Connection = new Connection();
2308 2308
 			$sth = $Connection->db->prepare($query);
2309 2309
                         $sth->execute();
2310
-                } catch(PDOException $e) {
2310
+                } catch (PDOException $e) {
2311 2311
                         return "error : ".$e->getMessage();
2312 2312
                 }
2313 2313
 	}
@@ -2322,7 +2322,7 @@  discard block
 block discarded – undo
2322 2322
 			$Connection = new Connection();
2323 2323
 			$sth = $Connection->db->prepare($query);
2324 2324
                         $sth->execute();
2325
-                } catch(PDOException $e) {
2325
+                } catch (PDOException $e) {
2326 2326
                         return "error : ".$e->getMessage();
2327 2327
                 }
2328 2328
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2337,7 +2337,7 @@  discard block
 block discarded – undo
2337 2337
 			$Connection = new Connection();
2338 2338
 			$sth = $Connection->db->prepare($query);
2339 2339
                         $sth->execute();
2340
-                } catch(PDOException $e) {
2340
+                } catch (PDOException $e) {
2341 2341
                         return "error : ".$e->getMessage();
2342 2342
                 }
2343 2343
 	}
@@ -2353,7 +2353,7 @@  discard block
 block discarded – undo
2353 2353
 			$Connection = new Connection();
2354 2354
 			$sth = $Connection->db->prepare($query);
2355 2355
                         $sth->execute();
2356
-                } catch(PDOException $e) {
2356
+                } catch (PDOException $e) {
2357 2357
                         return "error : ".$e->getMessage();
2358 2358
                 }
2359 2359
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2368,7 +2368,7 @@  discard block
 block discarded – undo
2368 2368
 			$Connection = new Connection();
2369 2369
 			$sth = $Connection->db->prepare($query);
2370 2370
                         $sth->execute();
2371
-                } catch(PDOException $e) {
2371
+                } catch (PDOException $e) {
2372 2372
                         return "error : ".$e->getMessage();
2373 2373
                 }
2374 2374
 	}
@@ -2383,7 +2383,7 @@  discard block
 block discarded – undo
2383 2383
 			$Connection = new Connection();
2384 2384
 			$sth = $Connection->db->prepare($query);
2385 2385
                         $sth->execute();
2386
-                } catch(PDOException $e) {
2386
+                } catch (PDOException $e) {
2387 2387
                         return "error : ".$e->getMessage();
2388 2388
                 }
2389 2389
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2398,7 +2398,7 @@  discard block
 block discarded – undo
2398 2398
 			$Connection = new Connection();
2399 2399
 			$sth = $Connection->db->prepare($query);
2400 2400
                         $sth->execute();
2401
-                } catch(PDOException $e) {
2401
+                } catch (PDOException $e) {
2402 2402
                         return "error : ".$e->getMessage();
2403 2403
                 }
2404 2404
 	}
@@ -2413,7 +2413,7 @@  discard block
 block discarded – undo
2413 2413
 			$Connection = new Connection();
2414 2414
 			$sth = $Connection->db->prepare($query);
2415 2415
                         $sth->execute();
2416
-                } catch(PDOException $e) {
2416
+                } catch (PDOException $e) {
2417 2417
                         return "error : ".$e->getMessage();
2418 2418
                 }
2419 2419
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2428,7 +2428,7 @@  discard block
 block discarded – undo
2428 2428
 			$Connection = new Connection();
2429 2429
 			$sth = $Connection->db->prepare($query);
2430 2430
                         $sth->execute();
2431
-                } catch(PDOException $e) {
2431
+                } catch (PDOException $e) {
2432 2432
                         return "error : ".$e->getMessage();
2433 2433
                 }
2434 2434
 	}
@@ -2443,7 +2443,7 @@  discard block
 block discarded – undo
2443 2443
 			$Connection = new Connection();
2444 2444
 			$sth = $Connection->db->prepare($query);
2445 2445
                         $sth->execute();
2446
-                } catch(PDOException $e) {
2446
+                } catch (PDOException $e) {
2447 2447
                         return "error : ".$e->getMessage();
2448 2448
                 }
2449 2449
 	}
@@ -2458,7 +2458,7 @@  discard block
 block discarded – undo
2458 2458
 			$Connection = new Connection();
2459 2459
 			$sth = $Connection->db->prepare($query);
2460 2460
                         $sth->execute();
2461
-                } catch(PDOException $e) {
2461
+                } catch (PDOException $e) {
2462 2462
                         return "error : ".$e->getMessage();
2463 2463
                 }
2464 2464
 	}
Please login to merge, or discard this patch.
require/libs/Predict/Predict.php 4 patches
Doc Comments   +3 added lines, -17 removed lines patch added patch discarded remove patch
@@ -146,20 +146,6 @@  discard block
 block discarded – undo
146 146
 
147 147
     /** Predict first pass after a certain time.
148 148
      *
149
-     *  @param Predict_Sat $sat   The satellite data.
150
-     *  @param Predict_QTH $qth   The observer's location data.
151
-     *  @param float       $start Starting time.
152
-     *  @param int         $maxdt The maximum number of days to look ahead (0 for no limit).
153
-     *
154
-     *  @return Predict_Pass or NULL if there was an error.
155
-     *
156
-     * This function will find the first upcoming pass with AOS no earlier than
157
-     * t = start and no later than t = (start+maxdt).
158
-     *
159
-     *  note For no time limit use maxdt = 0.0
160
-     *
161
-     *  note the data in sat will be corrupt (future) and must be refreshed
162
-     *       by the caller, if the caller will need it later on
163 149
      */
164 150
     public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt)
165 151
     {
@@ -407,7 +393,7 @@  discard block
 block discarded – undo
407 393
      *  @param Predict_QTH $qth   The observer's location (QTH) data.
408 394
      *  @param float       $start The julian date where calculation should start.
409 395
      *  @param int         $maxdt The upper time limit in days (0.0 = no limit)
410
-     *  @return The julain date of the next AOS or 0.0 if the satellite has no AOS.
396
+     *  @return double julain date of the next AOS or 0.0 if the satellite has no AOS.
411 397
      *
412 398
      * This function finds the time of AOS for the first coming pass taking place
413 399
      * no earlier that start.
@@ -563,7 +549,7 @@  discard block
 block discarded – undo
563 549
      *  @param Predict_QTH $qth The QTH observer location data.
564 550
      *  @param float       $start The time where calculation should start. (Julian Date)
565 551
      *  @param int         $maxdt The upper time limit in days (0.0 = no limit)
566
-     *  @return The time (julian date) of the next LOS or 0.0 if the satellite has no LOS.
552
+     *  @return double time (julian date) of the next LOS or 0.0 if the satellite has no LOS.
567 553
      *
568 554
      * This function finds the time of LOS for the first coming pass taking place
569 555
      * no earlier that start.
@@ -648,7 +634,7 @@  discard block
 block discarded – undo
648 634
      *  @param Predict_Sat $sat   The satellite to find AOS for.
649 635
      *  @param Predict_QTH $qth   The ground station.
650 636
      *  @param float       $start Start time, prefereably now.
651
-     *  @return The time of the previous AOS or 0.0 if the satellite has no AOS.
637
+     *  @return double time of the previous AOS or 0.0 if the satellite has no AOS.
652 638
      *
653 639
      * This function can be used to find the AOS time in the past of the
654 640
      * current pass.
Please login to merge, or discard this patch.
Indentation   +791 added lines, -791 removed lines patch added patch discarded remove patch
@@ -52,824 +52,824 @@
 block discarded – undo
52 52
  */
53 53
 class Predict
54 54
 {
55
-    const de2ra    =  1.74532925E-2;   /* Degrees to Radians */
56
-    const pi       =  3.1415926535898; /* Pi */
57
-    const pio2     =  1.5707963267949; /* Pi/2 */
58
-    const x3pio2   =  4.71238898;      /* 3*Pi/2 */
59
-    const twopi    =  6.2831853071796; /* 2*Pi  */
60
-    const e6a      =  1.0E-6;
61
-    const tothrd   =  6.6666667E-1;    /* 2/3 */
62
-    const xj2      =  1.0826158E-3;    /* J2 Harmonic */
63
-    const xj3      = -2.53881E-6;      /* J3 Harmonic */
64
-    const xj4      = -1.65597E-6;      /* J4 Harmonic */
65
-    const xke      =  7.43669161E-2;
66
-    const xkmper   =  6.378135E3;      /* Earth radius km */
67
-    const xmnpda   =  1.44E3;          /* Minutes per day */
68
-    const km2mi    =  0.621371;        /* Kilometers per Mile */
69
-    const ae       =  1.0;
70
-    const ck2      =  5.413079E-4;
71
-    const ck4      =  6.209887E-7;
72
-    const __f      =  3.352779E-3;
73
-    const ge       =  3.986008E5;
74
-    const __s__    =  1.012229;
75
-    const qoms2t   =  1.880279E-09;
76
-    const secday   =  8.6400E4;        /* Seconds per day */
77
-    const omega_E  =  1.0027379;
78
-    const omega_ER =  6.3003879;
79
-    const zns      =  1.19459E-5;
80
-    const c1ss     =  2.9864797E-6;
81
-    const zes      =  1.675E-2;
82
-    const znl      =  1.5835218E-4;
83
-    const c1l      =  4.7968065E-7;
84
-    const zel      =  5.490E-2;
85
-    const zcosis   =  9.1744867E-1;
86
-    const zsinis   =  3.9785416E-1;
87
-    const zsings   = -9.8088458E-1;
88
-    const zcosgs   =  1.945905E-1;
89
-    const zcoshs   =  1;
90
-    const zsinhs   =  0;
91
-    const q22      =  1.7891679E-6;
92
-    const q31      =  2.1460748E-6;
93
-    const q33      =  2.2123015E-7;
94
-    const g22      =  5.7686396;
95
-    const g32      =  9.5240898E-1;
96
-    const g44      =  1.8014998;
97
-    const g52      =  1.0508330;
98
-    const g54      =  4.4108898;
99
-    const root22   =  1.7891679E-6;
100
-    const root32   =  3.7393792E-7;
101
-    const root44   =  7.3636953E-9;
102
-    const root52   =  1.1428639E-7;
103
-    const root54   =  2.1765803E-9;
104
-    const thdt     =  4.3752691E-3;
105
-    const rho      =  1.5696615E-1;
106
-    const mfactor  =  7.292115E-5;
107
-    const __sr__   =  6.96000E5;      /*Solar radius - kilometers (IAU 76)*/
108
-    const AU       =  1.49597870E8;   /*Astronomical unit - kilometers (IAU 76)*/
109
-
110
-    /* visibility constants */
111
-    const SAT_VIS_NONE     = 0;
112
-    const SAT_VIS_VISIBLE  = 1;
113
-    const SAT_VIS_DAYLIGHT = 2;
114
-    const SAT_VIS_ECLIPSED = 3;
115
-
116
-    /* preferences */
117
-    public $minEle     = 10; // Minimum elevation
118
-    public $timeRes    = 10; // Pass details: time resolution
119
-    public $numEntries = 20; // Pass details: number of entries
120
-    public $threshold  = -6; // Twilight threshold
121
-
122
-    /**
123
-     *  Predict the next pass.
124
-     *
125
-     * This function simply wraps the get_pass function using the current time
126
-     * as parameter.
127
-     *
128
-     * Note: the data in sat will be corrupt (future) and must be refreshed
129
-     *       by the caller, if the caller will need it later on (eg. if the caller
130
-     *       is GtkSatList).
131
-     *
132
-     * @param Predict_Sat $sat   The satellite data.
133
-     * @param Predict_QTH $qth   The observer data.
134
-     * @param int         $maxdt The maximum number of days to look ahead.
135
-     *
136
-     * @return Predict_Pass Pointer instance or NULL if no pass can be
137
-     *         found.
138
-     */
139
-    public function get_next_pass(Predict_Sat $sat, Predict_QTH $qth, $maxdt)
140
-    {
141
-        /* get the current time and call the get_pass function */
142
-        $now = Predict_Time::get_current_daynum();
143
-
144
-        return $this->get_pass($sat, $qth, $now, $maxdt);
145
-    }
146
-
147
-    /** Predict first pass after a certain time.
148
-     *
149
-     *  @param Predict_Sat $sat   The satellite data.
150
-     *  @param Predict_QTH $qth   The observer's location data.
151
-     *  @param float       $start Starting time.
152
-     *  @param int         $maxdt The maximum number of days to look ahead (0 for no limit).
153
-     *
154
-     *  @return Predict_Pass or NULL if there was an error.
155
-     *
156
-     * This function will find the first upcoming pass with AOS no earlier than
157
-     * t = start and no later than t = (start+maxdt).
158
-     *
159
-     *  note For no time limit use maxdt = 0.0
160
-     *
161
-     *  note the data in sat will be corrupt (future) and must be refreshed
162
-     *       by the caller, if the caller will need it later on
163
-     */
164
-    public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt)
165
-    {
166
-        $aos = 0.0;    /* time of AOS */
167
-        $tca = 0.0;    /* time of TCA */
168
-        $los = 0.0;    /* time of LOS */
169
-        $dt = 0.0;     /* time diff */
170
-        $step = 0.0;   /* time step */
171
-        $t0 = $start;
172
-        $tres = 0.0;   /* required time resolution */
173
-        $max_el = 0.0; /* maximum elevation */
174
-        $pass = null;
175
-        $detail = null;
176
-        $done = false;
177
-        $iter = 0;      /* number of iterations */
178
-        /* FIXME: watchdog */
179
-
180
-        /*copy sat_in to a working structure*/
181
-        $sat         = clone $sat_in;
182
-        $sat_working = clone $sat_in;
183
-
184
-        /* get time resolution; sat-cfg stores it in seconds */
185
-        $tres = $this->timeRes / 86400.0;
186
-
187
-        /* loop until we find a pass with elevation > SAT_CFG_INT_PRED_MIN_EL
55
+	const de2ra    =  1.74532925E-2;   /* Degrees to Radians */
56
+	const pi       =  3.1415926535898; /* Pi */
57
+	const pio2     =  1.5707963267949; /* Pi/2 */
58
+	const x3pio2   =  4.71238898;      /* 3*Pi/2 */
59
+	const twopi    =  6.2831853071796; /* 2*Pi  */
60
+	const e6a      =  1.0E-6;
61
+	const tothrd   =  6.6666667E-1;    /* 2/3 */
62
+	const xj2      =  1.0826158E-3;    /* J2 Harmonic */
63
+	const xj3      = -2.53881E-6;      /* J3 Harmonic */
64
+	const xj4      = -1.65597E-6;      /* J4 Harmonic */
65
+	const xke      =  7.43669161E-2;
66
+	const xkmper   =  6.378135E3;      /* Earth radius km */
67
+	const xmnpda   =  1.44E3;          /* Minutes per day */
68
+	const km2mi    =  0.621371;        /* Kilometers per Mile */
69
+	const ae       =  1.0;
70
+	const ck2      =  5.413079E-4;
71
+	const ck4      =  6.209887E-7;
72
+	const __f      =  3.352779E-3;
73
+	const ge       =  3.986008E5;
74
+	const __s__    =  1.012229;
75
+	const qoms2t   =  1.880279E-09;
76
+	const secday   =  8.6400E4;        /* Seconds per day */
77
+	const omega_E  =  1.0027379;
78
+	const omega_ER =  6.3003879;
79
+	const zns      =  1.19459E-5;
80
+	const c1ss     =  2.9864797E-6;
81
+	const zes      =  1.675E-2;
82
+	const znl      =  1.5835218E-4;
83
+	const c1l      =  4.7968065E-7;
84
+	const zel      =  5.490E-2;
85
+	const zcosis   =  9.1744867E-1;
86
+	const zsinis   =  3.9785416E-1;
87
+	const zsings   = -9.8088458E-1;
88
+	const zcosgs   =  1.945905E-1;
89
+	const zcoshs   =  1;
90
+	const zsinhs   =  0;
91
+	const q22      =  1.7891679E-6;
92
+	const q31      =  2.1460748E-6;
93
+	const q33      =  2.2123015E-7;
94
+	const g22      =  5.7686396;
95
+	const g32      =  9.5240898E-1;
96
+	const g44      =  1.8014998;
97
+	const g52      =  1.0508330;
98
+	const g54      =  4.4108898;
99
+	const root22   =  1.7891679E-6;
100
+	const root32   =  3.7393792E-7;
101
+	const root44   =  7.3636953E-9;
102
+	const root52   =  1.1428639E-7;
103
+	const root54   =  2.1765803E-9;
104
+	const thdt     =  4.3752691E-3;
105
+	const rho      =  1.5696615E-1;
106
+	const mfactor  =  7.292115E-5;
107
+	const __sr__   =  6.96000E5;      /*Solar radius - kilometers (IAU 76)*/
108
+	const AU       =  1.49597870E8;   /*Astronomical unit - kilometers (IAU 76)*/
109
+
110
+	/* visibility constants */
111
+	const SAT_VIS_NONE     = 0;
112
+	const SAT_VIS_VISIBLE  = 1;
113
+	const SAT_VIS_DAYLIGHT = 2;
114
+	const SAT_VIS_ECLIPSED = 3;
115
+
116
+	/* preferences */
117
+	public $minEle     = 10; // Minimum elevation
118
+	public $timeRes    = 10; // Pass details: time resolution
119
+	public $numEntries = 20; // Pass details: number of entries
120
+	public $threshold  = -6; // Twilight threshold
121
+
122
+	/**
123
+	 *  Predict the next pass.
124
+	 *
125
+	 * This function simply wraps the get_pass function using the current time
126
+	 * as parameter.
127
+	 *
128
+	 * Note: the data in sat will be corrupt (future) and must be refreshed
129
+	 *       by the caller, if the caller will need it later on (eg. if the caller
130
+	 *       is GtkSatList).
131
+	 *
132
+	 * @param Predict_Sat $sat   The satellite data.
133
+	 * @param Predict_QTH $qth   The observer data.
134
+	 * @param int         $maxdt The maximum number of days to look ahead.
135
+	 *
136
+	 * @return Predict_Pass Pointer instance or NULL if no pass can be
137
+	 *         found.
138
+	 */
139
+	public function get_next_pass(Predict_Sat $sat, Predict_QTH $qth, $maxdt)
140
+	{
141
+		/* get the current time and call the get_pass function */
142
+		$now = Predict_Time::get_current_daynum();
143
+
144
+		return $this->get_pass($sat, $qth, $now, $maxdt);
145
+	}
146
+
147
+	/** Predict first pass after a certain time.
148
+	 *
149
+	 *  @param Predict_Sat $sat   The satellite data.
150
+	 *  @param Predict_QTH $qth   The observer's location data.
151
+	 *  @param float       $start Starting time.
152
+	 *  @param int         $maxdt The maximum number of days to look ahead (0 for no limit).
153
+	 *
154
+	 *  @return Predict_Pass or NULL if there was an error.
155
+	 *
156
+	 * This function will find the first upcoming pass with AOS no earlier than
157
+	 * t = start and no later than t = (start+maxdt).
158
+	 *
159
+	 *  note For no time limit use maxdt = 0.0
160
+	 *
161
+	 *  note the data in sat will be corrupt (future) and must be refreshed
162
+	 *       by the caller, if the caller will need it later on
163
+	 */
164
+	public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt)
165
+	{
166
+		$aos = 0.0;    /* time of AOS */
167
+		$tca = 0.0;    /* time of TCA */
168
+		$los = 0.0;    /* time of LOS */
169
+		$dt = 0.0;     /* time diff */
170
+		$step = 0.0;   /* time step */
171
+		$t0 = $start;
172
+		$tres = 0.0;   /* required time resolution */
173
+		$max_el = 0.0; /* maximum elevation */
174
+		$pass = null;
175
+		$detail = null;
176
+		$done = false;
177
+		$iter = 0;      /* number of iterations */
178
+		/* FIXME: watchdog */
179
+
180
+		/*copy sat_in to a working structure*/
181
+		$sat         = clone $sat_in;
182
+		$sat_working = clone $sat_in;
183
+
184
+		/* get time resolution; sat-cfg stores it in seconds */
185
+		$tres = $this->timeRes / 86400.0;
186
+
187
+		/* loop until we find a pass with elevation > SAT_CFG_INT_PRED_MIN_EL
188 188
             or we run out of time
189 189
             FIXME: we should have a safety break
190 190
         */
191
-        while (!$done) {
192
-            /* Find los of next pass or of current pass */
193
-            $los = $this->find_los($sat, $qth, $t0, $maxdt); // See if a pass is ongoing
194
-            $aos = $this->find_aos($sat, $qth, $t0, $maxdt);
195
-            /* sat_log_log(SAT_LOG_LEVEL_MSG, "%s:%s:%d: found aos %f and los %f for t0=%f", */
196
-            /*          __FILE__,  */
197
-            /*          __FUNCTION__, */
198
-            /*          __LINE__, */
199
-            /*          aos, */
200
-            /*          los,  */
201
-            /*          t0); */
202
-            if ($aos > $los) {
203
-                // los is from an currently happening pass, find previous aos
204
-                $aos = $this->find_prev_aos($sat, $qth, $t0);
205
-            }
206
-
207
-            /* aos = 0.0 means no aos */
208
-            if ($aos == 0.0) {
209
-                $done = true;
210
-            } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt)) ) {
211
-                /* check whether we are within time limits;
191
+		while (!$done) {
192
+			/* Find los of next pass or of current pass */
193
+			$los = $this->find_los($sat, $qth, $t0, $maxdt); // See if a pass is ongoing
194
+			$aos = $this->find_aos($sat, $qth, $t0, $maxdt);
195
+			/* sat_log_log(SAT_LOG_LEVEL_MSG, "%s:%s:%d: found aos %f and los %f for t0=%f", */
196
+			/*          __FILE__,  */
197
+			/*          __FUNCTION__, */
198
+			/*          __LINE__, */
199
+			/*          aos, */
200
+			/*          los,  */
201
+			/*          t0); */
202
+			if ($aos > $los) {
203
+				// los is from an currently happening pass, find previous aos
204
+				$aos = $this->find_prev_aos($sat, $qth, $t0);
205
+			}
206
+
207
+			/* aos = 0.0 means no aos */
208
+			if ($aos == 0.0) {
209
+				$done = true;
210
+			} else if (($maxdt > 0.0) && ($aos > ($start + $maxdt)) ) {
211
+				/* check whether we are within time limits;
212 212
                     maxdt = 0 mean no time limit.
213 213
                 */
214
-                $done = true;
215
-            } else {
216
-                //los = find_los (sat, qth, aos + 0.001, maxdt); // +1.5 min later
217
-                $dt = $los - $aos;
214
+				$done = true;
215
+			} else {
216
+				//los = find_los (sat, qth, aos + 0.001, maxdt); // +1.5 min later
217
+				$dt = $los - $aos;
218 218
 
219
-                /* get time step, which will give us the max number of entries */
220
-                $step = $dt / $this->numEntries;
219
+				/* get time step, which will give us the max number of entries */
220
+				$step = $dt / $this->numEntries;
221 221
 
222
-                /* but if this is smaller than the required resolution
222
+				/* but if this is smaller than the required resolution
223 223
                     we go with the resolution
224 224
                 */
225
-                if ($step < $tres) {
226
-                    $step = $tres;
227
-                }
228
-
229
-                /* create a pass_t entry; FIXME: g_try_new in 2.8 */
230
-                $pass = new Predict_Pass();
231
-
232
-                $pass->aos      = $aos;
233
-                $pass->los      = $los;
234
-                $pass->max_el   = 0.0;
235
-                $pass->aos_az   = 0.0;
236
-                $pass->los_az   = 0.0;
237
-                $pass->maxel_az = 0.0;
238
-                $pass->vis      = '---';
239
-                $pass->satname  = $sat->nickname;
240
-                $pass->details  = array();
241
-
242
-                /* iterate over each time step */
243
-                for ($t = $pass->aos; $t <= $pass->los; $t += $step) {
244
-
245
-                    /* calculate satellite data */
246
-                    $this->predict_calc($sat, $qth, $t);
247
-
248
-                    /* in the first iter we want to store
225
+				if ($step < $tres) {
226
+					$step = $tres;
227
+				}
228
+
229
+				/* create a pass_t entry; FIXME: g_try_new in 2.8 */
230
+				$pass = new Predict_Pass();
231
+
232
+				$pass->aos      = $aos;
233
+				$pass->los      = $los;
234
+				$pass->max_el   = 0.0;
235
+				$pass->aos_az   = 0.0;
236
+				$pass->los_az   = 0.0;
237
+				$pass->maxel_az = 0.0;
238
+				$pass->vis      = '---';
239
+				$pass->satname  = $sat->nickname;
240
+				$pass->details  = array();
241
+
242
+				/* iterate over each time step */
243
+				for ($t = $pass->aos; $t <= $pass->los; $t += $step) {
244
+
245
+					/* calculate satellite data */
246
+					$this->predict_calc($sat, $qth, $t);
247
+
248
+					/* in the first iter we want to store
249 249
                         pass->aos_az
250 250
                     */
251
-                    if ($t == $pass->aos) {
252
-                        $pass->aos_az = $sat->az;
253
-                        $pass->orbit  = $sat->orbit;
254
-                    }
255
-
256
-                    /* append details to sat->details */
257
-                    $detail             = new Predict_PassDetail();
258
-                    $detail->time       = $t;
259
-                    $detail->pos->x     = $sat->pos->x;
260
-                    $detail->pos->y     = $sat->pos->y;
261
-                    $detail->pos->z     = $sat->pos->z;
262
-                    $detail->pos->w     = $sat->pos->w;
263
-                    $detail->vel->x     = $sat->vel->x;
264
-                    $detail->vel->y     = $sat->vel->y;
265
-                    $detail->vel->z     = $sat->vel->z;
266
-                    $detail->vel->w     = $sat->vel->w;
267
-                    $detail->velo       = $sat->velo;
268
-                    $detail->az         = $sat->az;
269
-                    $detail->el         = $sat->el;
270
-                    $detail->range      = $sat->range;
271
-                    $detail->range_rate = $sat->range_rate;
272
-                    $detail->lat        = $sat->ssplat;
273
-                    $detail->lon        = $sat->ssplon;
274
-                    $detail->alt        = $sat->alt;
275
-                    $detail->ma         = $sat->ma;
276
-                    $detail->phase      = $sat->phase;
277
-                    $detail->footprint  = $sat->footprint;
278
-                    $detail->orbit      = $sat->orbit;
279
-                    $detail->vis        = $this->get_sat_vis($sat, $qth, $t);
280
-
281
-                    /* also store visibility "bit" */
282
-                    switch ($detail->vis) {
283
-                        case self::SAT_VIS_VISIBLE:
284
-                            $pass->vis[0] = 'V';
285
-                            break;
286
-                        case self::SAT_VIS_DAYLIGHT:
287
-                            $pass->vis[1] = 'D';
288
-                            break;
289
-                        case self::SAT_VIS_ECLIPSED:
290
-                            $pass->vis[2] = 'E';
291
-                            break;
292
-                        default:
293
-                            break;
294
-                    }
295
-
296
-                    // Using an array, no need to prepend and reverse the list
297
-                    // as gpredict does
298
-                    $pass->details[] = $detail;
299
-
300
-                    // Look up apparent magnitude if this is a visible pass
301
-                    if ($detail->vis === self::SAT_VIS_VISIBLE) {
302
-                        $apmag = $sat->calculateApparentMagnitude($t, $qth);
303
-                        if ($pass->max_apparent_magnitude === null || $apmag < $pass->max_apparent_magnitude) {
304
-                            $pass->max_apparent_magnitude = $apmag;
305
-                        }
306
-                    }
307
-
308
-                    /* store elevation if greater than the
251
+					if ($t == $pass->aos) {
252
+						$pass->aos_az = $sat->az;
253
+						$pass->orbit  = $sat->orbit;
254
+					}
255
+
256
+					/* append details to sat->details */
257
+					$detail             = new Predict_PassDetail();
258
+					$detail->time       = $t;
259
+					$detail->pos->x     = $sat->pos->x;
260
+					$detail->pos->y     = $sat->pos->y;
261
+					$detail->pos->z     = $sat->pos->z;
262
+					$detail->pos->w     = $sat->pos->w;
263
+					$detail->vel->x     = $sat->vel->x;
264
+					$detail->vel->y     = $sat->vel->y;
265
+					$detail->vel->z     = $sat->vel->z;
266
+					$detail->vel->w     = $sat->vel->w;
267
+					$detail->velo       = $sat->velo;
268
+					$detail->az         = $sat->az;
269
+					$detail->el         = $sat->el;
270
+					$detail->range      = $sat->range;
271
+					$detail->range_rate = $sat->range_rate;
272
+					$detail->lat        = $sat->ssplat;
273
+					$detail->lon        = $sat->ssplon;
274
+					$detail->alt        = $sat->alt;
275
+					$detail->ma         = $sat->ma;
276
+					$detail->phase      = $sat->phase;
277
+					$detail->footprint  = $sat->footprint;
278
+					$detail->orbit      = $sat->orbit;
279
+					$detail->vis        = $this->get_sat_vis($sat, $qth, $t);
280
+
281
+					/* also store visibility "bit" */
282
+					switch ($detail->vis) {
283
+						case self::SAT_VIS_VISIBLE:
284
+							$pass->vis[0] = 'V';
285
+							break;
286
+						case self::SAT_VIS_DAYLIGHT:
287
+							$pass->vis[1] = 'D';
288
+							break;
289
+						case self::SAT_VIS_ECLIPSED:
290
+							$pass->vis[2] = 'E';
291
+							break;
292
+						default:
293
+							break;
294
+					}
295
+
296
+					// Using an array, no need to prepend and reverse the list
297
+					// as gpredict does
298
+					$pass->details[] = $detail;
299
+
300
+					// Look up apparent magnitude if this is a visible pass
301
+					if ($detail->vis === self::SAT_VIS_VISIBLE) {
302
+						$apmag = $sat->calculateApparentMagnitude($t, $qth);
303
+						if ($pass->max_apparent_magnitude === null || $apmag < $pass->max_apparent_magnitude) {
304
+							$pass->max_apparent_magnitude = $apmag;
305
+						}
306
+					}
307
+
308
+					/* store elevation if greater than the
309 309
                         previously stored one
310 310
                     */
311
-                    if ($sat->el > $max_el) {
312
-                        $max_el         = $sat->el;
313
-                        $tca            = $t;
314
-                        $pass->maxel_az = $sat->az;
315
-                    }
316
-
317
-                    /*     g_print ("TIME: %f\tAZ: %f\tEL: %f (MAX: %f)\n", */
318
-                    /*           t, sat->az, sat->el, max_el); */
319
-                }
320
-
321
-                /* calculate satellite data */
322
-                $this->predict_calc($sat, $qth, $pass->los);
323
-                /* store los_az, max_el and tca */
324
-                $pass->los_az = $sat->az;
325
-                $pass->max_el = $max_el;
326
-                $pass->tca    = $tca;
327
-
328
-                /* check whether this pass is good */
329
-                if ($max_el >= $this->minEle) {
330
-                    $done = true;
331
-                } else {
332
-                    $done = false;
333
-                    $t0 = $los + 0.014; // +20 min
334
-                    $pass = null;
335
-                }
336
-
337
-                $iter++;
338
-            }
339
-        }
340
-
341
-        return $pass;
342
-    }
343
-
344
-    /**
345
-     * Calculate satellite visibility.
346
-     *
347
-     * @param Predict_Sat $sat     The satellite structure.
348
-     * @param Predict_QTH $qth     The QTH
349
-     * @param float       $jul_utc The time at which the visibility should be calculated.
350
-     *
351
-     * @return int The visiblity constant, 0, 1, 2, or 3 (see above)
352
-     */
353
-    public function get_sat_vis(Predict_Sat $sat, Predict_QTH $qth, $jul_utc)
354
-    {
355
-        /* gboolean sat_sun_status;
311
+					if ($sat->el > $max_el) {
312
+						$max_el         = $sat->el;
313
+						$tca            = $t;
314
+						$pass->maxel_az = $sat->az;
315
+					}
316
+
317
+					/*     g_print ("TIME: %f\tAZ: %f\tEL: %f (MAX: %f)\n", */
318
+					/*           t, sat->az, sat->el, max_el); */
319
+				}
320
+
321
+				/* calculate satellite data */
322
+				$this->predict_calc($sat, $qth, $pass->los);
323
+				/* store los_az, max_el and tca */
324
+				$pass->los_az = $sat->az;
325
+				$pass->max_el = $max_el;
326
+				$pass->tca    = $tca;
327
+
328
+				/* check whether this pass is good */
329
+				if ($max_el >= $this->minEle) {
330
+					$done = true;
331
+				} else {
332
+					$done = false;
333
+					$t0 = $los + 0.014; // +20 min
334
+					$pass = null;
335
+				}
336
+
337
+				$iter++;
338
+			}
339
+		}
340
+
341
+		return $pass;
342
+	}
343
+
344
+	/**
345
+	 * Calculate satellite visibility.
346
+	 *
347
+	 * @param Predict_Sat $sat     The satellite structure.
348
+	 * @param Predict_QTH $qth     The QTH
349
+	 * @param float       $jul_utc The time at which the visibility should be calculated.
350
+	 *
351
+	 * @return int The visiblity constant, 0, 1, 2, or 3 (see above)
352
+	 */
353
+	public function get_sat_vis(Predict_Sat $sat, Predict_QTH $qth, $jul_utc)
354
+	{
355
+		/* gboolean sat_sun_status;
356 356
         gdouble  sun_el;
357 357
         gdouble  threshold;
358 358
         gdouble  eclipse_depth;
359 359
         sat_vis_t vis = SAT_VIS_NONE; */
360 360
 
361
-        $eclipse_depth  = 0.0;
362
-        $zero_vector    = new Predict_Vector();
363
-        $obs_geodetic   = new Predict_Geodetic();
364
-
365
-        /* Solar ECI position vector  */
366
-        $solar_vector = new Predict_Vector();
367
-
368
-        /* Solar observed az and el vector  */
369
-        $solar_set = new Predict_ObsSet();
370
-
371
-        /* FIXME: could be passed as parameter */
372
-        $obs_geodetic->lon   = $qth->lon * self::de2ra;
373
-        $obs_geodetic->lat   = $qth->lat * self::de2ra;
374
-        $obs_geodetic->alt   = $qth->alt / 1000.0;
375
-        $obs_geodetic->theta = 0;
376
-
377
-        Predict_Solar::Calculate_Solar_Position($jul_utc, $solar_vector);
378
-        Predict_SGPObs::Calculate_Obs($jul_utc, $solar_vector, $zero_vector, $obs_geodetic, $solar_set);
379
-
380
-        if (Predict_Solar::Sat_Eclipsed($sat->pos, $solar_vector, $eclipse_depth)) {
381
-            /* satellite is eclipsed */
382
-            $sat_sun_status = false;
383
-        } else {
384
-            /* satellite in sunlight => may be visible */
385
-            $sat_sun_status = true;
386
-        }
387
-
388
-        if ($sat_sun_status) {
389
-            $sun_el = Predict_Math::Degrees($solar_set->el);
390
-
391
-            if ($sun_el <= $this->threshold && $sat->el >= 0.0) {
392
-                $vis = self::SAT_VIS_VISIBLE;
393
-            } else {
394
-                $vis = self::SAT_VIS_DAYLIGHT;
395
-            }
396
-        } else {
397
-            $vis = self::SAT_VIS_ECLIPSED;
398
-        }
399
-
400
-        return $vis;
401
-    }
402
-
403
-    /** Find the AOS time of the next pass.
404
-     *  @author Alexandru Csete, OZ9AEC
405
-     *  @author John A. Magliacane, KD2BD
406
-     *  @param Predict_Sat $sat   The satellite data.
407
-     *  @param Predict_QTH $qth   The observer's location (QTH) data.
408
-     *  @param float       $start The julian date where calculation should start.
409
-     *  @param int         $maxdt The upper time limit in days (0.0 = no limit)
410
-     *  @return The julain date of the next AOS or 0.0 if the satellite has no AOS.
411
-     *
412
-     * This function finds the time of AOS for the first coming pass taking place
413
-     * no earlier that start.
414
-     * If the satellite is currently within range, the function first calls
415
-     * find_los to get the next LOS time. Then the calculations are done using
416
-     * the new start time.
417
-     *
418
-     */
419
-    public function find_aos(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt)
420
-    {
421
-        $t = $start;
422
-        $aostime = 0.0;
423
-
424
-
425
-        /* make sure current sat values are
361
+		$eclipse_depth  = 0.0;
362
+		$zero_vector    = new Predict_Vector();
363
+		$obs_geodetic   = new Predict_Geodetic();
364
+
365
+		/* Solar ECI position vector  */
366
+		$solar_vector = new Predict_Vector();
367
+
368
+		/* Solar observed az and el vector  */
369
+		$solar_set = new Predict_ObsSet();
370
+
371
+		/* FIXME: could be passed as parameter */
372
+		$obs_geodetic->lon   = $qth->lon * self::de2ra;
373
+		$obs_geodetic->lat   = $qth->lat * self::de2ra;
374
+		$obs_geodetic->alt   = $qth->alt / 1000.0;
375
+		$obs_geodetic->theta = 0;
376
+
377
+		Predict_Solar::Calculate_Solar_Position($jul_utc, $solar_vector);
378
+		Predict_SGPObs::Calculate_Obs($jul_utc, $solar_vector, $zero_vector, $obs_geodetic, $solar_set);
379
+
380
+		if (Predict_Solar::Sat_Eclipsed($sat->pos, $solar_vector, $eclipse_depth)) {
381
+			/* satellite is eclipsed */
382
+			$sat_sun_status = false;
383
+		} else {
384
+			/* satellite in sunlight => may be visible */
385
+			$sat_sun_status = true;
386
+		}
387
+
388
+		if ($sat_sun_status) {
389
+			$sun_el = Predict_Math::Degrees($solar_set->el);
390
+
391
+			if ($sun_el <= $this->threshold && $sat->el >= 0.0) {
392
+				$vis = self::SAT_VIS_VISIBLE;
393
+			} else {
394
+				$vis = self::SAT_VIS_DAYLIGHT;
395
+			}
396
+		} else {
397
+			$vis = self::SAT_VIS_ECLIPSED;
398
+		}
399
+
400
+		return $vis;
401
+	}
402
+
403
+	/** Find the AOS time of the next pass.
404
+	 *  @author Alexandru Csete, OZ9AEC
405
+	 *  @author John A. Magliacane, KD2BD
406
+	 *  @param Predict_Sat $sat   The satellite data.
407
+	 *  @param Predict_QTH $qth   The observer's location (QTH) data.
408
+	 *  @param float       $start The julian date where calculation should start.
409
+	 *  @param int         $maxdt The upper time limit in days (0.0 = no limit)
410
+	 *  @return The julain date of the next AOS or 0.0 if the satellite has no AOS.
411
+	 *
412
+	 * This function finds the time of AOS for the first coming pass taking place
413
+	 * no earlier that start.
414
+	 * If the satellite is currently within range, the function first calls
415
+	 * find_los to get the next LOS time. Then the calculations are done using
416
+	 * the new start time.
417
+	 *
418
+	 */
419
+	public function find_aos(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt)
420
+	{
421
+		$t = $start;
422
+		$aostime = 0.0;
423
+
424
+
425
+		/* make sure current sat values are
426 426
             in sync with the time
427 427
         */
428
-        $this->predict_calc($sat, $qth, $start);
429
-
430
-        /* check whether satellite has aos */
431
-        if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
432
-            ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
433
-            !$this->has_aos($sat, $qth)) {
434
-
435
-            return 0.0;
436
-        }
437
-
438
-        if ($sat->el > 0.0) {
439
-            $t = $this->find_los($sat, $qth, $start, $maxdt) + 0.014; // +20 min
440
-        }
441
-
442
-        /* invalid time (potentially returned by find_los) */
443
-        if ($t < 0.1) {
444
-            return 0.0;
445
-        }
446
-
447
-        /* update satellite data */
448
-        $this->predict_calc($sat, $qth, $t);
449
-
450
-        /* use upper time limit */
451
-        if ($maxdt > 0.0) {
452
-
453
-            /* coarse time steps */
454
-            while (($sat->el < -1.0) && ($t <= ($start + $maxdt))) {
455
-                $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0);
456
-                $this->predict_calc($sat, $qth, $t);
457
-            }
458
-
459
-            /* fine steps */
460
-            while (($aostime == 0.0) && ($t <= ($start + $maxdt))) {
461
-
462
-                if (abs($sat->el) < 0.005) {
463
-                    $aostime = $t;
464
-                } else {
465
-                    $t -= $sat->el * sqrt($sat->alt) / 530000.0;
466
-                    $this->predict_calc($sat, $qth, $t);
467
-                }
468
-            }
469
-        } else {
470
-            /* don't use upper time limit */
471
-
472
-            /* coarse time steps */
473
-            while ($sat->el < -1.0) {
474
-
475
-                $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0);
476
-                $this->predict_calc($sat, $qth, $t);
477
-            }
478
-
479
-            /* fine steps */
480
-            while ($aostime == 0.0) {
481
-
482
-                if (abs($sat->el) < 0.005) {
483
-                    $aostime = $t;
484
-                } else {
485
-                    $t -= $sat->el * sqrt($sat->alt) / 530000.0;
486
-                    $this->predict_calc($sat, $qth, $t);
487
-                }
488
-
489
-            }
490
-        }
491
-
492
-        return $aostime;
493
-    }
494
-
495
-    /** SGP4SDP4 driver for doing AOS/LOS calculations.
496
-     *  @param Predict_Sat $sat The satellite data.
497
-     *  @param Predict_QTH $qth The QTH observer location data.
498
-     *  @param float       $t   The time for calculation (Julian Date)
499
-     *
500
-     */
501
-    public function predict_calc(Predict_Sat $sat, Predict_QTH $qth, $t)
502
-    {
503
-        $obs_set      = new Predict_ObsSet();
504
-        $sat_geodetic = new Predict_Geodetic();
505
-        $obs_geodetic = new Predict_Geodetic();
506
-
507
-        $obs_geodetic->lon   = $qth->lon * self::de2ra;
508
-        $obs_geodetic->lat   = $qth->lat * self::de2ra;
509
-        $obs_geodetic->alt   = $qth->alt / 1000.0;
510
-        $obs_geodetic->theta = 0;
511
-
512
-        $sat->jul_utc = $t;
513
-        $sat->tsince = ($sat->jul_utc - $sat->jul_epoch) * self::xmnpda;
514
-
515
-        /* call the norad routines according to the deep-space flag */
516
-        $sgpsdp = Predict_SGPSDP::getInstance($sat);
517
-        if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
518
-            $sgpsdp->SDP4($sat, $sat->tsince);
519
-        } else {
520
-            $sgpsdp->SGP4($sat, $sat->tsince);
521
-        }
522
-
523
-        Predict_Math::Convert_Sat_State($sat->pos, $sat->vel);
524
-
525
-        /* get the velocity of the satellite */
526
-        $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z);
527
-        $sat->velo = $sat->vel->w;
528
-        Predict_SGPObs::Calculate_Obs($sat->jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set);
529
-        Predict_SGPObs::Calculate_LatLonAlt($sat->jul_utc, $sat->pos, $sat_geodetic);
530
-
531
-        while ($sat_geodetic->lon < -self::pi) {
532
-            $sat_geodetic->lon += self::twopi;
533
-        }
534
-
535
-        while ($sat_geodetic->lon > (self::pi)) {
536
-            $sat_geodetic->lon -= self::twopi;
537
-        }
538
-
539
-        $sat->az = Predict_Math::Degrees($obs_set->az);
540
-        $sat->el = Predict_Math::Degrees($obs_set->el);
541
-        $sat->range = $obs_set->range;
542
-        $sat->range_rate = $obs_set->range_rate;
543
-        $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat);
544
-        $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon);
545
-        $sat->alt = $sat_geodetic->alt;
546
-        $sat->ma = Predict_Math::Degrees($sat->phase);
547
-        $sat->ma *= 256.0 / 360.0;
548
-        $sat->phase = Predict_Math::Degrees($sat->phase);
549
-
550
-        /* same formulas, but the one from predict is nicer */
551
-        //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w);
552
-        $sat->footprint = 12756.33 * acos(self::xkmper / (self::xkmper + $sat->alt));
553
-        $age = $sat->jul_utc - $sat->jul_epoch;
554
-        $sat->orbit = floor(($sat->tle->xno * self::xmnpda / self::twopi +
555
-                        $age * $sat->tle->bstar * self::ae) * $age +
556
-                        $sat->tle->xmo / self::twopi) + $sat->tle->revnum - 1;
557
-    }
558
-
559
-    /** Find the LOS time of the next pass.
560
-     *  @author Alexandru Csete, OZ9AEC
561
-     *  @author John A. Magliacane, KD2BD
562
-     *  @param Predict_Sat $sat The satellite data.
563
-     *  @param Predict_QTH $qth The QTH observer location data.
564
-     *  @param float       $start The time where calculation should start. (Julian Date)
565
-     *  @param int         $maxdt The upper time limit in days (0.0 = no limit)
566
-     *  @return The time (julian date) of the next LOS or 0.0 if the satellite has no LOS.
567
-     *
568
-     * This function finds the time of LOS for the first coming pass taking place
569
-     * no earlier that start.
570
-     * If the satellite is currently out of range, the function first calls
571
-     * find_aos to get the next AOS time. Then the calculations are done using
572
-     * the new start time.
573
-     * The function has a built-in watchdog to ensure that we don't end up in
574
-     * lengthy loops.
575
-     *
576
-     */
577
-    public function find_los(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt)
578
-    {
579
-        $t = $start;
580
-        $lostime = 0.0;
581
-
582
-
583
-        $this->predict_calc($sat, $qth, $start);
584
-
585
-        /* check whether satellite has aos */
586
-        if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
587
-            ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
588
-            !$this->has_aos ($sat, $qth)) {
589
-
590
-            return 0.0;
591
-        }
592
-
593
-        if ($sat->el < 0.0) {
594
-            $t = $this->find_aos($sat, $qth, $start, $maxdt) + 0.001; // +1.5 min
595
-        }
596
-
597
-        /* invalid time (potentially returned by find_aos) */
598
-        if ($t < 0.01) {
599
-            return 0.0;
600
-        }
601
-
602
-        /* update satellite data */
603
-        $this->predict_calc($sat, $qth, $t);
604
-
605
-        /* use upper time limit */
606
-        if ($maxdt > 0.0) {
607
-
608
-            /* coarse steps */
609
-            while (($sat->el >= 1.0) && ($t <= ($start + $maxdt))) {
610
-                $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0;
611
-                $this->predict_calc($sat, $qth, $t);
612
-            }
613
-
614
-            /* fine steps */
615
-            while (($lostime == 0.0) && ($t <= ($start + $maxdt)))  {
616
-
617
-                $t += $sat->el * sqrt($sat->alt) / 502500.0;
618
-                $this->predict_calc($sat, $qth, $t);
619
-
620
-                if (abs($sat->el) < 0.005) {
621
-                    $lostime = $t;
622
-                }
623
-            }
624
-        } else {
625
-        /* don't use upper limit */
626
-
627
-            /* coarse steps */
628
-            while ($sat->el >= 1.0) {
629
-                $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0;
630
-                $this->predict_calc($sat, $qth, $t);
631
-            }
632
-
633
-            /* fine steps */
634
-            while ($lostime == 0.0) {
635
-
636
-                $t += $sat->el * sqrt($sat->alt) / 502500.0;
637
-                $this->predict_calc($sat, $qth, $t);
638
-
639
-                if (abs($sat->el) < 0.005)
640
-                    $lostime = $t;
641
-            }
642
-        }
643
-
644
-        return $lostime;
645
-    }
646
-
647
-    /** Find AOS time of current pass.
648
-     *  @param Predict_Sat $sat   The satellite to find AOS for.
649
-     *  @param Predict_QTH $qth   The ground station.
650
-     *  @param float       $start Start time, prefereably now.
651
-     *  @return The time of the previous AOS or 0.0 if the satellite has no AOS.
652
-     *
653
-     * This function can be used to find the AOS time in the past of the
654
-     * current pass.
655
-     */
656
-    public function find_prev_aos(Predict_Sat $sat, Predict_QTH $qth, $start)
657
-    {
658
-        $aostime = $start;
659
-
660
-        /* make sure current sat values are
428
+		$this->predict_calc($sat, $qth, $start);
429
+
430
+		/* check whether satellite has aos */
431
+		if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
432
+			($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
433
+			!$this->has_aos($sat, $qth)) {
434
+
435
+			return 0.0;
436
+		}
437
+
438
+		if ($sat->el > 0.0) {
439
+			$t = $this->find_los($sat, $qth, $start, $maxdt) + 0.014; // +20 min
440
+		}
441
+
442
+		/* invalid time (potentially returned by find_los) */
443
+		if ($t < 0.1) {
444
+			return 0.0;
445
+		}
446
+
447
+		/* update satellite data */
448
+		$this->predict_calc($sat, $qth, $t);
449
+
450
+		/* use upper time limit */
451
+		if ($maxdt > 0.0) {
452
+
453
+			/* coarse time steps */
454
+			while (($sat->el < -1.0) && ($t <= ($start + $maxdt))) {
455
+				$t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0);
456
+				$this->predict_calc($sat, $qth, $t);
457
+			}
458
+
459
+			/* fine steps */
460
+			while (($aostime == 0.0) && ($t <= ($start + $maxdt))) {
461
+
462
+				if (abs($sat->el) < 0.005) {
463
+					$aostime = $t;
464
+				} else {
465
+					$t -= $sat->el * sqrt($sat->alt) / 530000.0;
466
+					$this->predict_calc($sat, $qth, $t);
467
+				}
468
+			}
469
+		} else {
470
+			/* don't use upper time limit */
471
+
472
+			/* coarse time steps */
473
+			while ($sat->el < -1.0) {
474
+
475
+				$t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0);
476
+				$this->predict_calc($sat, $qth, $t);
477
+			}
478
+
479
+			/* fine steps */
480
+			while ($aostime == 0.0) {
481
+
482
+				if (abs($sat->el) < 0.005) {
483
+					$aostime = $t;
484
+				} else {
485
+					$t -= $sat->el * sqrt($sat->alt) / 530000.0;
486
+					$this->predict_calc($sat, $qth, $t);
487
+				}
488
+
489
+			}
490
+		}
491
+
492
+		return $aostime;
493
+	}
494
+
495
+	/** SGP4SDP4 driver for doing AOS/LOS calculations.
496
+	 *  @param Predict_Sat $sat The satellite data.
497
+	 *  @param Predict_QTH $qth The QTH observer location data.
498
+	 *  @param float       $t   The time for calculation (Julian Date)
499
+	 *
500
+	 */
501
+	public function predict_calc(Predict_Sat $sat, Predict_QTH $qth, $t)
502
+	{
503
+		$obs_set      = new Predict_ObsSet();
504
+		$sat_geodetic = new Predict_Geodetic();
505
+		$obs_geodetic = new Predict_Geodetic();
506
+
507
+		$obs_geodetic->lon   = $qth->lon * self::de2ra;
508
+		$obs_geodetic->lat   = $qth->lat * self::de2ra;
509
+		$obs_geodetic->alt   = $qth->alt / 1000.0;
510
+		$obs_geodetic->theta = 0;
511
+
512
+		$sat->jul_utc = $t;
513
+		$sat->tsince = ($sat->jul_utc - $sat->jul_epoch) * self::xmnpda;
514
+
515
+		/* call the norad routines according to the deep-space flag */
516
+		$sgpsdp = Predict_SGPSDP::getInstance($sat);
517
+		if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
518
+			$sgpsdp->SDP4($sat, $sat->tsince);
519
+		} else {
520
+			$sgpsdp->SGP4($sat, $sat->tsince);
521
+		}
522
+
523
+		Predict_Math::Convert_Sat_State($sat->pos, $sat->vel);
524
+
525
+		/* get the velocity of the satellite */
526
+		$sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z);
527
+		$sat->velo = $sat->vel->w;
528
+		Predict_SGPObs::Calculate_Obs($sat->jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set);
529
+		Predict_SGPObs::Calculate_LatLonAlt($sat->jul_utc, $sat->pos, $sat_geodetic);
530
+
531
+		while ($sat_geodetic->lon < -self::pi) {
532
+			$sat_geodetic->lon += self::twopi;
533
+		}
534
+
535
+		while ($sat_geodetic->lon > (self::pi)) {
536
+			$sat_geodetic->lon -= self::twopi;
537
+		}
538
+
539
+		$sat->az = Predict_Math::Degrees($obs_set->az);
540
+		$sat->el = Predict_Math::Degrees($obs_set->el);
541
+		$sat->range = $obs_set->range;
542
+		$sat->range_rate = $obs_set->range_rate;
543
+		$sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat);
544
+		$sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon);
545
+		$sat->alt = $sat_geodetic->alt;
546
+		$sat->ma = Predict_Math::Degrees($sat->phase);
547
+		$sat->ma *= 256.0 / 360.0;
548
+		$sat->phase = Predict_Math::Degrees($sat->phase);
549
+
550
+		/* same formulas, but the one from predict is nicer */
551
+		//sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w);
552
+		$sat->footprint = 12756.33 * acos(self::xkmper / (self::xkmper + $sat->alt));
553
+		$age = $sat->jul_utc - $sat->jul_epoch;
554
+		$sat->orbit = floor(($sat->tle->xno * self::xmnpda / self::twopi +
555
+						$age * $sat->tle->bstar * self::ae) * $age +
556
+						$sat->tle->xmo / self::twopi) + $sat->tle->revnum - 1;
557
+	}
558
+
559
+	/** Find the LOS time of the next pass.
560
+	 *  @author Alexandru Csete, OZ9AEC
561
+	 *  @author John A. Magliacane, KD2BD
562
+	 *  @param Predict_Sat $sat The satellite data.
563
+	 *  @param Predict_QTH $qth The QTH observer location data.
564
+	 *  @param float       $start The time where calculation should start. (Julian Date)
565
+	 *  @param int         $maxdt The upper time limit in days (0.0 = no limit)
566
+	 *  @return The time (julian date) of the next LOS or 0.0 if the satellite has no LOS.
567
+	 *
568
+	 * This function finds the time of LOS for the first coming pass taking place
569
+	 * no earlier that start.
570
+	 * If the satellite is currently out of range, the function first calls
571
+	 * find_aos to get the next AOS time. Then the calculations are done using
572
+	 * the new start time.
573
+	 * The function has a built-in watchdog to ensure that we don't end up in
574
+	 * lengthy loops.
575
+	 *
576
+	 */
577
+	public function find_los(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt)
578
+	{
579
+		$t = $start;
580
+		$lostime = 0.0;
581
+
582
+
583
+		$this->predict_calc($sat, $qth, $start);
584
+
585
+		/* check whether satellite has aos */
586
+		if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
587
+			($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
588
+			!$this->has_aos ($sat, $qth)) {
589
+
590
+			return 0.0;
591
+		}
592
+
593
+		if ($sat->el < 0.0) {
594
+			$t = $this->find_aos($sat, $qth, $start, $maxdt) + 0.001; // +1.5 min
595
+		}
596
+
597
+		/* invalid time (potentially returned by find_aos) */
598
+		if ($t < 0.01) {
599
+			return 0.0;
600
+		}
601
+
602
+		/* update satellite data */
603
+		$this->predict_calc($sat, $qth, $t);
604
+
605
+		/* use upper time limit */
606
+		if ($maxdt > 0.0) {
607
+
608
+			/* coarse steps */
609
+			while (($sat->el >= 1.0) && ($t <= ($start + $maxdt))) {
610
+				$t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0;
611
+				$this->predict_calc($sat, $qth, $t);
612
+			}
613
+
614
+			/* fine steps */
615
+			while (($lostime == 0.0) && ($t <= ($start + $maxdt)))  {
616
+
617
+				$t += $sat->el * sqrt($sat->alt) / 502500.0;
618
+				$this->predict_calc($sat, $qth, $t);
619
+
620
+				if (abs($sat->el) < 0.005) {
621
+					$lostime = $t;
622
+				}
623
+			}
624
+		} else {
625
+		/* don't use upper limit */
626
+
627
+			/* coarse steps */
628
+			while ($sat->el >= 1.0) {
629
+				$t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0;
630
+				$this->predict_calc($sat, $qth, $t);
631
+			}
632
+
633
+			/* fine steps */
634
+			while ($lostime == 0.0) {
635
+
636
+				$t += $sat->el * sqrt($sat->alt) / 502500.0;
637
+				$this->predict_calc($sat, $qth, $t);
638
+
639
+				if (abs($sat->el) < 0.005)
640
+					$lostime = $t;
641
+			}
642
+		}
643
+
644
+		return $lostime;
645
+	}
646
+
647
+	/** Find AOS time of current pass.
648
+	 *  @param Predict_Sat $sat   The satellite to find AOS for.
649
+	 *  @param Predict_QTH $qth   The ground station.
650
+	 *  @param float       $start Start time, prefereably now.
651
+	 *  @return The time of the previous AOS or 0.0 if the satellite has no AOS.
652
+	 *
653
+	 * This function can be used to find the AOS time in the past of the
654
+	 * current pass.
655
+	 */
656
+	public function find_prev_aos(Predict_Sat $sat, Predict_QTH $qth, $start)
657
+	{
658
+		$aostime = $start;
659
+
660
+		/* make sure current sat values are
661 661
             in sync with the time
662 662
         */
663
-        $this->predict_calc($sat, $qth, $start);
664
-
665
-        /* check whether satellite has aos */
666
-        if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
667
-            ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
668
-            !$this->has_aos($sat, $qth)) {
669
-
670
-            return 0.0;
671
-        }
672
-
673
-        while ($sat->el >= 0.0) {
674
-            $aostime -= 0.0005; // 0.75 min
675
-            $this->predict_calc($sat, $qth, $aostime);
676
-        }
677
-
678
-        return $aostime;
679
-    }
680
-
681
-    /** Determine whether satellite ever reaches AOS.
682
-     *  @author John A. Magliacane, KD2BD
683
-     *  @author Alexandru Csete, OZ9AEC
684
-     *  @param Predict_Sat $sat The satellite data.
685
-     *  @param Predict_QTH $qth The observer's location data
686
-     *  @return bool true if the satellite will reach AOS, false otherwise.
687
-     *
688
-     */
689
-    public function has_aos(Predict_Sat $sat, Predict_QTH $qth)
690
-    {
691
-         $retcode = false;
692
-
693
-         /* FIXME */
694
-         if ($sat->meanmo == 0.0) {
695
-              $retcode = false;
696
-         } else {
697
-
698
-            /* xincl is already in RAD by select_ephemeris */
699
-            $lin = $sat->tle->xincl;
700
-            if ($lin >= self::pio2) {
701
-                $lin = self::pi - $lin;
702
-            }
703
-
704
-            $sma = 331.25 * exp(log(1440.0 / $sat->meanmo) * (2.0 / 3.0));
705
-            $apogee = $sma * (1.0 + $sat->tle->eo) - self::xkmper;
706
-
707
-            if ((acos(self::xkmper / ($apogee + self::xkmper)) + ($lin)) > abs($qth->lat * self::de2ra)) {
708
-                $retcode = true;
709
-            } else {
710
-                $retcode = false;
711
-            }
712
-        }
713
-
714
-        return $retcode;
715
-    }
716
-
717
-    /** Predict passes after a certain time.
718
-     *
719
-     *
720
-     * This function calculates num upcoming passes with AOS no earlier
721
-     * than t = start and not later that t = (start+maxdt). The function will
722
-     *  repeatedly call get_pass until
723
-     * the number of predicted passes is equal to num, the time has reached
724
-     * limit or the get_pass function returns NULL.
725
-     *
726
-     * note For no time limit use maxdt = 0.0
727
-     *
728
-     * note the data in sat will be corrupt (future) and must be refreshed
729
-     *      by the caller, if the caller will need it later on (eg. if the caller
730
-     *      is GtkSatList).
731
-     *
732
-     * note Prepending to a singly linked list is much faster than appending.
733
-     *      Therefore, the elements are prepended whereafter the GSList is
734
-     *      reversed
735
-     *
736
-     *
737
-     * @param Predict_Sat  $sat The satellite data
738
-     * @param Predict_QTH  $qth The observer's location data
739
-     * @param float $start The start julian date
740
-     * @param int   $maxdt The max # of days to look
741
-     * @param int   $num   The max # of passes to get
742
-     * @return array of Predict_Pass instances if found, empty array otherwise
743
-     */
744
-    public function get_passes(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt, $num = 0)
745
-    {
746
-        $passes = array();
747
-
748
-        /* if no number has been specified
663
+		$this->predict_calc($sat, $qth, $start);
664
+
665
+		/* check whether satellite has aos */
666
+		if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
667
+			($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
668
+			!$this->has_aos($sat, $qth)) {
669
+
670
+			return 0.0;
671
+		}
672
+
673
+		while ($sat->el >= 0.0) {
674
+			$aostime -= 0.0005; // 0.75 min
675
+			$this->predict_calc($sat, $qth, $aostime);
676
+		}
677
+
678
+		return $aostime;
679
+	}
680
+
681
+	/** Determine whether satellite ever reaches AOS.
682
+	 *  @author John A. Magliacane, KD2BD
683
+	 *  @author Alexandru Csete, OZ9AEC
684
+	 *  @param Predict_Sat $sat The satellite data.
685
+	 *  @param Predict_QTH $qth The observer's location data
686
+	 *  @return bool true if the satellite will reach AOS, false otherwise.
687
+	 *
688
+	 */
689
+	public function has_aos(Predict_Sat $sat, Predict_QTH $qth)
690
+	{
691
+		 $retcode = false;
692
+
693
+		 /* FIXME */
694
+		 if ($sat->meanmo == 0.0) {
695
+			  $retcode = false;
696
+		 } else {
697
+
698
+			/* xincl is already in RAD by select_ephemeris */
699
+			$lin = $sat->tle->xincl;
700
+			if ($lin >= self::pio2) {
701
+				$lin = self::pi - $lin;
702
+			}
703
+
704
+			$sma = 331.25 * exp(log(1440.0 / $sat->meanmo) * (2.0 / 3.0));
705
+			$apogee = $sma * (1.0 + $sat->tle->eo) - self::xkmper;
706
+
707
+			if ((acos(self::xkmper / ($apogee + self::xkmper)) + ($lin)) > abs($qth->lat * self::de2ra)) {
708
+				$retcode = true;
709
+			} else {
710
+				$retcode = false;
711
+			}
712
+		}
713
+
714
+		return $retcode;
715
+	}
716
+
717
+	/** Predict passes after a certain time.
718
+	 *
719
+	 *
720
+	 * This function calculates num upcoming passes with AOS no earlier
721
+	 * than t = start and not later that t = (start+maxdt). The function will
722
+	 *  repeatedly call get_pass until
723
+	 * the number of predicted passes is equal to num, the time has reached
724
+	 * limit or the get_pass function returns NULL.
725
+	 *
726
+	 * note For no time limit use maxdt = 0.0
727
+	 *
728
+	 * note the data in sat will be corrupt (future) and must be refreshed
729
+	 *      by the caller, if the caller will need it later on (eg. if the caller
730
+	 *      is GtkSatList).
731
+	 *
732
+	 * note Prepending to a singly linked list is much faster than appending.
733
+	 *      Therefore, the elements are prepended whereafter the GSList is
734
+	 *      reversed
735
+	 *
736
+	 *
737
+	 * @param Predict_Sat  $sat The satellite data
738
+	 * @param Predict_QTH  $qth The observer's location data
739
+	 * @param float $start The start julian date
740
+	 * @param int   $maxdt The max # of days to look
741
+	 * @param int   $num   The max # of passes to get
742
+	 * @return array of Predict_Pass instances if found, empty array otherwise
743
+	 */
744
+	public function get_passes(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt, $num = 0)
745
+	{
746
+		$passes = array();
747
+
748
+		/* if no number has been specified
749 749
             set it to something big */
750
-        if ($num == 0) {
751
-            $num = 100;
752
-        }
750
+		if ($num == 0) {
751
+			$num = 100;
752
+		}
753 753
 
754
-        $t = $start;
754
+		$t = $start;
755 755
 
756
-        for ($i = 0; $i < $num; $i++) {
757
-            $pass = $this->get_pass($sat, $qth, $t, $maxdt);
756
+		for ($i = 0; $i < $num; $i++) {
757
+			$pass = $this->get_pass($sat, $qth, $t, $maxdt);
758 758
 
759
-            if ($pass != null) {
760
-                $passes[] = $pass;
761
-                $t = $pass->los + 0.014; // +20 min
759
+			if ($pass != null) {
760
+				$passes[] = $pass;
761
+				$t = $pass->los + 0.014; // +20 min
762 762
 
763
-                /* if maxdt > 0.0 check whether we have reached t = start+maxdt
763
+				/* if maxdt > 0.0 check whether we have reached t = start+maxdt
764 764
                     if yes finish predictions
765 765
                 */
766
-                if (($maxdt > 0.0) && ($t >= ($start + $maxdt))) {
767
-                    $i = $num;
768
-                }
769
-            } else {
770
-                /* we can't get any more passes */
771
-                $i = $num;
772
-            }
773
-        }
774
-
775
-        return $passes;
776
-    }
777
-
778
-    /**
779
-     * Filters out visible passes and adds the visible aos, tca, los, and
780
-     * corresponding az and ele for each.
781
-     *
782
-     * @param array $passes The passes returned from get_passes()
783
-     *
784
-     * @author Bill Shupp
785
-     * @return array
786
-     */
787
-    public function filterVisiblePasses(array $passes)
788
-    {
789
-        $filtered = array();
790
-
791
-        foreach ($passes as $result) {
792
-            // Dummy check
793
-            if ($result->vis[0] != 'V') {
794
-                continue;
795
-            }
796
-
797
-            $aos    = false;
798
-            $aos_az = false;
799
-            $aos    = false;
800
-            $tca    = false;
801
-            $los_az = false;
802
-            $max_el = 0;
803
-
804
-            foreach ($result->details as $detail) {
805
-                if ($detail->vis != Predict::SAT_VIS_VISIBLE) {
806
-                    continue;
807
-                }
808
-                if ($detail->el < $this->minEle) {
809
-                    continue;
810
-                }
811
-
812
-                if ($aos == false) {
813
-                    $aos       = $detail->time;
814
-                    $aos_az    = $detail->az;
815
-                    $aos_el    = $detail->el;
816
-                    $tca       = $detail->time;
817
-                    $los       = $detail->time;
818
-                    $los_az    = $detail->az;
819
-                    $los_el    = $detail->el;
820
-                    $max_el    = $detail->el;
821
-                    $max_el_az = $detail->el;
822
-                    continue;
823
-                }
824
-                $los    = $detail->time;
825
-                $los_az = $detail->az;
826
-                $los_el = $detail->el;
827
-
828
-                if ($detail->el > $max_el) {
829
-                    $tca       = $detail->time;
830
-                    $max_el    = $detail->el;
831
-                    $max_el_az = $detail->az;
832
-                }
833
-            }
834
-
835
-            if ($aos === false) {
836
-                // Does not reach minimum elevation, skip
837
-                continue;
838
-            }
839
-
840
-            $result->visible_aos       = $aos;
841
-            $result->visible_aos_az    = $aos_az;
842
-            $result->visible_aos_el    = $aos_el;
843
-            $result->visible_tca       = $tca;
844
-            $result->visible_max_el    = $max_el;
845
-            $result->visible_max_el_az = $max_el_az;
846
-            $result->visible_los       = $los;
847
-            $result->visible_los_az    = $los_az;
848
-            $result->visible_los_el    = $los_el;
849
-
850
-            $filtered[] = $result;
851
-        }
852
-
853
-        return $filtered;
854
-    }
855
-
856
-    /**
857
-     * Translates aziumuth degrees to compass direction:
858
-     *
859
-     * N (0°), NNE (22.5°), NE (45°), ENE (67.5°), E (90°), ESE (112.5°),
860
-     * SE (135°), SSE (157.5°), S (180°), SSW (202.5°), SW (225°),
861
-     * WSW (247.5°), W (270°), WNW (292.5°), NW (315°), NNW (337.5°)
862
-     *
863
-     * @param int $az The azimuth in degrees, defaults to 0
864
-     *
865
-     * @return string
866
-     */
867
-    public function azDegreesToDirection($az = 0)
868
-    {
869
-        $i = floor($az / 22.5);
870
-        $m = (22.5 * (2 * $i + 1)) / 2;
871
-        $i = ($az >= $m) ? $i + 1 : $i;
872
-
873
-        return trim(substr('N  NNENE ENEE  ESESE SSES  SSWSW WSWW  WNWNW NNWN  ', $i * 3, 3));
874
-    }
766
+				if (($maxdt > 0.0) && ($t >= ($start + $maxdt))) {
767
+					$i = $num;
768
+				}
769
+			} else {
770
+				/* we can't get any more passes */
771
+				$i = $num;
772
+			}
773
+		}
774
+
775
+		return $passes;
776
+	}
777
+
778
+	/**
779
+	 * Filters out visible passes and adds the visible aos, tca, los, and
780
+	 * corresponding az and ele for each.
781
+	 *
782
+	 * @param array $passes The passes returned from get_passes()
783
+	 *
784
+	 * @author Bill Shupp
785
+	 * @return array
786
+	 */
787
+	public function filterVisiblePasses(array $passes)
788
+	{
789
+		$filtered = array();
790
+
791
+		foreach ($passes as $result) {
792
+			// Dummy check
793
+			if ($result->vis[0] != 'V') {
794
+				continue;
795
+			}
796
+
797
+			$aos    = false;
798
+			$aos_az = false;
799
+			$aos    = false;
800
+			$tca    = false;
801
+			$los_az = false;
802
+			$max_el = 0;
803
+
804
+			foreach ($result->details as $detail) {
805
+				if ($detail->vis != Predict::SAT_VIS_VISIBLE) {
806
+					continue;
807
+				}
808
+				if ($detail->el < $this->minEle) {
809
+					continue;
810
+				}
811
+
812
+				if ($aos == false) {
813
+					$aos       = $detail->time;
814
+					$aos_az    = $detail->az;
815
+					$aos_el    = $detail->el;
816
+					$tca       = $detail->time;
817
+					$los       = $detail->time;
818
+					$los_az    = $detail->az;
819
+					$los_el    = $detail->el;
820
+					$max_el    = $detail->el;
821
+					$max_el_az = $detail->el;
822
+					continue;
823
+				}
824
+				$los    = $detail->time;
825
+				$los_az = $detail->az;
826
+				$los_el = $detail->el;
827
+
828
+				if ($detail->el > $max_el) {
829
+					$tca       = $detail->time;
830
+					$max_el    = $detail->el;
831
+					$max_el_az = $detail->az;
832
+				}
833
+			}
834
+
835
+			if ($aos === false) {
836
+				// Does not reach minimum elevation, skip
837
+				continue;
838
+			}
839
+
840
+			$result->visible_aos       = $aos;
841
+			$result->visible_aos_az    = $aos_az;
842
+			$result->visible_aos_el    = $aos_el;
843
+			$result->visible_tca       = $tca;
844
+			$result->visible_max_el    = $max_el;
845
+			$result->visible_max_el_az = $max_el_az;
846
+			$result->visible_los       = $los;
847
+			$result->visible_los_az    = $los_az;
848
+			$result->visible_los_el    = $los_el;
849
+
850
+			$filtered[] = $result;
851
+		}
852
+
853
+		return $filtered;
854
+	}
855
+
856
+	/**
857
+	 * Translates aziumuth degrees to compass direction:
858
+	 *
859
+	 * N (0°), NNE (22.5°), NE (45°), ENE (67.5°), E (90°), ESE (112.5°),
860
+	 * SE (135°), SSE (157.5°), S (180°), SSW (202.5°), SW (225°),
861
+	 * WSW (247.5°), W (270°), WNW (292.5°), NW (315°), NNW (337.5°)
862
+	 *
863
+	 * @param int $az The azimuth in degrees, defaults to 0
864
+	 *
865
+	 * @return string
866
+	 */
867
+	public function azDegreesToDirection($az = 0)
868
+	{
869
+		$i = floor($az / 22.5);
870
+		$m = (22.5 * (2 * $i + 1)) / 2;
871
+		$i = ($az >= $m) ? $i + 1 : $i;
872
+
873
+		return trim(substr('N  NNENE ENEE  ESESE SSES  SSWSW WSWW  WNWNW NNWN  ', $i * 3, 3));
874
+	}
875 875
 }
Please login to merge, or discard this patch.
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -52,60 +52,60 @@  discard block
 block discarded – undo
52 52
  */
53 53
 class Predict
54 54
 {
55
-    const de2ra    =  1.74532925E-2;   /* Degrees to Radians */
56
-    const pi       =  3.1415926535898; /* Pi */
57
-    const pio2     =  1.5707963267949; /* Pi/2 */
58
-    const x3pio2   =  4.71238898;      /* 3*Pi/2 */
59
-    const twopi    =  6.2831853071796; /* 2*Pi  */
60
-    const e6a      =  1.0E-6;
61
-    const tothrd   =  6.6666667E-1;    /* 2/3 */
62
-    const xj2      =  1.0826158E-3;    /* J2 Harmonic */
63
-    const xj3      = -2.53881E-6;      /* J3 Harmonic */
64
-    const xj4      = -1.65597E-6;      /* J4 Harmonic */
65
-    const xke      =  7.43669161E-2;
66
-    const xkmper   =  6.378135E3;      /* Earth radius km */
67
-    const xmnpda   =  1.44E3;          /* Minutes per day */
68
-    const km2mi    =  0.621371;        /* Kilometers per Mile */
69
-    const ae       =  1.0;
70
-    const ck2      =  5.413079E-4;
71
-    const ck4      =  6.209887E-7;
72
-    const __f      =  3.352779E-3;
73
-    const ge       =  3.986008E5;
74
-    const __s__    =  1.012229;
75
-    const qoms2t   =  1.880279E-09;
76
-    const secday   =  8.6400E4;        /* Seconds per day */
77
-    const omega_E  =  1.0027379;
78
-    const omega_ER =  6.3003879;
79
-    const zns      =  1.19459E-5;
80
-    const c1ss     =  2.9864797E-6;
81
-    const zes      =  1.675E-2;
82
-    const znl      =  1.5835218E-4;
83
-    const c1l      =  4.7968065E-7;
84
-    const zel      =  5.490E-2;
85
-    const zcosis   =  9.1744867E-1;
86
-    const zsinis   =  3.9785416E-1;
55
+    const de2ra    = 1.74532925E-2; /* Degrees to Radians */
56
+    const pi       = 3.1415926535898; /* Pi */
57
+    const pio2     = 1.5707963267949; /* Pi/2 */
58
+    const x3pio2   = 4.71238898; /* 3*Pi/2 */
59
+    const twopi    = 6.2831853071796; /* 2*Pi  */
60
+    const e6a      = 1.0E-6;
61
+    const tothrd   = 6.6666667E-1; /* 2/3 */
62
+    const xj2      = 1.0826158E-3; /* J2 Harmonic */
63
+    const xj3      = -2.53881E-6; /* J3 Harmonic */
64
+    const xj4      = -1.65597E-6; /* J4 Harmonic */
65
+    const xke      = 7.43669161E-2;
66
+    const xkmper   = 6.378135E3; /* Earth radius km */
67
+    const xmnpda   = 1.44E3; /* Minutes per day */
68
+    const km2mi    = 0.621371; /* Kilometers per Mile */
69
+    const ae       = 1.0;
70
+    const ck2      = 5.413079E-4;
71
+    const ck4      = 6.209887E-7;
72
+    const __f      = 3.352779E-3;
73
+    const ge       = 3.986008E5;
74
+    const __s__    = 1.012229;
75
+    const qoms2t   = 1.880279E-09;
76
+    const secday   = 8.6400E4; /* Seconds per day */
77
+    const omega_E  = 1.0027379;
78
+    const omega_ER = 6.3003879;
79
+    const zns      = 1.19459E-5;
80
+    const c1ss     = 2.9864797E-6;
81
+    const zes      = 1.675E-2;
82
+    const znl      = 1.5835218E-4;
83
+    const c1l      = 4.7968065E-7;
84
+    const zel      = 5.490E-2;
85
+    const zcosis   = 9.1744867E-1;
86
+    const zsinis   = 3.9785416E-1;
87 87
     const zsings   = -9.8088458E-1;
88
-    const zcosgs   =  1.945905E-1;
89
-    const zcoshs   =  1;
90
-    const zsinhs   =  0;
91
-    const q22      =  1.7891679E-6;
92
-    const q31      =  2.1460748E-6;
93
-    const q33      =  2.2123015E-7;
94
-    const g22      =  5.7686396;
95
-    const g32      =  9.5240898E-1;
96
-    const g44      =  1.8014998;
97
-    const g52      =  1.0508330;
98
-    const g54      =  4.4108898;
99
-    const root22   =  1.7891679E-6;
100
-    const root32   =  3.7393792E-7;
101
-    const root44   =  7.3636953E-9;
102
-    const root52   =  1.1428639E-7;
103
-    const root54   =  2.1765803E-9;
104
-    const thdt     =  4.3752691E-3;
105
-    const rho      =  1.5696615E-1;
106
-    const mfactor  =  7.292115E-5;
107
-    const __sr__   =  6.96000E5;      /*Solar radius - kilometers (IAU 76)*/
108
-    const AU       =  1.49597870E8;   /*Astronomical unit - kilometers (IAU 76)*/
88
+    const zcosgs   = 1.945905E-1;
89
+    const zcoshs   = 1;
90
+    const zsinhs   = 0;
91
+    const q22      = 1.7891679E-6;
92
+    const q31      = 2.1460748E-6;
93
+    const q33      = 2.2123015E-7;
94
+    const g22      = 5.7686396;
95
+    const g32      = 9.5240898E-1;
96
+    const g44      = 1.8014998;
97
+    const g52      = 1.0508330;
98
+    const g54      = 4.4108898;
99
+    const root22   = 1.7891679E-6;
100
+    const root32   = 3.7393792E-7;
101
+    const root44   = 7.3636953E-9;
102
+    const root52   = 1.1428639E-7;
103
+    const root54   = 2.1765803E-9;
104
+    const thdt     = 4.3752691E-3;
105
+    const rho      = 1.5696615E-1;
106
+    const mfactor  = 7.292115E-5;
107
+    const __sr__   = 6.96000E5; /*Solar radius - kilometers (IAU 76)*/
108
+    const AU       = 1.49597870E8; /*Astronomical unit - kilometers (IAU 76)*/
109 109
 
110 110
     /* visibility constants */
111 111
     const SAT_VIS_NONE     = 0;
@@ -163,18 +163,18 @@  discard block
 block discarded – undo
163 163
      */
164 164
     public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt)
165 165
     {
166
-        $aos = 0.0;    /* time of AOS */
167
-        $tca = 0.0;    /* time of TCA */
168
-        $los = 0.0;    /* time of LOS */
169
-        $dt = 0.0;     /* time diff */
170
-        $step = 0.0;   /* time step */
166
+        $aos = 0.0; /* time of AOS */
167
+        $tca = 0.0; /* time of TCA */
168
+        $los = 0.0; /* time of LOS */
169
+        $dt = 0.0; /* time diff */
170
+        $step = 0.0; /* time step */
171 171
         $t0 = $start;
172
-        $tres = 0.0;   /* required time resolution */
172
+        $tres = 0.0; /* required time resolution */
173 173
         $max_el = 0.0; /* maximum elevation */
174 174
         $pass = null;
175 175
         $detail = null;
176 176
         $done = false;
177
-        $iter = 0;      /* number of iterations */
177
+        $iter = 0; /* number of iterations */
178 178
         /* FIXME: watchdog */
179 179
 
180 180
         /*copy sat_in to a working structure*/
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         $sat_working = clone $sat_in;
183 183
 
184 184
         /* get time resolution; sat-cfg stores it in seconds */
185
-        $tres = $this->timeRes / 86400.0;
185
+        $tres = $this->timeRes/86400.0;
186 186
 
187 187
         /* loop until we find a pass with elevation > SAT_CFG_INT_PRED_MIN_EL
188 188
             or we run out of time
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             /* aos = 0.0 means no aos */
208 208
             if ($aos == 0.0) {
209 209
                 $done = true;
210
-            } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt)) ) {
210
+            } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt))) {
211 211
                 /* check whether we are within time limits;
212 212
                     maxdt = 0 mean no time limit.
213 213
                 */
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
                 $dt = $los - $aos;
218 218
 
219 219
                 /* get time step, which will give us the max number of entries */
220
-                $step = $dt / $this->numEntries;
220
+                $step = $dt/$this->numEntries;
221 221
 
222 222
                 /* but if this is smaller than the required resolution
223 223
                     we go with the resolution
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
         $solar_set = new Predict_ObsSet();
370 370
 
371 371
         /* FIXME: could be passed as parameter */
372
-        $obs_geodetic->lon   = $qth->lon * self::de2ra;
373
-        $obs_geodetic->lat   = $qth->lat * self::de2ra;
374
-        $obs_geodetic->alt   = $qth->alt / 1000.0;
372
+        $obs_geodetic->lon   = $qth->lon*self::de2ra;
373
+        $obs_geodetic->lat   = $qth->lat*self::de2ra;
374
+        $obs_geodetic->alt   = $qth->alt/1000.0;
375 375
         $obs_geodetic->theta = 0;
376 376
 
377 377
         Predict_Solar::Calculate_Solar_Position($jul_utc, $solar_vector);
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 
453 453
             /* coarse time steps */
454 454
             while (($sat->el < -1.0) && ($t <= ($start + $maxdt))) {
455
-                $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0);
455
+                $t -= 0.00035*($sat->el*(($sat->alt/8400.0) + 0.46) - 2.0);
456 456
                 $this->predict_calc($sat, $qth, $t);
457 457
             }
458 458
 
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
                 if (abs($sat->el) < 0.005) {
463 463
                     $aostime = $t;
464 464
                 } else {
465
-                    $t -= $sat->el * sqrt($sat->alt) / 530000.0;
465
+                    $t -= $sat->el*sqrt($sat->alt)/530000.0;
466 466
                     $this->predict_calc($sat, $qth, $t);
467 467
                 }
468 468
             }
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
             /* coarse time steps */
473 473
             while ($sat->el < -1.0) {
474 474
 
475
-                $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0);
475
+                $t -= 0.00035*($sat->el*(($sat->alt/8400.0) + 0.46) - 2.0);
476 476
                 $this->predict_calc($sat, $qth, $t);
477 477
             }
478 478
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
                 if (abs($sat->el) < 0.005) {
483 483
                     $aostime = $t;
484 484
                 } else {
485
-                    $t -= $sat->el * sqrt($sat->alt) / 530000.0;
485
+                    $t -= $sat->el*sqrt($sat->alt)/530000.0;
486 486
                     $this->predict_calc($sat, $qth, $t);
487 487
                 }
488 488
 
@@ -504,17 +504,17 @@  discard block
 block discarded – undo
504 504
         $sat_geodetic = new Predict_Geodetic();
505 505
         $obs_geodetic = new Predict_Geodetic();
506 506
 
507
-        $obs_geodetic->lon   = $qth->lon * self::de2ra;
508
-        $obs_geodetic->lat   = $qth->lat * self::de2ra;
509
-        $obs_geodetic->alt   = $qth->alt / 1000.0;
507
+        $obs_geodetic->lon   = $qth->lon*self::de2ra;
508
+        $obs_geodetic->lat   = $qth->lat*self::de2ra;
509
+        $obs_geodetic->alt   = $qth->alt/1000.0;
510 510
         $obs_geodetic->theta = 0;
511 511
 
512 512
         $sat->jul_utc = $t;
513
-        $sat->tsince = ($sat->jul_utc - $sat->jul_epoch) * self::xmnpda;
513
+        $sat->tsince = ($sat->jul_utc - $sat->jul_epoch)*self::xmnpda;
514 514
 
515 515
         /* call the norad routines according to the deep-space flag */
516 516
         $sgpsdp = Predict_SGPSDP::getInstance($sat);
517
-        if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
517
+        if ($sat->flags&Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
518 518
             $sgpsdp->SDP4($sat, $sat->tsince);
519 519
         } else {
520 520
             $sgpsdp->SGP4($sat, $sat->tsince);
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
         Predict_Math::Convert_Sat_State($sat->pos, $sat->vel);
524 524
 
525 525
         /* get the velocity of the satellite */
526
-        $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z);
526
+        $sat->vel->w = sqrt($sat->vel->x*$sat->vel->x + $sat->vel->y*$sat->vel->y + $sat->vel->z*$sat->vel->z);
527 527
         $sat->velo = $sat->vel->w;
528 528
         Predict_SGPObs::Calculate_Obs($sat->jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set);
529 529
         Predict_SGPObs::Calculate_LatLonAlt($sat->jul_utc, $sat->pos, $sat_geodetic);
@@ -544,16 +544,16 @@  discard block
 block discarded – undo
544 544
         $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon);
545 545
         $sat->alt = $sat_geodetic->alt;
546 546
         $sat->ma = Predict_Math::Degrees($sat->phase);
547
-        $sat->ma *= 256.0 / 360.0;
547
+        $sat->ma *= 256.0/360.0;
548 548
         $sat->phase = Predict_Math::Degrees($sat->phase);
549 549
 
550 550
         /* same formulas, but the one from predict is nicer */
551 551
         //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w);
552
-        $sat->footprint = 12756.33 * acos(self::xkmper / (self::xkmper + $sat->alt));
552
+        $sat->footprint = 12756.33*acos(self::xkmper/(self::xkmper + $sat->alt));
553 553
         $age = $sat->jul_utc - $sat->jul_epoch;
554
-        $sat->orbit = floor(($sat->tle->xno * self::xmnpda / self::twopi +
555
-                        $age * $sat->tle->bstar * self::ae) * $age +
556
-                        $sat->tle->xmo / self::twopi) + $sat->tle->revnum - 1;
554
+        $sat->orbit = floor(($sat->tle->xno*self::xmnpda/self::twopi +
555
+                        $age*$sat->tle->bstar*self::ae)*$age +
556
+                        $sat->tle->xmo/self::twopi) + $sat->tle->revnum - 1;
557 557
     }
558 558
 
559 559
     /** Find the LOS time of the next pass.
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
         /* check whether satellite has aos */
586 586
         if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) ||
587 587
             ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) ||
588
-            !$this->has_aos ($sat, $qth)) {
588
+            !$this->has_aos($sat, $qth)) {
589 589
 
590 590
             return 0.0;
591 591
         }
@@ -607,14 +607,14 @@  discard block
 block discarded – undo
607 607
 
608 608
             /* coarse steps */
609 609
             while (($sat->el >= 1.0) && ($t <= ($start + $maxdt))) {
610
-                $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0;
610
+                $t += cos(($sat->el - 1.0)*self::de2ra)*sqrt($sat->alt)/25000.0;
611 611
                 $this->predict_calc($sat, $qth, $t);
612 612
             }
613 613
 
614 614
             /* fine steps */
615
-            while (($lostime == 0.0) && ($t <= ($start + $maxdt)))  {
615
+            while (($lostime == 0.0) && ($t <= ($start + $maxdt))) {
616 616
 
617
-                $t += $sat->el * sqrt($sat->alt) / 502500.0;
617
+                $t += $sat->el*sqrt($sat->alt)/502500.0;
618 618
                 $this->predict_calc($sat, $qth, $t);
619 619
 
620 620
                 if (abs($sat->el) < 0.005) {
@@ -626,14 +626,14 @@  discard block
 block discarded – undo
626 626
 
627 627
             /* coarse steps */
628 628
             while ($sat->el >= 1.0) {
629
-                $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0;
629
+                $t += cos(($sat->el - 1.0)*self::de2ra)*sqrt($sat->alt)/25000.0;
630 630
                 $this->predict_calc($sat, $qth, $t);
631 631
             }
632 632
 
633 633
             /* fine steps */
634 634
             while ($lostime == 0.0) {
635 635
 
636
-                $t += $sat->el * sqrt($sat->alt) / 502500.0;
636
+                $t += $sat->el*sqrt($sat->alt)/502500.0;
637 637
                 $this->predict_calc($sat, $qth, $t);
638 638
 
639 639
                 if (abs($sat->el) < 0.005)
@@ -701,10 +701,10 @@  discard block
 block discarded – undo
701 701
                 $lin = self::pi - $lin;
702 702
             }
703 703
 
704
-            $sma = 331.25 * exp(log(1440.0 / $sat->meanmo) * (2.0 / 3.0));
705
-            $apogee = $sma * (1.0 + $sat->tle->eo) - self::xkmper;
704
+            $sma = 331.25*exp(log(1440.0/$sat->meanmo)*(2.0/3.0));
705
+            $apogee = $sma*(1.0 + $sat->tle->eo) - self::xkmper;
706 706
 
707
-            if ((acos(self::xkmper / ($apogee + self::xkmper)) + ($lin)) > abs($qth->lat * self::de2ra)) {
707
+            if ((acos(self::xkmper/($apogee + self::xkmper)) + ($lin)) > abs($qth->lat*self::de2ra)) {
708 708
                 $retcode = true;
709 709
             } else {
710 710
                 $retcode = false;
@@ -866,10 +866,10 @@  discard block
 block discarded – undo
866 866
      */
867 867
     public function azDegreesToDirection($az = 0)
868 868
     {
869
-        $i = floor($az / 22.5);
870
-        $m = (22.5 * (2 * $i + 1)) / 2;
869
+        $i = floor($az/22.5);
870
+        $m = (22.5*(2*$i + 1))/2;
871 871
         $i = ($az >= $m) ? $i + 1 : $i;
872 872
 
873
-        return trim(substr('N  NNENE ENEE  ESESE SSES  SSWSW WSWW  WNWNW NNWN  ', $i * 3, 3));
873
+        return trim(substr('N  NNENE ENEE  ESESE SSES  SSWSW WSWW  WNWNW NNWN  ', $i*3, 3));
874 874
     }
875 875
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -636,8 +636,9 @@
 block discarded – undo
636 636
                 $t += $sat->el * sqrt($sat->alt) / 502500.0;
637 637
                 $this->predict_calc($sat, $qth, $t);
638 638
 
639
-                if (abs($sat->el) < 0.005)
640
-                    $lostime = $t;
639
+                if (abs($sat->el) < 0.005) {
640
+                                    $lostime = $t;
641
+                }
641 642
             }
642 643
         }
643 644
 
Please login to merge, or discard this patch.
require/libs/Predict/Predict/Math.php 3 patches
Doc Comments   +16 added lines patch added patch discarded remove patch
@@ -42,6 +42,10 @@  discard block
 block discarded – undo
42 42
     }
43 43
 
44 44
     /* Returns arccosine of rgument */
45
+
46
+    /**
47
+     * @param double $arg
48
+     */
45 49
     public static function ArcCos($arg)
46 50
     {
47 51
         return Predict::pio2 - self::ArcSin($arg);
@@ -68,6 +72,10 @@  discard block
 block discarded – undo
68 72
     }
69 73
 
70 74
     /* Multiplies the vector v1 by the scalar k to produce the vector v2 */
75
+
76
+    /**
77
+     * @param integer $k
78
+     */
71 79
     public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2)
72 80
     {
73 81
         $v2->x = $k * $v1->x;
@@ -155,6 +163,10 @@  discard block
 block discarded – undo
155 163
     }
156 164
 
157 165
     /* Returns arg1 mod arg2 */
166
+
167
+    /**
168
+     * @param double $arg1
169
+     */
158 170
     public static function Modulus($arg1, $arg2)
159 171
     {
160 172
         $ret_val  = $arg1;
@@ -169,6 +181,10 @@  discard block
 block discarded – undo
169 181
     }
170 182
 
171 183
     /* Returns fractional part of double argument */
184
+
185
+    /**
186
+     * @param double $arg
187
+     */
172 188
     public static function Frac($arg)
173 189
     {
174 190
         return $arg - floor($arg);
Please login to merge, or discard this patch.
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -19,178 +19,178 @@
 block discarded – undo
19 19
  */
20 20
 class Predict_Math
21 21
 {
22
-    /* Returns sign of a float */
23
-    public static function Sign($arg)
24
-    {
25
-        if ($arg > 0 ) {
26
-            return 1;
27
-        } else if ($arg < 0 ) {
28
-            return -1;
29
-        } else {
30
-            return 0;
31
-        }
32
-    }
33
-
34
-    /* Returns the arcsine of the argument */
35
-    public static function ArcSin($arg)
36
-    {
37
-        if (abs($arg) >= 1 ) {
38
-            return (self::Sign($arg) * Predict::pio2);
39
-        } else {
40
-            return(atan($arg / sqrt(1 - $arg * $arg)));
41
-        }
42
-    }
43
-
44
-    /* Returns arccosine of rgument */
45
-    public static function ArcCos($arg)
46
-    {
47
-        return Predict::pio2 - self::ArcSin($arg);
48
-    }
49
-
50
-    /* Adds vectors v1 and v2 together to produce v3 */
51
-    public static function Vec_Add(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3)
52
-    {
53
-        $v3->x = $v1->x + $v2->x;
54
-        $v3->y = $v1->y + $v2->y;
55
-        $v3->z = $v1->z + $v2->z;
56
-
57
-        $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
58
-    }
59
-
60
-    /* Subtracts vector v2 from v1 to produce v3 */
61
-    public static function Vec_Sub(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3)
62
-    {
63
-        $v3->x = $v1->x - $v2->x;
64
-        $v3->y = $v1->y - $v2->y;
65
-        $v3->z = $v1->z - $v2->z;
66
-
67
-        $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
68
-    }
69
-
70
-    /* Multiplies the vector v1 by the scalar k to produce the vector v2 */
71
-    public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2)
72
-    {
73
-        $v2->x = $k * $v1->x;
74
-        $v2->y = $k * $v1->y;
75
-        $v2->z = $k * $v1->z;
76
-        $v2->w = abs($k) * $v1->w;
77
-    }
78
-
79
-    /* Multiplies the vector v1 by the scalar k */
80
-    public static function Scale_Vector($k, Predict_Vector $v)
81
-    {
82
-        $v->x *= $k;
83
-        $v->y *= $k;
84
-        $v->z *= $k;
85
-
86
-        $v->w = sqrt($v->x * $v->x + $v->y * $v->y + $v->z * $v->z);
87
-    }
88
-
89
-    /* Returns the dot product of two vectors */
90
-    public static function Dot(Predict_Vector $v1, Predict_Vector $v2)
91
-    {
92
-        return ($v1->x * $v2->x + $v1->y * $v2->y + $v1->z * $v2->z);
93
-    }
94
-
95
-    /* Calculates the angle between vectors v1 and v2 */
96
-    public static function Angle(Predict_Vector $v1, Predict_Vector $v2)
97
-    {
98
-        $v1->w = sqrt($v1->x * $v1->x + $v1->y * $v1->y + $v1->z * $v1->z);
99
-        $v2->w = sqrt($v2->x * $v2->x + $v2->y * $v2->y + $v2->z * $v2->z);
100
-        return (self::ArcCos(self::Dot($v1, $v2) / ($v1->w * $v2->w)));
101
-    }
102
-
103
-    /* Produces cross product of v1 and v2, and returns in v3 */
104
-    public static function Cross(Predict_Vector $v1, Predict_Vector $v2 ,Predict_Vector $v3)
105
-    {
106
-        $v3->x = $v1->y * $v2->z - $v1->z * $v2->y;
107
-        $v3->y = $v1->z * $v2->x - $v1->x * $v2->z;
108
-        $v3->z = $v1->x * $v2->y - $v1->y * $v2->x;
109
-
110
-        $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
111
-    }
112
-
113
-    /* Normalizes a vector */
114
-    public static function Normalize(Predict_Vector $v )
115
-    {
116
-        $v->x /= $v->w;
117
-        $v->y /= $v->w;
118
-        $v->z /= $v->w;
119
-    }
120
-
121
-    /* Four-quadrant arctan function */
122
-    public static function AcTan($sinx, $cosx)
123
-    {
124
-        if ($cosx == 0) {
125
-            if ($sinx > 0) {
126
-                return Predict::pio2;
127
-            } else {
128
-                return Predict::x3pio2;
129
-            }
130
-        } else {
131
-            if ($cosx > 0) {
132
-                if ($sinx > 0) {
133
-                    return atan($sinx / $cosx);
134
-                } else {
135
-                    return Predict::twopi + atan($sinx / $cosx);
136
-                }
137
-            } else {
138
-                return Predict::pi + atan($sinx / $cosx);
139
-            }
140
-        }
141
-    }
142
-
143
-    /* Returns mod 2pi of argument */
144
-    public static function FMod2p($x)
145
-    {
146
-        $ret_val  = $x;
147
-        $i        = (int) ($ret_val / Predict::twopi);
148
-        $ret_val -= $i * Predict::twopi;
149
-
150
-        if ($ret_val < 0) {
151
-            $ret_val += Predict::twopi;
152
-        }
153
-
154
-        return $ret_val;
155
-    }
156
-
157
-    /* Returns arg1 mod arg2 */
158
-    public static function Modulus($arg1, $arg2)
159
-    {
160
-        $ret_val  = $arg1;
161
-        $i        = (int) ($ret_val / $arg2);
162
-        $ret_val -= $i * $arg2;
163
-
164
-        if ($ret_val < 0) {
165
-            $ret_val += $arg2;
166
-        }
167
-
168
-        return $ret_val;
169
-    }
170
-
171
-    /* Returns fractional part of double argument */
172
-    public static function Frac($arg)
173
-    {
174
-        return $arg - floor($arg);
175
-    }
176
-
177
-    /* Converts the satellite's position and velocity  */
178
-    /* vectors from normalised values to km and km/sec */
179
-    public static function Convert_Sat_State(Predict_Vector $pos, Predict_Vector $vel)
180
-    {
181
-        self::Scale_Vector(Predict::xkmper, $pos);
182
-        self::Scale_Vector(Predict::xkmper * Predict::xmnpda / Predict::secday, $vel);
183
-    }
184
-
185
-    /* Returns angle in radians from arg in degrees */
186
-    public static function Radians($arg)
187
-    {
188
-        return $arg * Predict::de2ra;
189
-    }
190
-
191
-    /* Returns angle in degrees from arg in rads */
192
-    public static function Degrees($arg)
193
-    {
194
-      return $arg / Predict::de2ra;
195
-    }
22
+	/* Returns sign of a float */
23
+	public static function Sign($arg)
24
+	{
25
+		if ($arg > 0 ) {
26
+			return 1;
27
+		} else if ($arg < 0 ) {
28
+			return -1;
29
+		} else {
30
+			return 0;
31
+		}
32
+	}
33
+
34
+	/* Returns the arcsine of the argument */
35
+	public static function ArcSin($arg)
36
+	{
37
+		if (abs($arg) >= 1 ) {
38
+			return (self::Sign($arg) * Predict::pio2);
39
+		} else {
40
+			return(atan($arg / sqrt(1 - $arg * $arg)));
41
+		}
42
+	}
43
+
44
+	/* Returns arccosine of rgument */
45
+	public static function ArcCos($arg)
46
+	{
47
+		return Predict::pio2 - self::ArcSin($arg);
48
+	}
49
+
50
+	/* Adds vectors v1 and v2 together to produce v3 */
51
+	public static function Vec_Add(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3)
52
+	{
53
+		$v3->x = $v1->x + $v2->x;
54
+		$v3->y = $v1->y + $v2->y;
55
+		$v3->z = $v1->z + $v2->z;
56
+
57
+		$v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
58
+	}
59
+
60
+	/* Subtracts vector v2 from v1 to produce v3 */
61
+	public static function Vec_Sub(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3)
62
+	{
63
+		$v3->x = $v1->x - $v2->x;
64
+		$v3->y = $v1->y - $v2->y;
65
+		$v3->z = $v1->z - $v2->z;
66
+
67
+		$v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
68
+	}
69
+
70
+	/* Multiplies the vector v1 by the scalar k to produce the vector v2 */
71
+	public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2)
72
+	{
73
+		$v2->x = $k * $v1->x;
74
+		$v2->y = $k * $v1->y;
75
+		$v2->z = $k * $v1->z;
76
+		$v2->w = abs($k) * $v1->w;
77
+	}
78
+
79
+	/* Multiplies the vector v1 by the scalar k */
80
+	public static function Scale_Vector($k, Predict_Vector $v)
81
+	{
82
+		$v->x *= $k;
83
+		$v->y *= $k;
84
+		$v->z *= $k;
85
+
86
+		$v->w = sqrt($v->x * $v->x + $v->y * $v->y + $v->z * $v->z);
87
+	}
88
+
89
+	/* Returns the dot product of two vectors */
90
+	public static function Dot(Predict_Vector $v1, Predict_Vector $v2)
91
+	{
92
+		return ($v1->x * $v2->x + $v1->y * $v2->y + $v1->z * $v2->z);
93
+	}
94
+
95
+	/* Calculates the angle between vectors v1 and v2 */
96
+	public static function Angle(Predict_Vector $v1, Predict_Vector $v2)
97
+	{
98
+		$v1->w = sqrt($v1->x * $v1->x + $v1->y * $v1->y + $v1->z * $v1->z);
99
+		$v2->w = sqrt($v2->x * $v2->x + $v2->y * $v2->y + $v2->z * $v2->z);
100
+		return (self::ArcCos(self::Dot($v1, $v2) / ($v1->w * $v2->w)));
101
+	}
102
+
103
+	/* Produces cross product of v1 and v2, and returns in v3 */
104
+	public static function Cross(Predict_Vector $v1, Predict_Vector $v2 ,Predict_Vector $v3)
105
+	{
106
+		$v3->x = $v1->y * $v2->z - $v1->z * $v2->y;
107
+		$v3->y = $v1->z * $v2->x - $v1->x * $v2->z;
108
+		$v3->z = $v1->x * $v2->y - $v1->y * $v2->x;
109
+
110
+		$v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
111
+	}
112
+
113
+	/* Normalizes a vector */
114
+	public static function Normalize(Predict_Vector $v )
115
+	{
116
+		$v->x /= $v->w;
117
+		$v->y /= $v->w;
118
+		$v->z /= $v->w;
119
+	}
120
+
121
+	/* Four-quadrant arctan function */
122
+	public static function AcTan($sinx, $cosx)
123
+	{
124
+		if ($cosx == 0) {
125
+			if ($sinx > 0) {
126
+				return Predict::pio2;
127
+			} else {
128
+				return Predict::x3pio2;
129
+			}
130
+		} else {
131
+			if ($cosx > 0) {
132
+				if ($sinx > 0) {
133
+					return atan($sinx / $cosx);
134
+				} else {
135
+					return Predict::twopi + atan($sinx / $cosx);
136
+				}
137
+			} else {
138
+				return Predict::pi + atan($sinx / $cosx);
139
+			}
140
+		}
141
+	}
142
+
143
+	/* Returns mod 2pi of argument */
144
+	public static function FMod2p($x)
145
+	{
146
+		$ret_val  = $x;
147
+		$i        = (int) ($ret_val / Predict::twopi);
148
+		$ret_val -= $i * Predict::twopi;
149
+
150
+		if ($ret_val < 0) {
151
+			$ret_val += Predict::twopi;
152
+		}
153
+
154
+		return $ret_val;
155
+	}
156
+
157
+	/* Returns arg1 mod arg2 */
158
+	public static function Modulus($arg1, $arg2)
159
+	{
160
+		$ret_val  = $arg1;
161
+		$i        = (int) ($ret_val / $arg2);
162
+		$ret_val -= $i * $arg2;
163
+
164
+		if ($ret_val < 0) {
165
+			$ret_val += $arg2;
166
+		}
167
+
168
+		return $ret_val;
169
+	}
170
+
171
+	/* Returns fractional part of double argument */
172
+	public static function Frac($arg)
173
+	{
174
+		return $arg - floor($arg);
175
+	}
176
+
177
+	/* Converts the satellite's position and velocity  */
178
+	/* vectors from normalised values to km and km/sec */
179
+	public static function Convert_Sat_State(Predict_Vector $pos, Predict_Vector $vel)
180
+	{
181
+		self::Scale_Vector(Predict::xkmper, $pos);
182
+		self::Scale_Vector(Predict::xkmper * Predict::xmnpda / Predict::secday, $vel);
183
+	}
184
+
185
+	/* Returns angle in radians from arg in degrees */
186
+	public static function Radians($arg)
187
+	{
188
+		return $arg * Predict::de2ra;
189
+	}
190
+
191
+	/* Returns angle in degrees from arg in rads */
192
+	public static function Degrees($arg)
193
+	{
194
+	  return $arg / Predict::de2ra;
195
+	}
196 196
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
     /* Returns sign of a float */
23 23
     public static function Sign($arg)
24 24
     {
25
-        if ($arg > 0 ) {
25
+        if ($arg > 0) {
26 26
             return 1;
27
-        } else if ($arg < 0 ) {
27
+        } else if ($arg < 0) {
28 28
             return -1;
29 29
         } else {
30 30
             return 0;
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
     /* Returns the arcsine of the argument */
35 35
     public static function ArcSin($arg)
36 36
     {
37
-        if (abs($arg) >= 1 ) {
38
-            return (self::Sign($arg) * Predict::pio2);
37
+        if (abs($arg) >= 1) {
38
+            return (self::Sign($arg)*Predict::pio2);
39 39
         } else {
40
-            return(atan($arg / sqrt(1 - $arg * $arg)));
40
+            return(atan($arg/sqrt(1 - $arg*$arg)));
41 41
         }
42 42
     }
43 43
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $v3->y = $v1->y + $v2->y;
55 55
         $v3->z = $v1->z + $v2->z;
56 56
 
57
-        $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
57
+        $v3->w = sqrt($v3->x*$v3->x + $v3->y*$v3->y + $v3->z*$v3->z);
58 58
     }
59 59
 
60 60
     /* Subtracts vector v2 from v1 to produce v3 */
@@ -64,16 +64,16 @@  discard block
 block discarded – undo
64 64
         $v3->y = $v1->y - $v2->y;
65 65
         $v3->z = $v1->z - $v2->z;
66 66
 
67
-        $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
67
+        $v3->w = sqrt($v3->x*$v3->x + $v3->y*$v3->y + $v3->z*$v3->z);
68 68
     }
69 69
 
70 70
     /* Multiplies the vector v1 by the scalar k to produce the vector v2 */
71 71
     public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2)
72 72
     {
73
-        $v2->x = $k * $v1->x;
74
-        $v2->y = $k * $v1->y;
75
-        $v2->z = $k * $v1->z;
76
-        $v2->w = abs($k) * $v1->w;
73
+        $v2->x = $k*$v1->x;
74
+        $v2->y = $k*$v1->y;
75
+        $v2->z = $k*$v1->z;
76
+        $v2->w = abs($k)*$v1->w;
77 77
     }
78 78
 
79 79
     /* Multiplies the vector v1 by the scalar k */
@@ -83,35 +83,35 @@  discard block
 block discarded – undo
83 83
         $v->y *= $k;
84 84
         $v->z *= $k;
85 85
 
86
-        $v->w = sqrt($v->x * $v->x + $v->y * $v->y + $v->z * $v->z);
86
+        $v->w = sqrt($v->x*$v->x + $v->y*$v->y + $v->z*$v->z);
87 87
     }
88 88
 
89 89
     /* Returns the dot product of two vectors */
90 90
     public static function Dot(Predict_Vector $v1, Predict_Vector $v2)
91 91
     {
92
-        return ($v1->x * $v2->x + $v1->y * $v2->y + $v1->z * $v2->z);
92
+        return ($v1->x*$v2->x + $v1->y*$v2->y + $v1->z*$v2->z);
93 93
     }
94 94
 
95 95
     /* Calculates the angle between vectors v1 and v2 */
96 96
     public static function Angle(Predict_Vector $v1, Predict_Vector $v2)
97 97
     {
98
-        $v1->w = sqrt($v1->x * $v1->x + $v1->y * $v1->y + $v1->z * $v1->z);
99
-        $v2->w = sqrt($v2->x * $v2->x + $v2->y * $v2->y + $v2->z * $v2->z);
100
-        return (self::ArcCos(self::Dot($v1, $v2) / ($v1->w * $v2->w)));
98
+        $v1->w = sqrt($v1->x*$v1->x + $v1->y*$v1->y + $v1->z*$v1->z);
99
+        $v2->w = sqrt($v2->x*$v2->x + $v2->y*$v2->y + $v2->z*$v2->z);
100
+        return (self::ArcCos(self::Dot($v1, $v2)/($v1->w*$v2->w)));
101 101
     }
102 102
 
103 103
     /* Produces cross product of v1 and v2, and returns in v3 */
104
-    public static function Cross(Predict_Vector $v1, Predict_Vector $v2 ,Predict_Vector $v3)
104
+    public static function Cross(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3)
105 105
     {
106
-        $v3->x = $v1->y * $v2->z - $v1->z * $v2->y;
107
-        $v3->y = $v1->z * $v2->x - $v1->x * $v2->z;
108
-        $v3->z = $v1->x * $v2->y - $v1->y * $v2->x;
106
+        $v3->x = $v1->y*$v2->z - $v1->z*$v2->y;
107
+        $v3->y = $v1->z*$v2->x - $v1->x*$v2->z;
108
+        $v3->z = $v1->x*$v2->y - $v1->y*$v2->x;
109 109
 
110
-        $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z);
110
+        $v3->w = sqrt($v3->x*$v3->x + $v3->y*$v3->y + $v3->z*$v3->z);
111 111
     }
112 112
 
113 113
     /* Normalizes a vector */
114
-    public static function Normalize(Predict_Vector $v )
114
+    public static function Normalize(Predict_Vector $v)
115 115
     {
116 116
         $v->x /= $v->w;
117 117
         $v->y /= $v->w;
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
         } else {
131 131
             if ($cosx > 0) {
132 132
                 if ($sinx > 0) {
133
-                    return atan($sinx / $cosx);
133
+                    return atan($sinx/$cosx);
134 134
                 } else {
135
-                    return Predict::twopi + atan($sinx / $cosx);
135
+                    return Predict::twopi + atan($sinx/$cosx);
136 136
                 }
137 137
             } else {
138
-                return Predict::pi + atan($sinx / $cosx);
138
+                return Predict::pi + atan($sinx/$cosx);
139 139
             }
140 140
         }
141 141
     }
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
     public static function FMod2p($x)
145 145
     {
146 146
         $ret_val  = $x;
147
-        $i        = (int) ($ret_val / Predict::twopi);
148
-        $ret_val -= $i * Predict::twopi;
147
+        $i        = (int) ($ret_val/Predict::twopi);
148
+        $ret_val -= $i*Predict::twopi;
149 149
 
150 150
         if ($ret_val < 0) {
151 151
             $ret_val += Predict::twopi;
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
     public static function Modulus($arg1, $arg2)
159 159
     {
160 160
         $ret_val  = $arg1;
161
-        $i        = (int) ($ret_val / $arg2);
162
-        $ret_val -= $i * $arg2;
161
+        $i        = (int) ($ret_val/$arg2);
162
+        $ret_val -= $i*$arg2;
163 163
 
164 164
         if ($ret_val < 0) {
165 165
             $ret_val += $arg2;
@@ -179,18 +179,18 @@  discard block
 block discarded – undo
179 179
     public static function Convert_Sat_State(Predict_Vector $pos, Predict_Vector $vel)
180 180
     {
181 181
         self::Scale_Vector(Predict::xkmper, $pos);
182
-        self::Scale_Vector(Predict::xkmper * Predict::xmnpda / Predict::secday, $vel);
182
+        self::Scale_Vector(Predict::xkmper*Predict::xmnpda/Predict::secday, $vel);
183 183
     }
184 184
 
185 185
     /* Returns angle in radians from arg in degrees */
186 186
     public static function Radians($arg)
187 187
     {
188
-        return $arg * Predict::de2ra;
188
+        return $arg*Predict::de2ra;
189 189
     }
190 190
 
191 191
     /* Returns angle in degrees from arg in rads */
192 192
     public static function Degrees($arg)
193 193
     {
194
-      return $arg / Predict::de2ra;
194
+      return $arg/Predict::de2ra;
195 195
     }
196 196
 }
Please login to merge, or discard this patch.
require/libs/Predict/Predict/Sat.php 4 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
     }
125 125
 
126 126
     /** Initialise satellite data.
127
-     *  @param sat The satellite to initialise.
128
-     *  @param qth Optional QTH info, use (0,0) if NULL.
127
+     *  @param sat Predict_Sat satellite to initialise.
128
+     *  @param qth Predict_QTH QTH info, use (0,0) if NULL.
129 129
      *
130 130
      * This function calculates the satellite data at t = 0, ie. epoch time
131 131
      * The function is called automatically by gtk_sat_data_read_sat.
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
 
217 217
     /** Determinte whether satellite is in geostationary orbit.
218 218
      *  @author John A. Magliacane, KD2BD
219
-     *  @param sat Pointer to satellite data.
220
-     *  @return TRUE if the satellite appears to be in geostationary orbit,
219
+     *  @param sat Predict_Sat to satellite data.
220
+     *  @return boolean if the satellite appears to be in geostationary orbit,
221 221
      *          FALSE otherwise.
222 222
      *
223 223
      * A satellite is in geostationary orbit if
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
     /** Determine whether satellite has decayed.
240 240
      *  @author John A. Magliacane, KD2BD
241 241
      *  @author Alexandru Csete, OZ9AEC
242
-     *  @param sat Pointer to satellite data.
243
-     *  @return TRUE if the satellite appears to have decayed, FALSE otherwise.
242
+     *  @param sat Predict_Sat to satellite data.
243
+     *  @return boolean if the satellite appears to have decayed, FALSE otherwise.
244 244
      *  @bug Modified version of the predict code but it is not tested.
245 245
      *
246 246
      * A satellite is decayed if
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
      * @param float       $time The daynum the satellite is calculated for
274 274
      * @param Predict_QTH $qth  The observer location
275 275
      *
276
-     * @return null on failure, float otherwise
276
+     * @return null|double on failure, float otherwise
277 277
      */
278 278
     public function calculateApparentMagnitude($time, Predict_QTH $qth)
279 279
     {
Please login to merge, or discard this patch.
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -22,304 +22,304 @@
 block discarded – undo
22 22
  */
23 23
 class Predict_Sat
24 24
 {
25
-    // Fifth root of a hundred, used for magnitude calculation
26
-    const POGSONS_RATIO = 2.5118864315096;
27
-
28
-    public $name     = null;
29
-    public $nickname = null;
30
-    public $website  = null;
31
-
32
-    public $tle      = null;   /*!< Keplerian elements */
33
-    public $flags    = 0;      /*!< Flags for algo ctrl */
34
-    public $sgps     = null;
35
-    public $dps      = null;
36
-    public $deep_arg = null;
37
-    public $pos      = null;   /*!< Raw position and range */
38
-    public $vel      = null;   /*!< Raw velocity */
39
-
40
-    /*** FIXME: REMOVE */
41
-    public $bearing = null;   /*!< Az, El, range and vel */
42
-    public $astro   = null;   /*!< Ra and Decl */
43
-    /*** END */
44
-
45
-    /* time keeping fields */
46
-    public $jul_epoch = null;
47
-    public $jul_utc   = null;
48
-    public $tsince    = null;
49
-    public $aos       = null;    /*!< Next AOS. */
50
-    public $los       = null;    /*!< Next LOS */
51
-
52
-    public $az         = null;   /*!< Azimuth [deg] */
53
-    public $el         = null;   /*!< Elevation [deg] */
54
-    public $range      = null;   /*!< Range [km] */
55
-    public $range_rate = null;   /*!< Range Rate [km/sec] */
56
-    public $ra         = null;   /*!< Right Ascension [deg] */
57
-    public $dec        = null;   /*!< Declination [deg] */
58
-    public $ssplat     = null;   /*!< SSP latitude [deg] */
59
-    public $ssplon     = null;   /*!< SSP longitude [deg] */
60
-    public $alt        = null;   /*!< altitude [km] */
61
-    public $velo       = null;   /*!< velocity [km/s] */
62
-    public $ma         = null;   /*!< mean anomaly */
63
-    public $footprint  = null;   /*!< footprint */
64
-    public $phase      = null;   /*!< orbit phase */
65
-    public $meanmo     = null;   /*!< mean motion kept in rev/day */
66
-    public $orbit      = null;   /*!< orbit number */
67
-    public $otype      = null;   /*!< orbit type. */
68
-
69
-    public function __construct(Predict_TLE $tle)
70
-    {
71
-        $headerParts    = explode(' ', $tle->header);
72
-        $this->name     = $headerParts[0];
73
-        $this->nickname = $this->name;
74
-        $this->tle      = $tle;
75
-        $this->pos      = new Predict_Vector();
76
-        $this->vel      = new Predict_Vector();
77
-        $this->sgps     = new Predict_SGSDPStatic();
78
-        $this->deep_arg = new Predict_DeepArg();
79
-        $this->dps      = new Predict_DeepStatic();
80
-
81
-        $this->select_ephemeris();
82
-        $this->sat_data_init_sat($this);
83
-    }
84
-
85
-    /* Selects the apropriate ephemeris type to be used */
86
-    /* for predictions according to the data in the TLE */
87
-    /* It also processes values in the tle set so that  */
88
-    /* they are apropriate for the sgp4/sdp4 routines   */
89
-    public function select_ephemeris()
90
-    {
91
-        /* Preprocess tle set */
92
-        $this->tle->xnodeo *= Predict::de2ra;
93
-        $this->tle->omegao *= Predict::de2ra;
94
-        $this->tle->xmo    *= Predict::de2ra;
95
-        $this->tle->xincl  *= Predict::de2ra;
96
-        $temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda;
97
-
98
-        /* store mean motion before conversion */
99
-        $this->meanmo       = $this->tle->xno;
100
-        $this->tle->xno     = $this->tle->xno * $temp * Predict::xmnpda;
101
-        $this->tle->xndt2o *= $temp;
102
-        $this->tle->xndd6o  = $this->tle->xndd6o * $temp / Predict::xmnpda;
103
-        $this->tle->bstar  /= Predict::ae;
104
-
105
-        /* Period > 225 minutes is deep space */
106
-        $dd1 = Predict::xke / $this->tle->xno;
107
-        $dd2 = Predict::tothrd;
108
-        $a1 = pow($dd1, $dd2);
109
-        $r1 = cos($this->tle->xincl);
110
-        $dd1 = 1.0 - $this->tle->eo * $this->tle->eo;
111
-        $temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5);
112
-        $del1 = $temp / ($a1 * $a1);
113
-        $ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 *
114
-                                 ($del1 * 1.654320987654321 + 1.0)));
115
-        $delo = $temp / ($ao * $ao);
116
-        $xnodp = $this->tle->xno / ($delo + 1.0);
117
-
118
-        /* Select a deep-space/near-earth ephemeris */
119
-        if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) {
120
-            $this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG;
121
-        } else {
122
-            $this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG;
123
-        }
124
-    }
125
-
126
-    /** Initialise satellite data.
127
-     *  @param sat The satellite to initialise.
128
-     *  @param qth Optional QTH info, use (0,0) if NULL.
129
-     *
130
-     * This function calculates the satellite data at t = 0, ie. epoch time
131
-     * The function is called automatically by gtk_sat_data_read_sat.
132
-     */
133
-    public function sat_data_init_sat(Predict_Sat $sat, Predict_QTH $qth = null)
134
-    {
135
-        $obs_geodetic = new Predict_Geodetic();
136
-        $obs_set = new Predict_ObsSet();
137
-        $sat_geodetic = new Predict_Geodetic();
138
-        /* double jul_utc, age; */
139
-
140
-        $jul_utc = Predict_Time::Julian_Date_of_Epoch($sat->tle->epoch); // => tsince = 0.0
141
-        $sat->jul_epoch = $jul_utc;
142
-
143
-        /* initialise observer location */
144
-        if ($qth != null) {
145
-            $obs_geodetic->lon = $qth->lon * Predict::de2ra;
146
-            $obs_geodetic->lat = $qth->lat * Predict::de2ra;
147
-            $obs_geodetic->alt = $qth->alt / 1000.0;
148
-            $obs_geodetic->theta = 0;
149
-        }
150
-        else {
151
-            $obs_geodetic->lon = 0.0;
152
-            $obs_geodetic->lat = 0.0;
153
-            $obs_geodetic->alt = 0.0;
154
-            $obs_geodetic->theta = 0;
155
-        }
156
-
157
-        /* execute computations */
158
-        $sdpsgp = Predict_SGPSDP::getInstance($sat);
159
-        if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
160
-            $sdpsgp->SDP4($sat, 0.0);
161
-        } else {
162
-            $sdpsgp->SGP4($sat, 0.0);
163
-        }
164
-
165
-        /* scale position and velocity to km and km/sec */
166
-        Predict_Math::Convert_Sat_State($sat->pos, $sat->vel);
167
-
168
-        /* get the velocity of the satellite */
169
-        $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z);
170
-        $sat->velo = $sat->vel->w;
171
-        Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set);
172
-        Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic);
173
-
174
-        while ($sat_geodetic->lon < -Predict::pi) {
175
-            $sat_geodetic->lon += Predict::twopi;
176
-        }
177
-
178
-        while ($sat_geodetic->lon > Predict::pi) {
179
-            $sat_geodetic->lon -= Predict::twopi;
180
-        }
181
-
182
-        $sat->az = Predict_Math::Degrees($obs_set->az);
183
-        $sat->el = Predict_Math::Degrees($obs_set->el);
184
-        $sat->range = $obs_set->range;
185
-        $sat->range_rate = $obs_set->range_rate;
186
-        $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat);
187
-        $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon);
188
-        $sat->alt = $sat_geodetic->alt;
189
-        $sat->ma = Predict_Math::Degrees($sat->phase);
190
-        $sat->ma *= 256.0 / 360.0;
191
-        $sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w);
192
-        $age = 0.0;
193
-        $sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi +
194
-                                   $age * $sat->tle->bstar * Predict::ae) * $age +
195
-                                  $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1;
196
-
197
-        /* orbit type */
198
-        $sat->otype = $sat->get_orbit_type($sat);
199
-    }
200
-
201
-    public function get_orbit_type(Predict_Sat $sat)
202
-    {
203
-         $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN;
204
-
205
-         if ($this->geostationary($sat)) {
206
-              $orbit = Predict_SGPSDP::ORBIT_TYPE_GEO;
207
-         } else if ($this->decayed($sat)) {
208
-              $orbit = Predict_SGPSDP::ORBIT_TYPE_DECAYED;
209
-         } else {
210
-              $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN;
211
-         }
212
-
213
-         return $orbit;
214
-    }
215
-
216
-
217
-    /** Determinte whether satellite is in geostationary orbit.
218
-     *  @author John A. Magliacane, KD2BD
219
-     *  @param sat Pointer to satellite data.
220
-     *  @return TRUE if the satellite appears to be in geostationary orbit,
221
-     *          FALSE otherwise.
222
-     *
223
-     * A satellite is in geostationary orbit if
224
-     *
225
-     *     fabs (sat.meanmotion - 1.0027) < 0.0002
226
-     *
227
-     * Note: Appearantly, the mean motion can deviate much more from 1.0027 than 0.0002
228
-     */
229
-    public function geostationary(Predict_Sat $sat)
230
-    {
231
-         if (abs($sat->meanmo - 1.0027) < 0.0002) {
232
-              return true;
233
-         } else {
234
-              return false;
235
-        }
236
-    }
237
-
238
-
239
-    /** Determine whether satellite has decayed.
240
-     *  @author John A. Magliacane, KD2BD
241
-     *  @author Alexandru Csete, OZ9AEC
242
-     *  @param sat Pointer to satellite data.
243
-     *  @return TRUE if the satellite appears to have decayed, FALSE otherwise.
244
-     *  @bug Modified version of the predict code but it is not tested.
245
-     *
246
-     * A satellite is decayed if
247
-     *
248
-     *    satepoch + ((16.666666 - sat.meanmo) / (10.0*fabs(sat.drag))) < "now"
249
-     *
250
-     */
251
-    public function decayed(Predict_Sat $sat)
252
-    {
253
-        /* tle.xndt2o/(twopi/xmnpda/xmnpda) is the value before converted the
25
+	// Fifth root of a hundred, used for magnitude calculation
26
+	const POGSONS_RATIO = 2.5118864315096;
27
+
28
+	public $name     = null;
29
+	public $nickname = null;
30
+	public $website  = null;
31
+
32
+	public $tle      = null;   /*!< Keplerian elements */
33
+	public $flags    = 0;      /*!< Flags for algo ctrl */
34
+	public $sgps     = null;
35
+	public $dps      = null;
36
+	public $deep_arg = null;
37
+	public $pos      = null;   /*!< Raw position and range */
38
+	public $vel      = null;   /*!< Raw velocity */
39
+
40
+	/*** FIXME: REMOVE */
41
+	public $bearing = null;   /*!< Az, El, range and vel */
42
+	public $astro   = null;   /*!< Ra and Decl */
43
+	/*** END */
44
+
45
+	/* time keeping fields */
46
+	public $jul_epoch = null;
47
+	public $jul_utc   = null;
48
+	public $tsince    = null;
49
+	public $aos       = null;    /*!< Next AOS. */
50
+	public $los       = null;    /*!< Next LOS */
51
+
52
+	public $az         = null;   /*!< Azimuth [deg] */
53
+	public $el         = null;   /*!< Elevation [deg] */
54
+	public $range      = null;   /*!< Range [km] */
55
+	public $range_rate = null;   /*!< Range Rate [km/sec] */
56
+	public $ra         = null;   /*!< Right Ascension [deg] */
57
+	public $dec        = null;   /*!< Declination [deg] */
58
+	public $ssplat     = null;   /*!< SSP latitude [deg] */
59
+	public $ssplon     = null;   /*!< SSP longitude [deg] */
60
+	public $alt        = null;   /*!< altitude [km] */
61
+	public $velo       = null;   /*!< velocity [km/s] */
62
+	public $ma         = null;   /*!< mean anomaly */
63
+	public $footprint  = null;   /*!< footprint */
64
+	public $phase      = null;   /*!< orbit phase */
65
+	public $meanmo     = null;   /*!< mean motion kept in rev/day */
66
+	public $orbit      = null;   /*!< orbit number */
67
+	public $otype      = null;   /*!< orbit type. */
68
+
69
+	public function __construct(Predict_TLE $tle)
70
+	{
71
+		$headerParts    = explode(' ', $tle->header);
72
+		$this->name     = $headerParts[0];
73
+		$this->nickname = $this->name;
74
+		$this->tle      = $tle;
75
+		$this->pos      = new Predict_Vector();
76
+		$this->vel      = new Predict_Vector();
77
+		$this->sgps     = new Predict_SGSDPStatic();
78
+		$this->deep_arg = new Predict_DeepArg();
79
+		$this->dps      = new Predict_DeepStatic();
80
+
81
+		$this->select_ephemeris();
82
+		$this->sat_data_init_sat($this);
83
+	}
84
+
85
+	/* Selects the apropriate ephemeris type to be used */
86
+	/* for predictions according to the data in the TLE */
87
+	/* It also processes values in the tle set so that  */
88
+	/* they are apropriate for the sgp4/sdp4 routines   */
89
+	public function select_ephemeris()
90
+	{
91
+		/* Preprocess tle set */
92
+		$this->tle->xnodeo *= Predict::de2ra;
93
+		$this->tle->omegao *= Predict::de2ra;
94
+		$this->tle->xmo    *= Predict::de2ra;
95
+		$this->tle->xincl  *= Predict::de2ra;
96
+		$temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda;
97
+
98
+		/* store mean motion before conversion */
99
+		$this->meanmo       = $this->tle->xno;
100
+		$this->tle->xno     = $this->tle->xno * $temp * Predict::xmnpda;
101
+		$this->tle->xndt2o *= $temp;
102
+		$this->tle->xndd6o  = $this->tle->xndd6o * $temp / Predict::xmnpda;
103
+		$this->tle->bstar  /= Predict::ae;
104
+
105
+		/* Period > 225 minutes is deep space */
106
+		$dd1 = Predict::xke / $this->tle->xno;
107
+		$dd2 = Predict::tothrd;
108
+		$a1 = pow($dd1, $dd2);
109
+		$r1 = cos($this->tle->xincl);
110
+		$dd1 = 1.0 - $this->tle->eo * $this->tle->eo;
111
+		$temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5);
112
+		$del1 = $temp / ($a1 * $a1);
113
+		$ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 *
114
+								 ($del1 * 1.654320987654321 + 1.0)));
115
+		$delo = $temp / ($ao * $ao);
116
+		$xnodp = $this->tle->xno / ($delo + 1.0);
117
+
118
+		/* Select a deep-space/near-earth ephemeris */
119
+		if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) {
120
+			$this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG;
121
+		} else {
122
+			$this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG;
123
+		}
124
+	}
125
+
126
+	/** Initialise satellite data.
127
+	 *  @param sat The satellite to initialise.
128
+	 *  @param qth Optional QTH info, use (0,0) if NULL.
129
+	 *
130
+	 * This function calculates the satellite data at t = 0, ie. epoch time
131
+	 * The function is called automatically by gtk_sat_data_read_sat.
132
+	 */
133
+	public function sat_data_init_sat(Predict_Sat $sat, Predict_QTH $qth = null)
134
+	{
135
+		$obs_geodetic = new Predict_Geodetic();
136
+		$obs_set = new Predict_ObsSet();
137
+		$sat_geodetic = new Predict_Geodetic();
138
+		/* double jul_utc, age; */
139
+
140
+		$jul_utc = Predict_Time::Julian_Date_of_Epoch($sat->tle->epoch); // => tsince = 0.0
141
+		$sat->jul_epoch = $jul_utc;
142
+
143
+		/* initialise observer location */
144
+		if ($qth != null) {
145
+			$obs_geodetic->lon = $qth->lon * Predict::de2ra;
146
+			$obs_geodetic->lat = $qth->lat * Predict::de2ra;
147
+			$obs_geodetic->alt = $qth->alt / 1000.0;
148
+			$obs_geodetic->theta = 0;
149
+		}
150
+		else {
151
+			$obs_geodetic->lon = 0.0;
152
+			$obs_geodetic->lat = 0.0;
153
+			$obs_geodetic->alt = 0.0;
154
+			$obs_geodetic->theta = 0;
155
+		}
156
+
157
+		/* execute computations */
158
+		$sdpsgp = Predict_SGPSDP::getInstance($sat);
159
+		if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
160
+			$sdpsgp->SDP4($sat, 0.0);
161
+		} else {
162
+			$sdpsgp->SGP4($sat, 0.0);
163
+		}
164
+
165
+		/* scale position and velocity to km and km/sec */
166
+		Predict_Math::Convert_Sat_State($sat->pos, $sat->vel);
167
+
168
+		/* get the velocity of the satellite */
169
+		$sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z);
170
+		$sat->velo = $sat->vel->w;
171
+		Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set);
172
+		Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic);
173
+
174
+		while ($sat_geodetic->lon < -Predict::pi) {
175
+			$sat_geodetic->lon += Predict::twopi;
176
+		}
177
+
178
+		while ($sat_geodetic->lon > Predict::pi) {
179
+			$sat_geodetic->lon -= Predict::twopi;
180
+		}
181
+
182
+		$sat->az = Predict_Math::Degrees($obs_set->az);
183
+		$sat->el = Predict_Math::Degrees($obs_set->el);
184
+		$sat->range = $obs_set->range;
185
+		$sat->range_rate = $obs_set->range_rate;
186
+		$sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat);
187
+		$sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon);
188
+		$sat->alt = $sat_geodetic->alt;
189
+		$sat->ma = Predict_Math::Degrees($sat->phase);
190
+		$sat->ma *= 256.0 / 360.0;
191
+		$sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w);
192
+		$age = 0.0;
193
+		$sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi +
194
+								   $age * $sat->tle->bstar * Predict::ae) * $age +
195
+								  $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1;
196
+
197
+		/* orbit type */
198
+		$sat->otype = $sat->get_orbit_type($sat);
199
+	}
200
+
201
+	public function get_orbit_type(Predict_Sat $sat)
202
+	{
203
+		 $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN;
204
+
205
+		 if ($this->geostationary($sat)) {
206
+			  $orbit = Predict_SGPSDP::ORBIT_TYPE_GEO;
207
+		 } else if ($this->decayed($sat)) {
208
+			  $orbit = Predict_SGPSDP::ORBIT_TYPE_DECAYED;
209
+		 } else {
210
+			  $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN;
211
+		 }
212
+
213
+		 return $orbit;
214
+	}
215
+
216
+
217
+	/** Determinte whether satellite is in geostationary orbit.
218
+	 *  @author John A. Magliacane, KD2BD
219
+	 *  @param sat Pointer to satellite data.
220
+	 *  @return TRUE if the satellite appears to be in geostationary orbit,
221
+	 *          FALSE otherwise.
222
+	 *
223
+	 * A satellite is in geostationary orbit if
224
+	 *
225
+	 *     fabs (sat.meanmotion - 1.0027) < 0.0002
226
+	 *
227
+	 * Note: Appearantly, the mean motion can deviate much more from 1.0027 than 0.0002
228
+	 */
229
+	public function geostationary(Predict_Sat $sat)
230
+	{
231
+		 if (abs($sat->meanmo - 1.0027) < 0.0002) {
232
+			  return true;
233
+		 } else {
234
+			  return false;
235
+		}
236
+	}
237
+
238
+
239
+	/** Determine whether satellite has decayed.
240
+	 *  @author John A. Magliacane, KD2BD
241
+	 *  @author Alexandru Csete, OZ9AEC
242
+	 *  @param sat Pointer to satellite data.
243
+	 *  @return TRUE if the satellite appears to have decayed, FALSE otherwise.
244
+	 *  @bug Modified version of the predict code but it is not tested.
245
+	 *
246
+	 * A satellite is decayed if
247
+	 *
248
+	 *    satepoch + ((16.666666 - sat.meanmo) / (10.0*fabs(sat.drag))) < "now"
249
+	 *
250
+	 */
251
+	public function decayed(Predict_Sat $sat)
252
+	{
253
+		/* tle.xndt2o/(twopi/xmnpda/xmnpda) is the value before converted the
254 254
            value matches up with the value in predict 2.2.3 */
255
-        /*** FIXME decayed is treated as a static quantity.
255
+		/*** FIXME decayed is treated as a static quantity.
256 256
              It is time dependent. Also sat->jul_utc is often zero
257 257
              when this function is called
258 258
         ***/
259
-        if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) {
260
-    		return true;
261
-    	} elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) /
262
-                               (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) {
263
-              return true;
264
-        } else {
265
-              return false;
266
-        }
267
-    }
268
-
269
-    /**
270
-     * Experimental attempt at calculating apparent magnitude.  Known intrinsic
271
-     * magnitudes are listed inside the function for now.
272
-     *
273
-     * @param float       $time The daynum the satellite is calculated for
274
-     * @param Predict_QTH $qth  The observer location
275
-     *
276
-     * @return null on failure, float otherwise
277
-     */
278
-    public function calculateApparentMagnitude($time, Predict_QTH $qth)
279
-    {
280
-        // Recorded intrinsic magnitudes and their respective
281
-        // illumination and distance from heavens-above.com
282
-        static $intrinsicMagnitudes = array(
283
-            '25544' => array(
284
-                'mag'      => -1.3,
285
-                'illum'    => .5,
286
-                'distance' => 1000,
287
-            )
288
-        );
289
-
290
-        // Return null if we don't have a record of the intrinsic mag
291
-        if (!isset($intrinsicMagnitudes[$this->tle->catnr])) {
292
-            return null;
293
-        }
294
-        $imag = $intrinsicMagnitudes[$this->tle->catnr];
295
-
296
-        // Convert the observer's geodetic info to radians and km so
297
-        // we can compare vectors
298
-        $observerGeo      = new Predict_Geodetic();
299
-        $observerGeo->lat = Predict_Math::Radians($qth->lat);
300
-        $observerGeo->lon = Predict_Math::Radians($qth->lon);
301
-        $observerGeo->alt = $qth->alt * 1000;
302
-
303
-        // Now determine the sun and observer positions
304
-        $observerPos      = new Predict_Vector();
305
-        $observerVel      = new Predict_Vector();
306
-        $solarVector      = new Predict_Vector();
307
-        Predict_Solar::Calculate_Solar_Position($time, $solarVector);
308
-        Predict_SGPObs::Calculate_User_PosVel($time, $observerGeo, $observerPos, $observerVel);
309
-
310
-        // Determine the solar phase and and thus the percent illumination
311
-        $observerSatPos = new Predict_Vector();
312
-        Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos);
313
-        $phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos));
314
-        $illum      = $phaseAngle / 180;
315
-
316
-        $illuminationChange            = $illum / $imag['illum'];
317
-        $inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2);
318
-        $changeInMagnitude             = log(
319
-            $illuminationChange * $inverseSquareOfDistanceChange,
320
-            self::POGSONS_RATIO
321
-        );
322
-
323
-        return $imag['mag'] - $changeInMagnitude;
324
-    }
259
+		if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) {
260
+			return true;
261
+		} elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) /
262
+							   (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) {
263
+			  return true;
264
+		} else {
265
+			  return false;
266
+		}
267
+	}
268
+
269
+	/**
270
+	 * Experimental attempt at calculating apparent magnitude.  Known intrinsic
271
+	 * magnitudes are listed inside the function for now.
272
+	 *
273
+	 * @param float       $time The daynum the satellite is calculated for
274
+	 * @param Predict_QTH $qth  The observer location
275
+	 *
276
+	 * @return null on failure, float otherwise
277
+	 */
278
+	public function calculateApparentMagnitude($time, Predict_QTH $qth)
279
+	{
280
+		// Recorded intrinsic magnitudes and their respective
281
+		// illumination and distance from heavens-above.com
282
+		static $intrinsicMagnitudes = array(
283
+			'25544' => array(
284
+				'mag'      => -1.3,
285
+				'illum'    => .5,
286
+				'distance' => 1000,
287
+			)
288
+		);
289
+
290
+		// Return null if we don't have a record of the intrinsic mag
291
+		if (!isset($intrinsicMagnitudes[$this->tle->catnr])) {
292
+			return null;
293
+		}
294
+		$imag = $intrinsicMagnitudes[$this->tle->catnr];
295
+
296
+		// Convert the observer's geodetic info to radians and km so
297
+		// we can compare vectors
298
+		$observerGeo      = new Predict_Geodetic();
299
+		$observerGeo->lat = Predict_Math::Radians($qth->lat);
300
+		$observerGeo->lon = Predict_Math::Radians($qth->lon);
301
+		$observerGeo->alt = $qth->alt * 1000;
302
+
303
+		// Now determine the sun and observer positions
304
+		$observerPos      = new Predict_Vector();
305
+		$observerVel      = new Predict_Vector();
306
+		$solarVector      = new Predict_Vector();
307
+		Predict_Solar::Calculate_Solar_Position($time, $solarVector);
308
+		Predict_SGPObs::Calculate_User_PosVel($time, $observerGeo, $observerPos, $observerVel);
309
+
310
+		// Determine the solar phase and and thus the percent illumination
311
+		$observerSatPos = new Predict_Vector();
312
+		Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos);
313
+		$phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos));
314
+		$illum      = $phaseAngle / 180;
315
+
316
+		$illuminationChange            = $illum / $imag['illum'];
317
+		$inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2);
318
+		$changeInMagnitude             = log(
319
+			$illuminationChange * $inverseSquareOfDistanceChange,
320
+			self::POGSONS_RATIO
321
+		);
322
+
323
+		return $imag['mag'] - $changeInMagnitude;
324
+	}
325 325
 }
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -29,42 +29,42 @@  discard block
 block discarded – undo
29 29
     public $nickname = null;
30 30
     public $website  = null;
31 31
 
32
-    public $tle      = null;   /*!< Keplerian elements */
33
-    public $flags    = 0;      /*!< Flags for algo ctrl */
32
+    public $tle      = null; /*!< Keplerian elements */
33
+    public $flags    = 0; /*!< Flags for algo ctrl */
34 34
     public $sgps     = null;
35 35
     public $dps      = null;
36 36
     public $deep_arg = null;
37
-    public $pos      = null;   /*!< Raw position and range */
38
-    public $vel      = null;   /*!< Raw velocity */
37
+    public $pos      = null; /*!< Raw position and range */
38
+    public $vel      = null; /*!< Raw velocity */
39 39
 
40 40
     /*** FIXME: REMOVE */
41
-    public $bearing = null;   /*!< Az, El, range and vel */
42
-    public $astro   = null;   /*!< Ra and Decl */
41
+    public $bearing = null; /*!< Az, El, range and vel */
42
+    public $astro   = null; /*!< Ra and Decl */
43 43
     /*** END */
44 44
 
45 45
     /* time keeping fields */
46 46
     public $jul_epoch = null;
47 47
     public $jul_utc   = null;
48 48
     public $tsince    = null;
49
-    public $aos       = null;    /*!< Next AOS. */
50
-    public $los       = null;    /*!< Next LOS */
51
-
52
-    public $az         = null;   /*!< Azimuth [deg] */
53
-    public $el         = null;   /*!< Elevation [deg] */
54
-    public $range      = null;   /*!< Range [km] */
55
-    public $range_rate = null;   /*!< Range Rate [km/sec] */
56
-    public $ra         = null;   /*!< Right Ascension [deg] */
57
-    public $dec        = null;   /*!< Declination [deg] */
58
-    public $ssplat     = null;   /*!< SSP latitude [deg] */
59
-    public $ssplon     = null;   /*!< SSP longitude [deg] */
60
-    public $alt        = null;   /*!< altitude [km] */
61
-    public $velo       = null;   /*!< velocity [km/s] */
62
-    public $ma         = null;   /*!< mean anomaly */
63
-    public $footprint  = null;   /*!< footprint */
64
-    public $phase      = null;   /*!< orbit phase */
65
-    public $meanmo     = null;   /*!< mean motion kept in rev/day */
66
-    public $orbit      = null;   /*!< orbit number */
67
-    public $otype      = null;   /*!< orbit type. */
49
+    public $aos       = null; /*!< Next AOS. */
50
+    public $los       = null; /*!< Next LOS */
51
+
52
+    public $az         = null; /*!< Azimuth [deg] */
53
+    public $el         = null; /*!< Elevation [deg] */
54
+    public $range      = null; /*!< Range [km] */
55
+    public $range_rate = null; /*!< Range Rate [km/sec] */
56
+    public $ra         = null; /*!< Right Ascension [deg] */
57
+    public $dec        = null; /*!< Declination [deg] */
58
+    public $ssplat     = null; /*!< SSP latitude [deg] */
59
+    public $ssplon     = null; /*!< SSP longitude [deg] */
60
+    public $alt        = null; /*!< altitude [km] */
61
+    public $velo       = null; /*!< velocity [km/s] */
62
+    public $ma         = null; /*!< mean anomaly */
63
+    public $footprint  = null; /*!< footprint */
64
+    public $phase      = null; /*!< orbit phase */
65
+    public $meanmo     = null; /*!< mean motion kept in rev/day */
66
+    public $orbit      = null; /*!< orbit number */
67
+    public $otype      = null; /*!< orbit type. */
68 68
 
69 69
     public function __construct(Predict_TLE $tle)
70 70
     {
@@ -93,30 +93,30 @@  discard block
 block discarded – undo
93 93
         $this->tle->omegao *= Predict::de2ra;
94 94
         $this->tle->xmo    *= Predict::de2ra;
95 95
         $this->tle->xincl  *= Predict::de2ra;
96
-        $temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda;
96
+        $temp = Predict::twopi/Predict::xmnpda/Predict::xmnpda;
97 97
 
98 98
         /* store mean motion before conversion */
99 99
         $this->meanmo       = $this->tle->xno;
100
-        $this->tle->xno     = $this->tle->xno * $temp * Predict::xmnpda;
100
+        $this->tle->xno     = $this->tle->xno*$temp*Predict::xmnpda;
101 101
         $this->tle->xndt2o *= $temp;
102
-        $this->tle->xndd6o  = $this->tle->xndd6o * $temp / Predict::xmnpda;
102
+        $this->tle->xndd6o  = $this->tle->xndd6o*$temp/Predict::xmnpda;
103 103
         $this->tle->bstar  /= Predict::ae;
104 104
 
105 105
         /* Period > 225 minutes is deep space */
106
-        $dd1 = Predict::xke / $this->tle->xno;
106
+        $dd1 = Predict::xke/$this->tle->xno;
107 107
         $dd2 = Predict::tothrd;
108 108
         $a1 = pow($dd1, $dd2);
109 109
         $r1 = cos($this->tle->xincl);
110
-        $dd1 = 1.0 - $this->tle->eo * $this->tle->eo;
111
-        $temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5);
112
-        $del1 = $temp / ($a1 * $a1);
113
-        $ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 *
114
-                                 ($del1 * 1.654320987654321 + 1.0)));
115
-        $delo = $temp / ($ao * $ao);
116
-        $xnodp = $this->tle->xno / ($delo + 1.0);
110
+        $dd1 = 1.0 - $this->tle->eo*$this->tle->eo;
111
+        $temp = Predict::ck2*1.5*($r1*$r1*3.0 - 1.0)/pow($dd1, 1.5);
112
+        $del1 = $temp/($a1*$a1);
113
+        $ao = $a1*(1.0 - $del1*(Predict::tothrd*0.5 + $del1*
114
+                                 ($del1*1.654320987654321 + 1.0)));
115
+        $delo = $temp/($ao*$ao);
116
+        $xnodp = $this->tle->xno/($delo + 1.0);
117 117
 
118 118
         /* Select a deep-space/near-earth ephemeris */
119
-        if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) {
119
+        if (Predict::twopi/$xnodp/Predict::xmnpda >= .15625) {
120 120
             $this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG;
121 121
         } else {
122 122
             $this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG;
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
 
143 143
         /* initialise observer location */
144 144
         if ($qth != null) {
145
-            $obs_geodetic->lon = $qth->lon * Predict::de2ra;
146
-            $obs_geodetic->lat = $qth->lat * Predict::de2ra;
147
-            $obs_geodetic->alt = $qth->alt / 1000.0;
145
+            $obs_geodetic->lon = $qth->lon*Predict::de2ra;
146
+            $obs_geodetic->lat = $qth->lat*Predict::de2ra;
147
+            $obs_geodetic->alt = $qth->alt/1000.0;
148 148
             $obs_geodetic->theta = 0;
149 149
         }
150 150
         else {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
         /* execute computations */
158 158
         $sdpsgp = Predict_SGPSDP::getInstance($sat);
159
-        if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
159
+        if ($sat->flags&Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) {
160 160
             $sdpsgp->SDP4($sat, 0.0);
161 161
         } else {
162 162
             $sdpsgp->SGP4($sat, 0.0);
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
         Predict_Math::Convert_Sat_State($sat->pos, $sat->vel);
167 167
 
168 168
         /* get the velocity of the satellite */
169
-        $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z);
169
+        $sat->vel->w = sqrt($sat->vel->x*$sat->vel->x + $sat->vel->y*$sat->vel->y + $sat->vel->z*$sat->vel->z);
170 170
         $sat->velo = $sat->vel->w;
171 171
         Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set);
172 172
         Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic);
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
         $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon);
188 188
         $sat->alt = $sat_geodetic->alt;
189 189
         $sat->ma = Predict_Math::Degrees($sat->phase);
190
-        $sat->ma *= 256.0 / 360.0;
191
-        $sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w);
190
+        $sat->ma *= 256.0/360.0;
191
+        $sat->footprint = 2.0*Predict::xkmper*acos(Predict::xkmper/$sat->pos->w);
192 192
         $age = 0.0;
193
-        $sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi +
194
-                                   $age * $sat->tle->bstar * Predict::ae) * $age +
195
-                                  $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1;
193
+        $sat->orbit = floor(($sat->tle->xno*Predict::xmnpda/Predict::twopi +
194
+                                   $age*$sat->tle->bstar*Predict::ae)*$age +
195
+                                  $sat->tle->xmo/Predict::twopi) + $sat->tle->revnum - 1;
196 196
 
197 197
         /* orbit type */
198 198
         $sat->otype = $sat->get_orbit_type($sat);
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
              It is time dependent. Also sat->jul_utc is often zero
257 257
              when this function is called
258 258
         ***/
259
-        if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) {
259
+        if ((10.0*abs($sat->tle->xndt2o/(Predict::twopi/Predict::xmnpda/Predict::xmnpda))) == 0) {
260 260
     		return true;
261
-    	} elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) /
262
-                               (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) {
261
+    	} elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo)/
262
+                               (10.0*abs($sat->tle->xndt2o/(Predict::twopi/Predict::xmnpda/Predict::xmnpda)))) < $sat->jul_utc) {
263 263
               return true;
264 264
         } else {
265 265
               return false;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         $observerGeo      = new Predict_Geodetic();
299 299
         $observerGeo->lat = Predict_Math::Radians($qth->lat);
300 300
         $observerGeo->lon = Predict_Math::Radians($qth->lon);
301
-        $observerGeo->alt = $qth->alt * 1000;
301
+        $observerGeo->alt = $qth->alt*1000;
302 302
 
303 303
         // Now determine the sun and observer positions
304 304
         $observerPos      = new Predict_Vector();
@@ -311,12 +311,12 @@  discard block
 block discarded – undo
311 311
         $observerSatPos = new Predict_Vector();
312 312
         Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos);
313 313
         $phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos));
314
-        $illum      = $phaseAngle / 180;
314
+        $illum      = $phaseAngle/180;
315 315
 
316
-        $illuminationChange            = $illum / $imag['illum'];
317
-        $inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2);
316
+        $illuminationChange            = $illum/$imag['illum'];
317
+        $inverseSquareOfDistanceChange = pow(($imag['distance']/$this->range), 2);
318 318
         $changeInMagnitude             = log(
319
-            $illuminationChange * $inverseSquareOfDistanceChange,
319
+            $illuminationChange*$inverseSquareOfDistanceChange,
320 320
             self::POGSONS_RATIO
321 321
         );
322 322
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -146,8 +146,7 @@
 block discarded – undo
146 146
             $obs_geodetic->lat = $qth->lat * Predict::de2ra;
147 147
             $obs_geodetic->alt = $qth->alt / 1000.0;
148 148
             $obs_geodetic->theta = 0;
149
-        }
150
-        else {
149
+        } else {
151 150
             $obs_geodetic->lon = 0.0;
152 151
             $obs_geodetic->lat = 0.0;
153 152
             $obs_geodetic->alt = 0.0;
Please login to merge, or discard this patch.