Completed
Push — master ( 73f088...7f17b6 )
by Yannick
07:13
created
install/class.create_db.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -3,6 +3,10 @@
 block discarded – undo
3 3
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
4 4
 
5 5
 class create_db {
6
+
7
+	/**
8
+	 * @param string $filename
9
+	 */
6 10
 	public static function import_file($filename) {
7 11
 		$filename = filter_var($filename,FILTER_SANITIZE_STRING);
8 12
 		$Connection = new Connection();
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@  discard block
 block discarded – undo
6 6
 	public static function import_file($filename) {
7 7
 		$filename = filter_var($filename,FILTER_SANITIZE_STRING);
8 8
 		$Connection = new Connection();
9
-                //Connection::$db->beginTransaction();
10
-                 $templine = '';
11
-                 $lines = file($filename);
12
-                 foreach ($lines as $line)
13
-                 {
14
-                	if (substr($line,0,2) == '--' || $line == '') continue;
15
-                	$templine .= $line;
16
-                	if (substr(trim($line), -1,1) == ';')
17
-                	{
18
-                		try {
19
-                			$sth = $Connection->db->prepare($templine);
9
+				//Connection::$db->beginTransaction();
10
+				 $templine = '';
11
+				 $lines = file($filename);
12
+				 foreach ($lines as $line)
13
+				 {
14
+					if (substr($line,0,2) == '--' || $line == '') continue;
15
+					$templine .= $line;
16
+					if (substr(trim($line), -1,1) == ';')
17
+					{
18
+						try {
19
+							$sth = $Connection->db->prepare($templine);
20 20
 					$sth->execute();
21
-                    		} catch(PDOException $e) {
21
+							} catch(PDOException $e) {
22 22
 					return "error (import ".$filename.") : ".$e->getMessage()."\n";
23
-                    		}
24
-                		$templine = '';
25
-                	}
23
+							}
24
+						$templine = '';
25
+					}
26 26
 		}
27
-                //Connection::$db->commit();
28
-                $Connection->db = null;
29
-                return '';
27
+				//Connection::$db->commit();
28
+				$Connection->db = null;
29
+				return '';
30 30
 	}
31 31
 
32 32
 	public static function import_all_db($directory) {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		//foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename)
36 36
 		while(false !== ($filename = readdir($dh)))
37 37
 		{
38
-		    if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename);
38
+			if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename);
39 39
 		}
40 40
 		return $error;
41 41
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		$host = filter_var($host,FILTER_SANITIZE_STRING);
51 51
 		// Dirty hack
52 52
 		if ($host != 'localhost' && $host != '127.0.0.1') {
53
-		    $grantright = $_SERVER['SERVER_ADDR'];
53
+			$grantright = $_SERVER['SERVER_ADDR'];
54 54
 		} else $grantright = 'localhost';
55 55
 		try {
56 56
 			$dbh = new PDO($db_type.':host='.$host,$root,$root_pass);
Please login to merge, or discard this patch.
install/class.update_db.php 2 patches
Doc Comments   +31 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();
@@ -23,6 +26,9 @@  discard block
 block discarded – undo
23 26
 		curl_close($ch);
24 27
 	}
25 28
 
29
+	/**
30
+	 * @param string $in_file
31
+	 */
26 32
 	public static function gunzip($in_file,$out_file_name = '') {
27 33
 		//echo $in_file.' -> '.$out_file_name."\n";
28 34
 		$buffer_size = 4096; // read 4kb at a time
@@ -40,6 +46,9 @@  discard block
 block discarded – undo
40 46
 		}
41 47
 	}
42 48
 
49
+	/**
50
+	 * @param string $in_file
51
+	 */
43 52
 	public static function unzip($in_file) {
44 53
 		if ($in_file != '' && file_exists($in_file)) {
45 54
 			$path = pathinfo(realpath($in_file), PATHINFO_DIRNAME);
@@ -61,6 +70,9 @@  discard block
 block discarded – undo
61 70
 		}
62 71
 	}
63 72
 	
73
+	/**
74
+	 * @param string $database_file
75
+	 */
64 76
 	public static function retrieve_route_sqlite_to_dest($database_file) {
65 77
 		global $globalDebug, $globalTransaction;
66 78
 		//$query = 'TRUNCATE TABLE routes';
@@ -103,6 +115,10 @@  discard block
 block discarded – undo
103 115
 		}
104 116
                 return '';
105 117
 	}
118
+
119
+	/**
120
+	 * @param string $database_file
121
+	 */
106 122
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
107 123
 		global $globalTransaction;
108 124
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -168,6 +184,9 @@  discard block
 block discarded – undo
168 184
 		return '';
169 185
 	}
170 186
 
187
+	/**
188
+	 * @param string $database_file
189
+	 */
171 190
 	public static function retrieve_modes_flarmnet($database_file) {
172 191
 		global $globalTransaction;
173 192
 		$Common = new Common();
@@ -237,6 +256,9 @@  discard block
 block discarded – undo
237 256
 		return '';
238 257
 	}
239 258
 
259
+	/**
260
+	 * @param string $database_file
261
+	 */
240 262
 	public static function retrieve_modes_ogn($database_file) {
241 263
 		global $globalTransaction;
242 264
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -305,6 +327,9 @@  discard block
 block discarded – undo
305 327
 		return '';
306 328
 	}
307 329
 
330
+	/**
331
+	 * @param string $database_file
332
+	 */
308 333
 	public static function retrieve_owner($database_file,$country = 'F') {
309 334
 		global $globalTransaction;
310 335
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -937,6 +962,9 @@  discard block
 block discarded – undo
937 962
 
938 963
 	}
939 964
 */
965
+	/**
966
+	 * @param string $filename
967
+	 */
940 968
 	public static function waypoints($filename) {
941 969
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
942 970
 		global $tmp_dir, $globalTransaction;
@@ -993,6 +1021,9 @@  discard block
 block discarded – undo
993 1021
 		return '';
994 1022
         }
995 1023
 
1024
+	/**
1025
+	 * @param string $filename
1026
+	 */
996 1027
 	public static function ivao_airlines($filename) {
997 1028
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
998 1029
 		global $tmp_dir, $globalTransaction;
Please login to merge, or discard this patch.
Indentation   +305 added lines, -305 removed lines patch added patch discarded remove patch
@@ -70,38 +70,38 @@  discard block
 block discarded – undo
70 70
 		try {
71 71
 			//$Connection = new Connection();
72 72
 			$sth = $Connection->db->prepare($query);
73
-                        $sth->execute(array(':source' => $database_file));
74
-                } catch(PDOException $e) {
75
-                        return "error : ".$e->getMessage();
76
-                }
73
+						$sth->execute(array(':source' => $database_file));
74
+				} catch(PDOException $e) {
75
+						return "error : ".$e->getMessage();
76
+				}
77 77
 
78
-    		if ($globalDebug) echo " - Add routes to DB -";
79
-    		update_db::connect_sqlite($database_file);
78
+			if ($globalDebug) echo " - Add routes to DB -";
79
+			update_db::connect_sqlite($database_file);
80 80
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
81 81
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
82 82
 		try {
83
-                        $sth = update_db::$db_sqlite->prepare($query);
84
-                        $sth->execute();
85
-                } catch(PDOException $e) {
86
-                        return "error : ".$e->getMessage();
87
-                }
83
+						$sth = update_db::$db_sqlite->prepare($query);
84
+						$sth->execute();
85
+				} catch(PDOException $e) {
86
+						return "error : ".$e->getMessage();
87
+				}
88 88
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
89 89
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
90 90
 		$Connection = new Connection();
91 91
 		$sth_dest = $Connection->db->prepare($query_dest);
92 92
 		try {
93 93
 			if ($globalTransaction) $Connection->db->beginTransaction();
94
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
94
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
95 95
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
96 96
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
97 97
 				$sth_dest->execute($query_dest_values);
98
-            		}
98
+					}
99 99
 			if ($globalTransaction) $Connection->db->commit();
100 100
 		} catch(PDOException $e) {
101 101
 			if ($globalTransaction) $Connection->db->rollBack(); 
102 102
 			return "error : ".$e->getMessage();
103 103
 		}
104
-                return '';
104
+				return '';
105 105
 	}
106 106
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
107 107
 		global $globalTransaction;
@@ -110,27 +110,27 @@  discard block
 block discarded – undo
110 110
 		try {
111 111
 			$Connection = new Connection();
112 112
 			$sth = $Connection->db->prepare($query);
113
-                        $sth->execute(array(':source' => $database_file));
114
-                } catch(PDOException $e) {
115
-                        return "error : ".$e->getMessage();
116
-                }
113
+						$sth->execute(array(':source' => $database_file));
114
+				} catch(PDOException $e) {
115
+						return "error : ".$e->getMessage();
116
+				}
117 117
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
118 118
 		try {
119 119
 			$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121
-                        $sth->execute(array(':source' => $database_file));
122
-                } catch(PDOException $e) {
123
-                        return "error : ".$e->getMessage();
124
-                }
121
+						$sth->execute(array(':source' => $database_file));
122
+				} catch(PDOException $e) {
123
+						return "error : ".$e->getMessage();
124
+				}
125 125
 
126
-    		update_db::connect_sqlite($database_file);
126
+			update_db::connect_sqlite($database_file);
127 127
 		$query = 'select * from Aircraft';
128 128
 		try {
129
-                        $sth = update_db::$db_sqlite->prepare($query);
130
-                        $sth->execute();
131
-                } catch(PDOException $e) {
132
-                        return "error : ".$e->getMessage();
133
-                }
129
+						$sth = update_db::$db_sqlite->prepare($query);
130
+						$sth->execute();
131
+				} catch(PDOException $e) {
132
+						return "error : ".$e->getMessage();
133
+				}
134 134
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
135 135
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
136 136
 		
@@ -141,17 +141,17 @@  discard block
 block discarded – undo
141 141
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
142 142
 		try {
143 143
 			if ($globalTransaction) $Connection->db->beginTransaction();
144
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
144
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
145 145
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
146 146
 				if ($values['UserString4'] == 'M') $type = 'military';
147 147
 				else $type = null;
148 148
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
149 149
 				$sth_dest->execute($query_dest_values);
150 150
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
151
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
152
-				    $sth_dest_owner->execute($query_dest_owner_values);
151
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
152
+					$sth_dest_owner->execute($query_dest_owner_values);
153 153
 				}
154
-            		}
154
+					}
155 155
 			if ($globalTransaction) $Connection->db->commit();
156 156
 		} catch(PDOException $e) {
157 157
 			return "error : ".$e->getMessage();
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 		try {
162 162
 			$Connection = new Connection();
163 163
 			$sth = $Connection->db->prepare($query);
164
-                        $sth->execute(array(':source' => $database_file));
165
-                } catch(PDOException $e) {
166
-                        return "error : ".$e->getMessage();
167
-                }
164
+						$sth->execute(array(':source' => $database_file));
165
+				} catch(PDOException $e) {
166
+						return "error : ".$e->getMessage();
167
+				}
168 168
 		return '';
169 169
 	}
170 170
 
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 		try {
177 177
 			$Connection = new Connection();
178 178
 			$sth = $Connection->db->prepare($query);
179
-                        $sth->execute(array(':source' => $database_file));
180
-                } catch(PDOException $e) {
181
-                        return "error : ".$e->getMessage();
182
-                }
179
+						$sth->execute(array(':source' => $database_file));
180
+				} catch(PDOException $e) {
181
+						return "error : ".$e->getMessage();
182
+				}
183 183
 		
184 184
 		if ($fh = fopen($database_file,"r")) {
185 185
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -189,25 +189,25 @@  discard block
 block discarded – undo
189 189
 			$sth_dest = $Connection->db->prepare($query_dest);
190 190
 			try {
191 191
 				if ($globalTransaction) $Connection->db->beginTransaction();
192
-            			while (!feof($fh)) {
193
-            				$line = $Common->hex2str(fgets($fh,9999));
192
+						while (!feof($fh)) {
193
+							$line = $Common->hex2str(fgets($fh,9999));
194 194
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
195
-            				$values['ModeS'] = substr($line,0,6);
196
-            				$values['Registration'] = trim(substr($line,69,6));
197
-            				$aircraft_name = trim(substr($line,48,6));
198
-            				// Check if we can find ICAO, else set it to GLID
199
-            				$aircraft_name_split = explode(' ',$aircraft_name);
200
-            				$search_more = '';
201
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
202
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
203
-            				$sth_search = $Connection->db->prepare($query_search);
195
+							$values['ModeS'] = substr($line,0,6);
196
+							$values['Registration'] = trim(substr($line,69,6));
197
+							$aircraft_name = trim(substr($line,48,6));
198
+							// Check if we can find ICAO, else set it to GLID
199
+							$aircraft_name_split = explode(' ',$aircraft_name);
200
+							$search_more = '';
201
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
202
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
203
+							$sth_search = $Connection->db->prepare($query_search);
204 204
 					try {
205
-                                    		$sth_search->execute();
206
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
207
-	            				//if (count($result) > 0) {
208
-	            				if (isset($result['icao']) && $result['icao'] != '') {
209
-	            				    $values['ICAOTypeCode'] = $result['icao'];
210
-	            				} 
205
+											$sth_search->execute();
206
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
207
+								//if (count($result) > 0) {
208
+								if (isset($result['icao']) && $result['icao'] != '') {
209
+									$values['ICAOTypeCode'] = $result['icao'];
210
+								} 
211 211
 					} catch(PDOException $e) {
212 212
 						return "error : ".$e->getMessage();
213 213
 					}
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
 		try {
231 231
 			$Connection = new Connection();
232 232
 			$sth = $Connection->db->prepare($query);
233
-                        $sth->execute(array(':source' => $database_file));
234
-                } catch(PDOException $e) {
235
-                        return "error : ".$e->getMessage();
236
-                }
233
+						$sth->execute(array(':source' => $database_file));
234
+				} catch(PDOException $e) {
235
+						return "error : ".$e->getMessage();
236
+				}
237 237
 		return '';
238 238
 	}
239 239
 
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 		try {
245 245
 			$Connection = new Connection();
246 246
 			$sth = $Connection->db->prepare($query);
247
-                        $sth->execute(array(':source' => $database_file));
248
-                } catch(PDOException $e) {
249
-                        return "error : ".$e->getMessage();
250
-                }
247
+						$sth->execute(array(':source' => $database_file));
248
+				} catch(PDOException $e) {
249
+						return "error : ".$e->getMessage();
250
+				}
251 251
 		
252 252
 		if ($fh = fopen($database_file,"r")) {
253 253
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -258,24 +258,24 @@  discard block
 block discarded – undo
258 258
 			try {
259 259
 				if ($globalTransaction) $Connection->db->beginTransaction();
260 260
 				$tmp = fgetcsv($fh,9999,',',"'");
261
-            			while (!feof($fh)) {
262
-            				$line = fgetcsv($fh,9999,',',"'");
261
+						while (!feof($fh)) {
262
+							$line = fgetcsv($fh,9999,',',"'");
263 263
             				
264 264
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
265 265
 					//print_r($line);
266
-            				$values['ModeS'] = $line[1];
267
-            				$values['Registration'] = $line[3];
268
-            				$aircraft_name = $line[2];
269
-            				// Check if we can find ICAO, else set it to GLID
270
-            				$aircraft_name_split = explode(' ',$aircraft_name);
271
-            				$search_more = '';
272
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
273
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
274
-            				$sth_search = $Connection->db->prepare($query_search);
266
+							$values['ModeS'] = $line[1];
267
+							$values['Registration'] = $line[3];
268
+							$aircraft_name = $line[2];
269
+							// Check if we can find ICAO, else set it to GLID
270
+							$aircraft_name_split = explode(' ',$aircraft_name);
271
+							$search_more = '';
272
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
273
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
274
+							$sth_search = $Connection->db->prepare($query_search);
275 275
 					try {
276
-                                    		$sth_search->execute();
277
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
278
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
276
+											$sth_search->execute();
277
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
278
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
279 279
 					} catch(PDOException $e) {
280 280
 						return "error : ".$e->getMessage();
281 281
 					}
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 		try {
299 299
 			$Connection = new Connection();
300 300
 			$sth = $Connection->db->prepare($query);
301
-                        $sth->execute(array(':source' => $database_file));
302
-                } catch(PDOException $e) {
303
-                        return "error : ".$e->getMessage();
304
-                }
301
+						$sth->execute(array(':source' => $database_file));
302
+				} catch(PDOException $e) {
303
+						return "error : ".$e->getMessage();
304
+				}
305 305
 		return '';
306 306
 	}
307 307
 
@@ -312,10 +312,10 @@  discard block
 block discarded – undo
312 312
 		try {
313 313
 			$Connection = new Connection();
314 314
 			$sth = $Connection->db->prepare($query);
315
-                        $sth->execute(array(':source' => $database_file));
316
-                } catch(PDOException $e) {
317
-                        return "error : ".$e->getMessage();
318
-                }
315
+						$sth->execute(array(':source' => $database_file));
316
+				} catch(PDOException $e) {
317
+						return "error : ".$e->getMessage();
318
+				}
319 319
 		
320 320
 		if ($fh = fopen($database_file,"r")) {
321 321
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -326,94 +326,94 @@  discard block
 block discarded – undo
326 326
 			try {
327 327
 				if ($globalTransaction) $Connection->db->beginTransaction();
328 328
 				$tmp = fgetcsv($fh,9999,',','"');
329
-            			while (!feof($fh)) {
330
-            				$line = fgetcsv($fh,9999,',','"');
331
-            				//print_r($line);
332
-            				if ($country == 'F') {
333
-            				    $values['registration'] = $line[0];
334
-            				    $values['base'] = $line[4];
335
-            				    $values['owner'] = $line[5];
336
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
337
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
338
-					    $values['cancel'] = $line[7];
329
+						while (!feof($fh)) {
330
+							$line = fgetcsv($fh,9999,',','"');
331
+							//print_r($line);
332
+							if ($country == 'F') {
333
+								$values['registration'] = $line[0];
334
+								$values['base'] = $line[4];
335
+								$values['owner'] = $line[5];
336
+								if ($line[6] == '') $values['date_first_reg'] = null;
337
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
338
+						$values['cancel'] = $line[7];
339 339
 					} elseif ($country == 'EI') {
340
-					    // TODO : add modeS & reg to aircraft_modes
341
-            				    $values['registration'] = $line[0];
342
-            				    $values['base'] = $line[3];
343
-            				    $values['owner'] = $line[2];
344
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
345
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
346
-					    $values['cancel'] = '';
340
+						// TODO : add modeS & reg to aircraft_modes
341
+								$values['registration'] = $line[0];
342
+								$values['base'] = $line[3];
343
+								$values['owner'] = $line[2];
344
+								if ($line[1] == '') $values['date_first_reg'] = null;
345
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
346
+						$values['cancel'] = '';
347 347
 					} elseif ($country == 'HB') {
348
-					    // TODO : add modeS & reg to aircraft_modes
349
-            				    $values['registration'] = $line[0];
350
-            				    $values['base'] = null;
351
-            				    $values['owner'] = $line[5];
352
-            				    $values['date_first_reg'] = null;
353
-					    $values['cancel'] = '';
348
+						// TODO : add modeS & reg to aircraft_modes
349
+								$values['registration'] = $line[0];
350
+								$values['base'] = null;
351
+								$values['owner'] = $line[5];
352
+								$values['date_first_reg'] = null;
353
+						$values['cancel'] = '';
354 354
 					} elseif ($country == 'OK') {
355
-					    // TODO : add modeS & reg to aircraft_modes
356
-            				    $values['registration'] = $line[3];
357
-            				    $values['base'] = null;
358
-            				    $values['owner'] = $line[5];
359
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
360
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
361
-					    $values['cancel'] = '';
355
+						// TODO : add modeS & reg to aircraft_modes
356
+								$values['registration'] = $line[3];
357
+								$values['base'] = null;
358
+								$values['owner'] = $line[5];
359
+								if ($line[18] == '') $values['date_first_reg'] = null;
360
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
361
+						$values['cancel'] = '';
362 362
 					} elseif ($country == 'VH') {
363
-					    // TODO : add modeS & reg to aircraft_modes
364
-            				    $values['registration'] = $line[0];
365
-            				    $values['base'] = null;
366
-            				    $values['owner'] = $line[12];
367
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
368
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
369
-
370
-					    $values['cancel'] = $line[39];
363
+						// TODO : add modeS & reg to aircraft_modes
364
+								$values['registration'] = $line[0];
365
+								$values['base'] = null;
366
+								$values['owner'] = $line[12];
367
+								if ($line[28] == '') $values['date_first_reg'] = null;
368
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
369
+
370
+						$values['cancel'] = $line[39];
371 371
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
372
-            				    $values['registration'] = $line[0];
373
-            				    $values['base'] = null;
374
-            				    $values['owner'] = $line[4];
375
-            				    $values['date_first_reg'] = null;
376
-					    $values['cancel'] = '';
372
+								$values['registration'] = $line[0];
373
+								$values['base'] = null;
374
+								$values['owner'] = $line[4];
375
+								$values['date_first_reg'] = null;
376
+						$values['cancel'] = '';
377 377
 					} elseif ($country == 'CC') {
378
-            				    $values['registration'] = $line[0];
379
-            				    $values['base'] = null;
380
-            				    $values['owner'] = $line[6];
381
-            				    $values['date_first_reg'] = null;
382
-					    $values['cancel'] = '';
378
+								$values['registration'] = $line[0];
379
+								$values['base'] = null;
380
+								$values['owner'] = $line[6];
381
+								$values['date_first_reg'] = null;
382
+						$values['cancel'] = '';
383 383
 					} elseif ($country == 'HJ') {
384
-            				    $values['registration'] = $line[0];
385
-            				    $values['base'] = null;
386
-            				    $values['owner'] = $line[8];
387
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
388
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
389
-					    $values['cancel'] = '';
384
+								$values['registration'] = $line[0];
385
+								$values['base'] = null;
386
+								$values['owner'] = $line[8];
387
+								if ($line[7] == '') $values['date_first_reg'] = null;
388
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
389
+						$values['cancel'] = '';
390 390
 					} elseif ($country == 'PP') {
391
-            				    $values['registration'] = $line[0];
392
-            				    $values['base'] = null;
393
-            				    $values['owner'] = $line[4];
394
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
395
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
396
-					    $values['cancel'] = $line[7];
391
+								$values['registration'] = $line[0];
392
+								$values['base'] = null;
393
+								$values['owner'] = $line[4];
394
+								if ($line[6] == '') $values['date_first_reg'] = null;
395
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
396
+						$values['cancel'] = $line[7];
397 397
 					} elseif ($country == 'E7') {
398
-            				    $values['registration'] = $line[0];
399
-            				    $values['base'] = null;
400
-            				    $values['owner'] = $line[4];
401
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
402
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
403
-					    $values['cancel'] = '';
398
+								$values['registration'] = $line[0];
399
+								$values['base'] = null;
400
+								$values['owner'] = $line[4];
401
+								if ($line[5] == '') $values['date_first_reg'] = null;
402
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
403
+						$values['cancel'] = '';
404 404
 					} elseif ($country == '8Q') {
405
-            				    $values['registration'] = $line[0];
406
-            				    $values['base'] = null;
407
-            				    $values['owner'] = $line[3];
408
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
409
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
410
-					    $values['cancel'] = '';
405
+								$values['registration'] = $line[0];
406
+								$values['base'] = null;
407
+								$values['owner'] = $line[3];
408
+								if ($line[7] == '') $values['date_first_reg'] = null;
409
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
410
+						$values['cancel'] = '';
411 411
 					} elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') {
412
-            				    $values['registration'] = $line[0];
413
-            				    $values['base'] = null;
414
-            				    $values['owner'] = $line[3];
415
-            				    $values['date_first_reg'] = null;
416
-					    $values['cancel'] = '';
412
+								$values['registration'] = $line[0];
413
+								$values['base'] = null;
414
+								$values['owner'] = $line[3];
415
+								$values['date_first_reg'] = null;
416
+						$values['cancel'] = '';
417 417
 					}
418 418
 					if ($values['cancel'] == '' && $values['registration'] != null) {
419 419
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -535,20 +535,20 @@  discard block
 block discarded – undo
535 535
 		try {
536 536
 			$Connection = new Connection();
537 537
 			$sth = $Connection->db->prepare($query);
538
-                        $sth->execute();
539
-                } catch(PDOException $e) {
540
-                        return "error : ".$e->getMessage();
541
-                }
538
+						$sth->execute();
539
+				} catch(PDOException $e) {
540
+						return "error : ".$e->getMessage();
541
+				}
542 542
 
543 543
 
544 544
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
545 545
 		try {
546 546
 			$Connection = new Connection();
547 547
 			$sth = $Connection->db->prepare($query);
548
-                        $sth->execute();
549
-                } catch(PDOException $e) {
550
-                        return "error : ".$e->getMessage();
551
-                }
548
+						$sth->execute();
549
+				} catch(PDOException $e) {
550
+						return "error : ".$e->getMessage();
551
+				}
552 552
 
553 553
 		$query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`)
554 554
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
@@ -614,10 +614,10 @@  discard block
 block discarded – undo
614 614
 		try {
615 615
 			$Connection = new Connection();
616 616
 			$sth = $Connection->db->prepare($query);
617
-                        $sth->execute();
618
-                } catch(PDOException $e) {
619
-                        return "error : ".$e->getMessage();
620
-                }
617
+						$sth->execute();
618
+				} catch(PDOException $e) {
619
+						return "error : ".$e->getMessage();
620
+				}
621 621
 
622 622
 
623 623
 		if ($globalDebug) echo "Insert Not available Airport...\n";
@@ -627,10 +627,10 @@  discard block
 block discarded – undo
627 627
 		try {
628 628
 			$Connection = new Connection();
629 629
 			$sth = $Connection->db->prepare($query);
630
-                        $sth->execute($query_values);
631
-                } catch(PDOException $e) {
632
-                        return "error : ".$e->getMessage();
633
-                }
630
+						$sth->execute($query_values);
631
+				} catch(PDOException $e) {
632
+						return "error : ".$e->getMessage();
633
+				}
634 634
 		$i++;
635 635
 /*
636 636
 		$query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)';
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 
745 745
 
746 746
 
747
-                return "success";
747
+				return "success";
748 748
 	}
749 749
 	
750 750
 	public static function translation() {
@@ -760,10 +760,10 @@  discard block
 block discarded – undo
760 760
 		try {
761 761
 			$Connection = new Connection();
762 762
 			$sth = $Connection->db->prepare($query);
763
-                        $sth->execute(array(':source' => 'translation.csv'));
764
-                } catch(PDOException $e) {
765
-                        return "error : ".$e->getMessage();
766
-                }
763
+						$sth->execute(array(':source' => 'translation.csv'));
764
+				} catch(PDOException $e) {
765
+						return "error : ".$e->getMessage();
766
+				}
767 767
 
768 768
 		
769 769
 		//update_db::unzip($out_file);
@@ -782,21 +782,21 @@  discard block
 block discarded – undo
782 782
 					$data = $row;
783 783
 					$operator = $data[2];
784 784
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
785
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
786
-                                                //echo substr($operator, 0, 2)."\n";;
787
-                                                if (count($airline_array) > 0) {
785
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
786
+												//echo substr($operator, 0, 2)."\n";;
787
+												if (count($airline_array) > 0) {
788 788
 							//print_r($airline_array);
789 789
 							$operator = $airline_array[0]['icao'].substr($operator,2);
790
-                                                }
791
-                                        }
790
+												}
791
+										}
792 792
 					
793 793
 					$operator_correct = $data[3];
794 794
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
795
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
796
-                                                if (count($airline_array) > 0) {
797
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
798
-                                            	}
799
-                                        }
795
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
796
+												if (count($airline_array) > 0) {
797
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
798
+												}
799
+										}
800 800
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
801 801
 					try {
802 802
 						$sth = $Connection->db->prepare($query);
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 			//$Connection->db->commit();
811 811
 		}
812 812
 		return '';
813
-        }
813
+		}
814 814
 	
815 815
 	public static function translation_fam() {
816 816
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -820,10 +820,10 @@  discard block
 block discarded – undo
820 820
 		try {
821 821
 			$Connection = new Connection();
822 822
 			$sth = $Connection->db->prepare($query);
823
-                        $sth->execute(array(':source' => 'website_fam'));
824
-                } catch(PDOException $e) {
825
-                        return "error : ".$e->getMessage();
826
-                }
823
+						$sth->execute(array(':source' => 'website_fam'));
824
+				} catch(PDOException $e) {
825
+						return "error : ".$e->getMessage();
826
+				}
827 827
 
828 828
 		
829 829
 		//update_db::unzip($out_file);
@@ -852,54 +852,54 @@  discard block
 block discarded – undo
852 852
 			//$Connection->db->commit();
853 853
 		}
854 854
 		return '';
855
-        }
855
+		}
856 856
 
857 857
 	/**
858
-        * Convert a HTML table to an array
859
-        * @param String $data HTML page
860
-        * @return Array array of the tables in HTML page
861
-        */
862
-        private static function table2array($data) {
863
-                $html = str_get_html($data);
864
-                $tabledata=array();
865
-                foreach($html->find('tr') as $element)
866
-                {
867
-                        $td = array();
868
-                        foreach( $element->find('th') as $row)
869
-                        {
870
-                                $td [] = trim($row->plaintext);
871
-                        }
872
-                        $td=array_filter($td);
873
-                        $tabledata[] = $td;
874
-
875
-                        $td = array();
876
-                        $tdi = array();
877
-                        foreach( $element->find('td') as $row)
878
-                        {
879
-                                $td [] = trim($row->plaintext);
880
-                                $tdi [] = trim($row->innertext);
881
-                        }
882
-                        $td=array_filter($td);
883
-                        $tdi=array_filter($tdi);
884
-                    //    $tabledata[]=array_merge($td,$tdi);
885
-                        $tabledata[]=$td;
886
-                }
887
-                return(array_filter($tabledata));
888
-        }
889
-
890
-       /**
891
-        * Get data from form result
892
-        * @param String $url form URL
893
-        * @return String the result
894
-        */
895
-        private static function getData($url) {
896
-                $ch = curl_init();
897
-                curl_setopt($ch, CURLOPT_URL, $url);
898
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
899
-                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
900
-                curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
901
-                return curl_exec($ch);
902
-        }
858
+	 * Convert a HTML table to an array
859
+	 * @param String $data HTML page
860
+	 * @return Array array of the tables in HTML page
861
+	 */
862
+		private static function table2array($data) {
863
+				$html = str_get_html($data);
864
+				$tabledata=array();
865
+				foreach($html->find('tr') as $element)
866
+				{
867
+						$td = array();
868
+						foreach( $element->find('th') as $row)
869
+						{
870
+								$td [] = trim($row->plaintext);
871
+						}
872
+						$td=array_filter($td);
873
+						$tabledata[] = $td;
874
+
875
+						$td = array();
876
+						$tdi = array();
877
+						foreach( $element->find('td') as $row)
878
+						{
879
+								$td [] = trim($row->plaintext);
880
+								$tdi [] = trim($row->innertext);
881
+						}
882
+						$td=array_filter($td);
883
+						$tdi=array_filter($tdi);
884
+					//    $tabledata[]=array_merge($td,$tdi);
885
+						$tabledata[]=$td;
886
+				}
887
+				return(array_filter($tabledata));
888
+		}
889
+
890
+	   /**
891
+	    * Get data from form result
892
+	    * @param String $url form URL
893
+	    * @return String the result
894
+	    */
895
+		private static function getData($url) {
896
+				$ch = curl_init();
897
+				curl_setopt($ch, CURLOPT_URL, $url);
898
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
899
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
900
+				curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
901
+				return curl_exec($ch);
902
+		}
903 903
 /*
904 904
 	public static function waypoints() {
905 905
 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html');
@@ -949,10 +949,10 @@  discard block
 block discarded – undo
949 949
 		try {
950 950
 			$Connection = new Connection();
951 951
 			$sth = $Connection->db->prepare($query);
952
-                        $sth->execute();
953
-                } catch(PDOException $e) {
954
-                        return "error : ".$e->getMessage();
955
-                }
952
+						$sth->execute();
953
+				} catch(PDOException $e) {
954
+						return "error : ".$e->getMessage();
955
+				}
956 956
 
957 957
 		
958 958
 		//update_db::unzip($out_file);
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
 			if ($globalTransaction) $Connection->db->commit();
994 994
 		}
995 995
 		return '';
996
-        }
996
+		}
997 997
 
998 998
 	public static function ivao_airlines($filename) {
999 999
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1002,10 +1002,10 @@  discard block
 block discarded – undo
1002 1002
 		try {
1003 1003
 			$Connection = new Connection();
1004 1004
 			$sth = $Connection->db->prepare($query);
1005
-                        $sth->execute();
1006
-                } catch(PDOException $e) {
1007
-                        return "error : ".$e->getMessage();
1008
-                }
1005
+						$sth->execute();
1006
+				} catch(PDOException $e) {
1007
+						return "error : ".$e->getMessage();
1008
+				}
1009 1009
 
1010 1010
 		$header = NULL;
1011 1011
 		$delimiter = ':';
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
 			if ($globalTransaction) $Connection->db->commit();
1030 1030
 		}
1031 1031
 		return '';
1032
-        }
1032
+		}
1033 1033
 	
1034 1034
 	public static function update_airspace() {
1035 1035
 		global $tmp_dir, $globalDBdriver;
@@ -1065,10 +1065,10 @@  discard block
 block discarded – undo
1065 1065
 			$query = 'DROP TABLE countries';
1066 1066
 			try {
1067 1067
 				$sth = $Connection->db->prepare($query);
1068
-            	        	$sth->execute();
1069
-	                } catch(PDOException $e) {
1070
-    	                	echo "error : ".$e->getMessage();
1071
-	                }
1068
+							$sth->execute();
1069
+					} catch(PDOException $e) {
1070
+							echo "error : ".$e->getMessage();
1071
+					}
1072 1072
 		}
1073 1073
 		if ($globalDBdriver == 'mysql') {
1074 1074
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -1413,12 +1413,12 @@  discard block
 block discarded – undo
1413 1413
 		echo $data;
1414 1414
 		*/
1415 1415
 		if (file_exists($tmp_dir.'aircrafts.html')) {
1416
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1417
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
1418
-		    $result = fread($fh,100000000);
1419
-		    //echo $result;
1420
-		    //var_dump(str_get_html($result));
1421
-		    //print_r(self::table2array($result));
1416
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
1417
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
1418
+			$result = fread($fh,100000000);
1419
+			//echo $result;
1420
+			//var_dump(str_get_html($result));
1421
+			//print_r(self::table2array($result));
1422 1422
 		}
1423 1423
 
1424 1424
 	}
@@ -1432,10 +1432,10 @@  discard block
 block discarded – undo
1432 1432
 		try {
1433 1433
 			$Connection = new Connection();
1434 1434
 			$sth = $Connection->db->prepare($query);
1435
-                        $sth->execute();
1436
-                } catch(PDOException $e) {
1437
-                        return "error : ".$e->getMessage();
1438
-                }
1435
+						$sth->execute();
1436
+				} catch(PDOException $e) {
1437
+						return "error : ".$e->getMessage();
1438
+				}
1439 1439
 
1440 1440
 		$error = '';
1441 1441
 		if ($globalDebug) echo "Notam : Download...";
@@ -1491,8 +1491,8 @@  discard block
 block discarded – undo
1491 1491
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
1492 1492
 					$data['permanent'] = 0;
1493 1493
 				} else {
1494
-				    $data['date_end'] = NULL;
1495
-				    $data['permanent'] = 1;
1494
+					$data['date_end'] = NULL;
1495
+					$data['permanent'] = 1;
1496 1496
 				}
1497 1497
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
1498 1498
 				$NOTAM = new NOTAM();
@@ -1516,13 +1516,13 @@  discard block
 block discarded – undo
1516 1516
 		try {
1517 1517
 			$Connection = new Connection();
1518 1518
 			$sth = $Connection->db->prepare($query);
1519
-                        $sth->execute();
1520
-                } catch(PDOException $e) {
1521
-                        return "error : ".$e->getMessage();
1522
-                }
1523
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
1524
-                if ($row['nb'] > 0) return false;
1525
-                else return true;
1519
+						$sth->execute();
1520
+				} catch(PDOException $e) {
1521
+						return "error : ".$e->getMessage();
1522
+				}
1523
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
1524
+				if ($row['nb'] > 0) return false;
1525
+				else return true;
1526 1526
 	}
1527 1527
 
1528 1528
 	public static function insert_last_update() {
@@ -1531,10 +1531,10 @@  discard block
 block discarded – undo
1531 1531
 		try {
1532 1532
 			$Connection = new Connection();
1533 1533
 			$sth = $Connection->db->prepare($query);
1534
-                        $sth->execute();
1535
-                } catch(PDOException $e) {
1536
-                        return "error : ".$e->getMessage();
1537
-                }
1534
+						$sth->execute();
1535
+				} catch(PDOException $e) {
1536
+						return "error : ".$e->getMessage();
1537
+				}
1538 1538
 	}
1539 1539
 
1540 1540
 	public static function check_last_notam_update() {
@@ -1547,13 +1547,13 @@  discard block
 block discarded – undo
1547 1547
 		try {
1548 1548
 			$Connection = new Connection();
1549 1549
 			$sth = $Connection->db->prepare($query);
1550
-                        $sth->execute();
1551
-                } catch(PDOException $e) {
1552
-                        return "error : ".$e->getMessage();
1553
-                }
1554
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
1555
-                if ($row['nb'] > 0) return false;
1556
-                else return true;
1550
+						$sth->execute();
1551
+				} catch(PDOException $e) {
1552
+						return "error : ".$e->getMessage();
1553
+				}
1554
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
1555
+				if ($row['nb'] > 0) return false;
1556
+				else return true;
1557 1557
 	}
1558 1558
 
1559 1559
 	public static function insert_last_notam_update() {
@@ -1562,10 +1562,10 @@  discard block
 block discarded – undo
1562 1562
 		try {
1563 1563
 			$Connection = new Connection();
1564 1564
 			$sth = $Connection->db->prepare($query);
1565
-                        $sth->execute();
1566
-                } catch(PDOException $e) {
1567
-                        return "error : ".$e->getMessage();
1568
-                }
1565
+						$sth->execute();
1566
+				} catch(PDOException $e) {
1567
+						return "error : ".$e->getMessage();
1568
+				}
1569 1569
 	}
1570 1570
 
1571 1571
 	public static function check_last_owner_update() {
@@ -1578,13 +1578,13 @@  discard block
 block discarded – undo
1578 1578
 		try {
1579 1579
 			$Connection = new Connection();
1580 1580
 			$sth = $Connection->db->prepare($query);
1581
-                        $sth->execute();
1582
-                } catch(PDOException $e) {
1583
-                        return "error : ".$e->getMessage();
1584
-                }
1585
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
1586
-                if ($row['nb'] > 0) return false;
1587
-                else return true;
1581
+						$sth->execute();
1582
+				} catch(PDOException $e) {
1583
+						return "error : ".$e->getMessage();
1584
+				}
1585
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
1586
+				if ($row['nb'] > 0) return false;
1587
+				else return true;
1588 1588
 	}
1589 1589
 
1590 1590
 	public static function insert_last_owner_update() {
@@ -1593,10 +1593,10 @@  discard block
 block discarded – undo
1593 1593
 		try {
1594 1594
 			$Connection = new Connection();
1595 1595
 			$sth = $Connection->db->prepare($query);
1596
-                        $sth->execute();
1597
-                } catch(PDOException $e) {
1598
-                        return "error : ".$e->getMessage();
1599
-                }
1596
+						$sth->execute();
1597
+				} catch(PDOException $e) {
1598
+						return "error : ".$e->getMessage();
1599
+				}
1600 1600
 	}
1601 1601
 	
1602 1602
 	public static function update_all() {
Please login to merge, or discard this patch.
install/libs/sparqllib.php 1 patch
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -13,6 +13,9 @@  discard block
 block discarded – undo
13 13
 function sparql_connect( $endpoint ) { return new sparql_connection( $endpoint ); }
14 14
 
15 15
 function sparql_ns( $short, $long, $db = null ) { return _sparql_a_connection( $db )->ns( $short, $long ); }
16
+/**
17
+ * @param string $sparql
18
+ */
16 19
 function sparql_query( $sparql, $db = null ) { return _sparql_a_connection( $db )->query( $sparql ); }
17 20
 function sparql_errno( $db = null ) { return _sparql_a_connection( $db )->errno(); }
18 21
 function sparql_error( $db = null ) { return _sparql_a_connection( $db )->error(); }
@@ -84,6 +87,9 @@  discard block
 block discarded – undo
84 87
 		$this->params = $params;
85 88
 	}
86 89
 
90
+	/**
91
+	 * @param integer $timeout
92
+	 */
87 93
 	function query( $query, $timeout=null )
88 94
 	{	
89 95
 		$prefixes = "";
@@ -324,6 +330,10 @@  discard block
 block discarded – undo
324 330
 	var $fields;
325 331
 	var $db;
326 332
 	var $i = 0;
333
+
334
+	/**
335
+	 * @param sparql_connection $db
336
+	 */
327 337
 	function __construct( $db, $rows, $fields )
328 338
 	{
329 339
 		$this->rows = $rows;
Please login to merge, or discard this patch.
require/class.ACARS.php 2 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -809,8 +809,6 @@
 block discarded – undo
809 809
 	/**
810 810
 	* Get Message title from label from DB
811 811
 	*
812
-	* @param String $ident
813
-	* @return Array Return ACARS data in array
814 812
 	*/
815 813
 	public function getTitlefromLabel($label) {
816 814
 		$Connection = new Connection($this->db);
Please login to merge, or discard this patch.
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
 	function parse($data) {
94 94
 		global $globalDebug, $globalACARSArchive;
95 95
 		$Image = new Image($this->db);
@@ -660,11 +660,11 @@  discard block
 block discarded – undo
660 660
 
661 661
 
662 662
 	/**
663
-	* Add ACARS data
664
-	*
665
-	* @param String ACARS data in acarsdec data
666
-	*
667
-	*/
663
+	 * Add ACARS data
664
+	 *
665
+	 * @param String ACARS data in acarsdec data
666
+	 *
667
+	 */
668 668
 	function add($data) {
669 669
 		global $globalDebug, $globalACARSArchive;
670 670
 		$Image = new Image($this->db);
@@ -719,15 +719,15 @@  discard block
 block discarded – undo
719 719
 	}
720 720
 
721 721
 	/**
722
-	* Add Live ACARS data in DB
723
-	*
724
-	* @param String $ident ident
725
-	* @param String $registration Registration of the aircraft
726
-	* @param String $label Label of the ACARS message
727
-	* @param String $block_id Block id of the ACARS message
728
-	* @param String $msg_no Number of the ACARS message
729
-	* @param String $message ACARS message
730
-	*/
722
+	 * Add Live ACARS data in DB
723
+	 *
724
+	 * @param String $ident ident
725
+	 * @param String $registration Registration of the aircraft
726
+	 * @param String $label Label of the ACARS message
727
+	 * @param String $block_id Block id of the ACARS message
728
+	 * @param String $msg_no Number of the ACARS message
729
+	 * @param String $message ACARS message
730
+	 */
731 731
 	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
732 732
 		global $globalDebug;
733 733
 		date_default_timezone_set('UTC');
@@ -765,15 +765,15 @@  discard block
 block discarded – undo
765 765
 	}
766 766
 
767 767
 	/**
768
-	* Add Archive ACARS data in DB
769
-	*
770
-	* @param String $ident ident
771
-	* @param String $registration Registration of the aircraft
772
-	* @param String $label Label of the ACARS message
773
-	* @param String $block_id Block id of the ACARS message
774
-	* @param String $msg_no Number of the ACARS message
775
-	* @param String $message ACARS message
776
-	*/
768
+	 * Add Archive ACARS data in DB
769
+	 *
770
+	 * @param String $ident ident
771
+	 * @param String $registration Registration of the aircraft
772
+	 * @param String $label Label of the ACARS message
773
+	 * @param String $block_id Block id of the ACARS message
774
+	 * @param String $msg_no Number of the ACARS message
775
+	 * @param String $message ACARS message
776
+	 */
777 777
 	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
778 778
 		global $globalDebug;
779 779
 		date_default_timezone_set('UTC');
@@ -807,11 +807,11 @@  discard block
 block discarded – undo
807 807
 	}
808 808
 
809 809
 	/**
810
-	* Get Message title from label from DB
811
-	*
812
-	* @param String $ident
813
-	* @return Array Return ACARS data in array
814
-	*/
810
+	 * Get Message title from label from DB
811
+	 *
812
+	 * @param String $ident
813
+	 * @return Array Return ACARS data in array
814
+	 */
815 815
 	public function getTitlefromLabel($label) {
816 816
 		$Connection = new Connection($this->db);
817 817
 		$this->db = $Connection->db;
@@ -830,10 +830,10 @@  discard block
 block discarded – undo
830 830
 	}
831 831
 
832 832
 	/**
833
-	* List all Message title & label from DB
834
-	*
835
-	* @return Array Return ACARS data in array
836
-	*/
833
+	 * List all Message title & label from DB
834
+	 *
835
+	 * @return Array Return ACARS data in array
836
+	 */
837 837
 	public function getAllTitleLabel() {
838 838
 		$query = "SELECT * FROM acars_label ORDER BY title";
839 839
 		$query_values = array();
@@ -850,11 +850,11 @@  discard block
 block discarded – undo
850 850
 	}
851 851
 
852 852
 	/**
853
-	* Get Live ACARS data from DB
854
-	*
855
-	* @param String $ident
856
-	* @return Array Return ACARS data in array
857
-	*/
853
+	 * Get Live ACARS data from DB
854
+	 *
855
+	 * @param String $ident
856
+	 * @return Array Return ACARS data in array
857
+	 */
858 858
 	public function getLiveAcarsData($ident) {
859 859
 		$query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC";
860 860
 		$query_values = array(':ident' => $ident);
@@ -871,10 +871,10 @@  discard block
 block discarded – undo
871 871
 	}
872 872
 
873 873
 	/**
874
-	* Get Latest ACARS data from DB
875
-	*
876
-	* @return Array Return ACARS data in array
877
-	*/
874
+	 * Get Latest ACARS data from DB
875
+	 *
876
+	 * @return Array Return ACARS data in array
877
+	 */
878 878
 	public function getLatestAcarsData($limit = '',$label = '') {
879 879
 		global $globalURL, $globalDBdriver;
880 880
 		$Image = new Image($this->db);
@@ -972,10 +972,10 @@  discard block
 block discarded – undo
972 972
 	}
973 973
 
974 974
 	/**
975
-	* Get Archive ACARS data from DB
976
-	*
977
-	* @return Array Return ACARS data in array
978
-	*/
975
+	 * Get Archive ACARS data from DB
976
+	 *
977
+	 * @return Array Return ACARS data in array
978
+	 */
979 979
 	public function getArchiveAcarsData($limit = '',$label = '') {
980 980
 		global $globalURL, $globalDBdriver;
981 981
 		$Image = new Image($this->db);
@@ -1077,13 +1077,13 @@  discard block
 block discarded – undo
1077 1077
 	}
1078 1078
 
1079 1079
 	/**
1080
-	* Add ModeS data to DB
1081
-	*
1082
-	* @param String $ident ident
1083
-	* @param String $registration Registration of the aircraft
1084
-	* @param String $icao
1085
-	* @param String $ICAOTypeCode
1086
-	*/
1080
+	 * Add ModeS data to DB
1081
+	 *
1082
+	 * @param String $ident ident
1083
+	 * @param String $registration Registration of the aircraft
1084
+	 * @param String $icao
1085
+	 * @param String $ICAOTypeCode
1086
+	 */
1087 1087
 	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1088 1088
 		global $globalDebug, $globalDBdriver;
1089 1089
 		$ident = trim($ident);
Please login to merge, or discard this patch.
require/class.APRS.php 2 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -1,5 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 class aprs {
3
+
4
+    /**
5
+     * @param integer $n
6
+     * @param integer $s
7
+     */
3 8
     private function urshift($n, $s) {
4 9
 	return ($n >= 0) ? ($n >> $s) :
5 10
     	    (($n & 0x7fffffff) >> $s) | 
Please login to merge, or discard this patch.
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class aprs {
3
-    private function urshift($n, $s) {
3
+	private function urshift($n, $s) {
4 4
 	return ($n >= 0) ? ($n >> $s) :
5
-    	    (($n & 0x7fffffff) >> $s) | 
6
-        	(0x40000000 >> ($s - 1));
7
-    }
5
+			(($n & 0x7fffffff) >> $s) | 
6
+			(0x40000000 >> ($s - 1));
7
+	}
8 8
 
9
-    public function parse($input) {
9
+	public function parse($input) {
10 10
 	$debug = false;
11 11
 	$result = array();
12 12
 	$input_len = strlen($input);
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	
18 18
 	/* Check that end was found and body has at least one byte. */
19 19
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
20
-	    echo 'invalid';
21
-	    return false;
20
+		echo 'invalid';
21
+		return false;
22 22
 	}
23 23
 	
24 24
 	/* Save header and body. */
@@ -31,44 +31,44 @@  discard block
 block discarded – undo
31 31
 	/* Parse source, target and path. */
32 32
 	//FLRDF0A52>APRS,qAS,LSTB
33 33
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
34
-	    $ident = $matches[1];
35
-	    $all_elements = $matches[2];
36
-	    if ($debug) echo 'ident : '.$ident."\n";
37
-	    $result['ident'] = $ident;
34
+		$ident = $matches[1];
35
+		$all_elements = $matches[2];
36
+		if ($debug) echo 'ident : '.$ident."\n";
37
+		$result['ident'] = $ident;
38 38
 	} else return false;
39 39
 	$elements = explode(',',$all_elements);
40 40
 	$source = end($elements);
41 41
 	$result['source'] = $source;
42 42
 	foreach ($elements as $element) {
43
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
44
-	        //echo "ok";
45
-	        if ($element == 'TCPIP*') return false;
46
-	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
43
+		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
44
+			//echo "ok";
45
+			if ($element == 'TCPIP*') return false;
46
+		} elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
47 47
 		//echo "ok";
48
-	    } else {
49
-	        return false;
50
-	    }
48
+		} else {
49
+			return false;
50
+		}
51 51
 	}
52 52
 	// Check for Timestamp
53 53
 	$body_parse = substr($body,1);
54 54
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
55
-	    $timestamp = $matches[0];
56
-	    if ($matches[4] == 'h') {
55
+		$timestamp = $matches[0];
56
+		if ($matches[4] == 'h') {
57 57
 		$timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]);
58 58
 		//echo 'timestamp : '.$timestamp.' - now : '.time()."\n";
59 59
 		/*
60 60
 		if (time() + 3900 < $timestamp) $timestamp -= 86400;
61 61
 		elseif (time() - 82500 > $timestamp) $timestamp += 86400;
62 62
 		*/
63
-	    } elseif ($matches[4] == 'z' || $matches[4] == '/') {
63
+		} elseif ($matches[4] == 'z' || $matches[4] == '/') {
64 64
 		// FIXME : fix this...
65 65
 		$timestamp = strtotime($matches[1].' '.$matches[2].':'.$matches[3]);
66
-	    }
67
-	    $body_parse = substr($body_parse,7);
68
-	    $result['timestamp'] = $timestamp;
66
+		}
67
+		$body_parse = substr($body_parse,7);
68
+		$result['timestamp'] = $timestamp;
69 69
 	}
70 70
 	if (strlen($body_parse) > 19) {
71
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
71
+		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
72 72
 		// 4658.70N/00707.78Ez
73 73
 		//print_r(str_split($body_parse));
74 74
 		$latlon = $matches[0];
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		$lon = intval($lon_deg);
85 85
 		if ($lat > 89 || $lon > 179) return false;
86 86
 	    
87
-	    /*
87
+		/*
88 88
 	    $tmp_5b = str_replace('.','',$lat_min);
89 89
 	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
90 90
 	        print_r($matches);
@@ -96,58 +96,58 @@  discard block
 block discarded – undo
96 96
 		if ($wind == 'W') $longitude = 0-$longitude;
97 97
 		$result['latitude'] = $latitude;
98 98
 		$result['longitude'] = $longitude;
99
-	    }
100
-	    if ($body_len > 19) {
99
+		}
100
+		if ($body_len > 19) {
101 101
 		$body_split = str_split($body_parse);
102 102
 		$symbol_code = $body_split[18];
103 103
 		if ($symbol_code != '_') {
104
-		    $body_parse = substr($body_parse,19);
105
-		    $body_parse_len = strlen($body_parse);
106
-		    if ($body_parse_len >= 7) {
104
+			$body_parse = substr($body_parse,19);
105
+			$body_parse_len = strlen($body_parse);
106
+			if ($body_parse_len >= 7) {
107 107
 			
108
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
109
-		    	    $course = substr($body_parse,0,3);
110
-		    	    $tmp_s = intval($course);
111
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['course'] = intval($course);
112
-		    	    $speed = substr($body_parse,4,3);
113
-		    	    $result['speed'] = round($speed*1.852);
114
-		    	    $body_parse = substr($body_parse,7);
115
-		        }
116
-		        // Check PHGR, PHG, RNG
117
-		    } else if ($body_parse_len > 0) {
108
+				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
109
+					$course = substr($body_parse,0,3);
110
+					$tmp_s = intval($course);
111
+					if ($tmp_s >= 1 && $tmp_s <= 360) $result['course'] = intval($course);
112
+					$speed = substr($body_parse,4,3);
113
+					$result['speed'] = round($speed*1.852);
114
+					$body_parse = substr($body_parse,7);
115
+				}
116
+				// Check PHGR, PHG, RNG
117
+			} else if ($body_parse_len > 0) {
118 118
 			$rest = $body_parse;
119
-		    }
120
-		    if (strlen($body_parse) > 0) {
121
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
122
-		            $altitude = intval($matches[1]);
123
-		            $result['altitude'] = round($altitude*0.3048);
124
-		            $body_parse = substr($body_parse,strlen($matches[0])+1);
125
-		        }
126
-		    }
119
+			}
120
+			if (strlen($body_parse) > 0) {
121
+				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
122
+					$altitude = intval($matches[1]);
123
+					$result['altitude'] = round($altitude*0.3048);
124
+					$body_parse = substr($body_parse,strlen($matches[0])+1);
125
+				}
126
+			}
127 127
 		    
128
-		    // Telemetry
129
-		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
130
-		        // Nothing yet...
131
-		    }
132
-		    // DAO
133
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
134
-			    $dao = $matches[1];
135
-			    $dao_split = str_split($dao);
136
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
137
-			        $lat_off = (($dao[1])-48.0)*0.001/60.0;
138
-			        $lon_off = (($dao[2])-48.0)*0.001/60.0;
128
+			// Telemetry
129
+			if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
130
+				// Nothing yet...
131
+			}
132
+			// DAO
133
+			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
134
+				$dao = $matches[1];
135
+				$dao_split = str_split($dao);
136
+				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
137
+					$lat_off = (($dao[1])-48.0)*0.001/60.0;
138
+					$lon_off = (($dao[2])-48.0)*0.001/60.0;
139 139
 			    
140
-			    }
141
-			    if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
142
-			    else $result['latitude'] += $lat_off;
143
-			    if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
144
-			    else $result['longitude'] += $lon_off;
145
-		            $body_parse = substr($body_parse,6);
146
-		    }
140
+				}
141
+				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
142
+				else $result['latitude'] += $lat_off;
143
+				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
144
+				else $result['longitude'] += $lon_off;
145
+					$body_parse = substr($body_parse,6);
146
+			}
147 147
 		    
148
-		    // OGN comment
148
+			// OGN comment
149 149
 		   // echo "Before OGN : ".$body_parse."\n";
150
-		    if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
150
+			if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
151 151
 			$id = $matches[1];
152 152
 			$mode = substr($id,0,2);
153 153
 			$address = substr($id,2);
@@ -177,49 +177,49 @@  discard block
 block discarded – undo
177 177
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
178 178
 			$result['stealth'] = $stealth;
179 179
 			$result['address'] = $address;
180
-		    }
180
+			}
181 181
 		    
182
-		    //Comment
183
-		    $result['comment'] = $body_parse;
182
+			//Comment
183
+			$result['comment'] = $body_parse;
184 184
 		} else {
185
-		    // parse weather
186
-		    $body_parse = substr($body_parse,19);
187
-		    $body_parse_len = strlen($body_parse);
185
+			// parse weather
186
+			$body_parse = substr($body_parse,19);
187
+			$body_parse_len = strlen($body_parse);
188 188
 
189
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
189
+			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
190 190
 			$result['wind_dir'] = $matches[1];
191 191
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
192 192
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
193 193
 			$result['temp'] = round(5/9*(($matches[4])-32),1);
194
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
195
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
194
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
195
+			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
196 196
 			$result['wind_dir'] = $matches[1];
197 197
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
198 198
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
199 199
 			$result['temp'] = round(5/9*(($matches[4])-32),1);
200
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
201
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
200
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
201
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
202 202
 			$result['wind_dir'] = $matches[1];
203 203
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
204 204
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
205
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
206
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
205
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
206
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
207 207
 			$result['wind_dir'] = $matches[1];
208 208
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
209 209
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
210
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
211
-		    }
212
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
210
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
211
+			}
212
+			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
213 213
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
214
-		    }
214
+			}
215
+		}
215 216
 		}
216
-	    }
217 217
 	}
218 218
 	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
219 219
 	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
220 220
 	//print_r($result);
221 221
 	return $result;
222
-    }
222
+	}
223 223
 }
224 224
 /*
225 225
 $aprs = new aprs();
Please login to merge, or discard this patch.
require/class.Common.php 2 patches
Doc Comments   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	* Check is distance realistic
161 161
 	* @param int $timeDifference the time between the reception of both messages
162 162
 	* @param float $distance distance covered
163
-	* @return whether distance is realistic
163
+	* @return boolean distance is realistic
164 164
 	*/
165 165
 	public function withinThreshold ($timeDifference, $distance) {
166 166
 		$x = abs($timeDifference);
@@ -183,6 +183,9 @@  discard block
 block discarded – undo
183 183
 	}
184 184
 
185 185
 
186
+	/**
187
+	 * @param string $latlong
188
+	 */
186 189
 	public function convertDec($dms,$latlong) {
187 190
 		if ($latlong == 'latitude') {
188 191
 			$deg = substr($dms, 0, 2);
@@ -274,7 +277,7 @@  discard block
 block discarded – undo
274 277
 	/**
275 278
 	* Returns list of available locales
276 279
 	*
277
-	* @return array
280
+	* @return string[]
278 281
 	 */
279 282
 	public function listLocaleDir()
280 283
 	{
Please login to merge, or discard this patch.
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 or 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 or 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
 	
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 	}
80 80
 	
81 81
 	/**
82
-	* Convert a HTML table to an array
83
-	* @param String $data HTML page
84
-	* @return Array array of the tables in HTML page
85
-	*/
82
+	 * Convert a HTML table to an array
83
+	 * @param String $data HTML page
84
+	 * @return Array array of the tables in HTML page
85
+	 */
86 86
 	public function table2array($data) {
87 87
 		if (!is_string($data)) return array();
88 88
 		if ($data == '') return array();
@@ -115,10 +115,10 @@  discard block
 block discarded – undo
115 115
 	}
116 116
 	
117 117
 	/**
118
-	* Convert <p> part of a HTML page to an array
119
-	* @param String $data HTML page
120
-	* @return Array array of the <p> in HTML page
121
-	*/
118
+	 * Convert <p> part of a HTML page to an array
119
+	 * @param String $data HTML page
120
+	 * @return Array array of the <p> in HTML page
121
+	 */
122 122
 	public function text2array($data) {
123 123
 		$html = str_get_html($data);
124 124
 		$tabledata=array();
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
 	}
133 133
 
134 134
 	/**
135
-	* Give distance between 2 coordonnates
136
-	* @param Float $lat latitude of first point
137
-	* @param Float $lon longitude of first point
138
-	* @param Float $latc latitude of second point
139
-	* @param Float $lonc longitude of second point
140
-	* @param String $unit km else no unit used
141
-	* @return Float Distance in $unit
142
-	*/
135
+	 * Give distance between 2 coordonnates
136
+	 * @param Float $lat latitude of first point
137
+	 * @param Float $lon longitude of first point
138
+	 * @param Float $latc latitude of second point
139
+	 * @param Float $lonc longitude of second point
140
+	 * @param String $unit km else no unit used
141
+	 * @return Float Distance in $unit
142
+	 */
143 143
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
144 144
 		if ($lat == $latc && $lon == $lonc) return 0;
145 145
 		$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;
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 	}
158 158
 
159 159
 	/**
160
-	* Check is distance realistic
161
-	* @param int $timeDifference the time between the reception of both messages
162
-	* @param float $distance distance covered
163
-	* @return whether distance is realistic
164
-	*/
160
+	 * Check is distance realistic
161
+	 * @param int $timeDifference the time between the reception of both messages
162
+	 * @param float $distance distance covered
163
+	 * @return whether distance is realistic
164
+	 */
165 165
 	public function withinThreshold ($timeDifference, $distance) {
166 166
 		$x = abs($timeDifference);
167 167
 		$d = abs($distance);
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	}
180 180
 
181 181
 	public function isInteger($input){
182
-	    return(ctype_digit(strval($input)));
182
+		return(ctype_digit(strval($input)));
183 183
 	}
184 184
 
185 185
 
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 	}
196 196
 	
197 197
 	/**
198
-	* Copy folder contents
199
-	* @param       string   $source    Source path
200
-	* @param       string   $dest      Destination path
201
-	* @return      bool     Returns true on success, false on failure
202
-	*/
198
+	 * Copy folder contents
199
+	 * @param       string   $source    Source path
200
+	 * @param       string   $dest      Destination path
201
+	 * @return      bool     Returns true on success, false on failure
202
+	 */
203 203
 	public function xcopy($source, $dest, $permissions = 0755)
204 204
 	{
205 205
 		$files = glob($source.'*.*');
@@ -211,20 +211,20 @@  discard block
 block discarded – undo
211 211
 	}
212 212
 	
213 213
 	/**
214
-	* Check if an url exist
215
-	* @param	String $url url to check
216
-	* @return	bool Return true on succes false on failure
217
-	*/
214
+	 * Check if an url exist
215
+	 * @param	String $url url to check
216
+	 * @return	bool Return true on succes false on failure
217
+	 */
218 218
 	public function urlexist($url){
219 219
 		$headers=get_headers($url);
220 220
 		return stripos($headers[0],"200 OK")?true:false;
221 221
 	}
222 222
 	
223 223
 	/**
224
-	* Convert hexa to string
225
-	* @param	String $hex data in hexa
226
-	* @return	String Return result
227
-	*/
224
+	 * Convert hexa to string
225
+	 * @param	String $hex data in hexa
226
+	 * @return	String Return result
227
+	 */
228 228
 	public function hex2str($hex) {
229 229
 		$str = '';
230 230
 		$hexln = strlen($hex);
@@ -272,9 +272,9 @@  discard block
 block discarded – undo
272 272
 	}
273 273
 	
274 274
 	/**
275
-	* Returns list of available locales
276
-	*
277
-	* @return array
275
+	 * Returns list of available locales
276
+	 *
277
+	 * @return array
278 278
 	 */
279 279
 	public function listLocaleDir()
280 280
 	{
Please login to merge, or discard this patch.
require/class.Connection.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -6,6 +6,9 @@  discard block
 block discarded – undo
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 23;
8 8
 	
9
+	/**
10
+	 * @param string $dbname
11
+	 */
9 12
 	public function __construct($dbc = null,$dbname = null) {
10 13
 	    global $globalDBdriver;
11 14
 	    if ($dbc === null) {
@@ -102,6 +105,9 @@  discard block
 block discarded – undo
102 105
 		return true;
103 106
 	}
104 107
 
108
+	/**
109
+	 * @param string $table
110
+	 */
105 111
 	public function tableExists($table)
106 112
 	{
107 113
 		global $globalDBdriver, $globalDBname;
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,18 +7,18 @@  discard block
 block discarded – undo
7 7
 	public $latest_schema = 23;
8 8
 	
9 9
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10
-	    global $globalDBdriver;
11
-	    if ($dbc === null) {
10
+		global $globalDBdriver;
11
+		if ($dbc === null) {
12 12
 		if ($this->db === null && $dbname === null) {
13
-		    if ($user === null && $pass === null) {
13
+			if ($user === null && $pass === null) {
14 14
 			$this->createDBConnection();
15
-		    } else {
15
+			} else {
16 16
 			$this->createDBConnection(null,$user,$pass);
17
-		    }
17
+			}
18 18
 		} else {
19
-		    $this->createDBConnection($dbname);
19
+			$this->createDBConnection($dbname);
20 20
 		}
21
-	    } elseif ($dbname === null || $dbname === 'default') {
21
+		} elseif ($dbname === null || $dbname === 'default') {
22 22
 		$this->db = $dbc;
23 23
 		if ($this->connectionExists() === false) {
24 24
 			/*
@@ -28,19 +28,19 @@  discard block
 block discarded – undo
28 28
 			*/
29 29
 			$this->createDBConnection();
30 30
 		}
31
-	    } else {
31
+		} else {
32 32
 		//$this->connectionExists();
33 33
 		$this->dbs[$dbname] = $dbc;
34
-	    }
34
+		}
35 35
 	}
36 36
 
37 37
 
38 38
 	/**
39
-	* Creates the database connection
40
-	*
41
-	* @return Boolean of the database connection
42
-	*
43
-	*/
39
+	 * Creates the database connection
40
+	 *
41
+	 * @return Boolean of the database connection
42
+	 *
43
+	 */
44 44
 
45 45
 	public function createDBConnection($DBname = null, $user = null, $pass = null)
46 46
 	{
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 			return false;
134 134
 		}
135 135
 		if($results->rowCount()>0) {
136
-		    return true; 
136
+			return true; 
137 137
 		}
138 138
 		else return false;
139 139
 	}
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
 				$sum = $sum->fetchColumn(0);
151 151
 			} else $sum = 0;
152 152
 			if (intval($sum) !== 2) {
153
-			     return false;
153
+				 return false;
154 154
 			}
155 155
 			
156 156
 		} catch(PDOException $e) {
157 157
 			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
158
-            			throw $e;
159
-	                }
160
-	                //echo 'error ! '.$e->getMessage();
158
+						throw $e;
159
+					}
160
+					//echo 'error ! '.$e->getMessage();
161 161
 			return false;
162 162
 		}
163 163
 		return true; 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			return false;
182 182
 		}
183 183
 		if($results->rowCount()>0) {
184
-		    return true; 
184
+			return true; 
185 185
 		}
186 186
 		else return false;
187 187
 	}
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 		$version = 0;
236 236
 		if ($this->tableExists('aircraft')) {
237 237
 			if (!$this->tableExists('config')) {
238
-	    			$version = '1';
239
-	    			return $version;
238
+					$version = '1';
239
+					return $version;
240 240
 			} else {
241 241
 				$Connection = new Connection();
242 242
 				$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 	* @return Boolean if latest version or not
258 258
 	*/
259 259
 	public function latest() {
260
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
261
-	    else return false;
260
+		if ($this->check_schema_version() == $this->latest_schema) return true;
261
+		else return false;
262 262
 	}
263 263
 
264 264
 }
Please login to merge, or discard this patch.
require/class.Image.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -327,6 +327,9 @@
 block discarded – undo
327 327
     }
328 328
 
329 329
 
330
+    /**
331
+     * @param string $aircraft_icao
332
+     */
330 333
     public function fromIvaoMtl($aircraft_icao,$airline_icao) {
331 334
 	$Common = new Common();
332 335
 	//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
Please login to merge, or discard this patch.
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -4,27 +4,27 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/settings.php');
5 5
 
6 6
 class Image {
7
-    public $db;
7
+	public $db;
8 8
 
9
-    function __construct($dbc = null) {
10
-	    $Connection = new Connection($dbc);
11
-            $this->db = $Connection->db;
12
-    }
9
+	function __construct($dbc = null) {
10
+		$Connection = new Connection($dbc);
11
+			$this->db = $Connection->db;
12
+	}
13 13
 
14
-    /**
15
-    * Gets the images based on the aircraft registration
16
-    *
17
-    * @return Array the images list
18
-    *
19
-    */
20
-    public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
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);
25
-	    if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
14
+	/**
15
+	 * Gets the images based on the aircraft registration
16
+	 *
17
+	 * @return Array the images list
18
+	 *
19
+	 */
20
+	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
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);
25
+		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
26 26
 	    
27
-	    $registration = trim($registration);
27
+		$registration = trim($registration);
28 28
 
29 29
 	$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright
30 30
 			FROM spotter_image 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	
34 34
 	$sth = $this->db->prepare($query);
35 35
 	$sth->execute(array(':registration' => $registration));
36
-          /*
36
+		  /*
37 37
         $images_array = array();
38 38
 	$temp_array = array();
39 39
 
@@ -52,36 +52,36 @@  discard block
 block discarded – undo
52 52
         
53 53
         return $images_array;
54 54
         */
55
-        return $sth->fetchAll(PDO::FETCH_ASSOC);
56
-    }
55
+		return $sth->fetchAll(PDO::FETCH_ASSOC);
56
+	}
57 57
 
58
-    /**
59
-    * Gets the image copyright based on the Exif data
60
-    *
61
-    * @return String image copyright
62
-    *
63
-    */
64
-    public function getExifCopyright($url) {
65
-        $exif = exif_read_data($url);
66
-        $copyright = '';
67
-        if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
68
-        elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
69
-        if ($copyright != '') {
70
-    	    $copyright = str_replace('Copyright ','',$copyright);
71
-    	    $copyright = str_replace('© ','',$copyright);
72
-    	    $copyright = str_replace('(c) ','',$copyright);
73
-        }
74
-        return $copyright;
75
-    }
58
+	/**
59
+	 * Gets the image copyright based on the Exif data
60
+	 *
61
+	 * @return String image copyright
62
+	 *
63
+	 */
64
+	public function getExifCopyright($url) {
65
+		$exif = exif_read_data($url);
66
+		$copyright = '';
67
+		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
68
+		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
69
+		if ($copyright != '') {
70
+			$copyright = str_replace('Copyright ','',$copyright);
71
+			$copyright = str_replace('© ','',$copyright);
72
+			$copyright = str_replace('(c) ','',$copyright);
73
+		}
74
+		return $copyright;
75
+	}
76 76
     
77
-    /**
78
-    * Adds the images based on the aircraft registration
79
-    *
80
-    * @return String either success or error
81
-    *
82
-    */
83
-    public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
84
-    {
77
+	/**
78
+	 * Adds the images based on the aircraft registration
79
+	 *
80
+	 * @return String either success or error
81
+	 *
82
+	 */
83
+	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
84
+	{
85 85
 	global $globalAircraftImageFetch;
86 86
 	if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
87 87
 	$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -90,29 +90,29 @@  discard block
 block discarded – undo
90 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
-	    $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
-	    try {
93
+		$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
+		try {
95 95
 		
96 96
 		$sth = $this->db->prepare($query);
97 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) {
98
+		} catch(PDOException $e) {
99 99
 		echo $e->getMessage."\n";
100 100
 		return "error";
101
-	    }
101
+		}
102 102
 	}
103 103
 	return "success";
104
-    }
104
+	}
105 105
     
106 106
     
107
-    /**
108
-    * Gets the aircraft image
109
-    *
110
-    * @param String $aircraft_registration the registration of the aircraft
111
-    * @return Array the aircraft thumbnail, orignal url and copyright
112
-    *
113
-    */
114
-    public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '')
115
-    {
107
+	/**
108
+	 * Gets the aircraft image
109
+	 *
110
+	 * @param String $aircraft_registration the registration of the aircraft
111
+	 * @return Array the aircraft thumbnail, orignal url and copyright
112
+	 *
113
+	 */
114
+	public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '')
115
+	{
116 116
 	global $globalAircraftImageSources, $globalIVAO;
117 117
 	$Spotter = new Spotter($this->db);
118 118
 	if (!isset($globalIVAO)) $globalIVAO = FALSE;
@@ -120,17 +120,17 @@  discard block
 block discarded – undo
120 120
 	
121 121
 	if ($aircraft_registration != '') {
122 122
 	if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
123
-	    $aircraft_registration = urlencode(trim($aircraft_registration));
124
-	    $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
125
-    	    if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
126
-	    else $aircraft_name = '';
127
-	    if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
128
-    	    else $aircraft_icao = '';
129
-    	    if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
130
-    	    else $airline_icao = '';
131
-        } elseif ($aircraft_icao != '') {
132
-    	    $aircraft_registration = $aircraft_icao;
133
-    	    $aircraft_name = '';
123
+		$aircraft_registration = urlencode(trim($aircraft_registration));
124
+		$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
125
+			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
126
+		else $aircraft_name = '';
127
+		if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
128
+			else $aircraft_icao = '';
129
+			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
130
+			else $airline_icao = '';
131
+		} elseif ($aircraft_icao != '') {
132
+			$aircraft_registration = $aircraft_icao;
133
+			$aircraft_name = '';
134 134
 	} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
135 135
 
136 136
 	if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
@@ -150,29 +150,29 @@  discard block
 block discarded – undo
150 150
 		if (isset($images_array) && $images_array['original'] != '') return $images_array;
151 151
 	}
152 152
 	return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
153
-    }
153
+	}
154 154
 
155
-    /**
156
-    * Gets the aircraft image from Planespotters
157
-    *
158
-    * @param String $aircraft_registration the registration of the aircraft
159
-    * @param String $aircraft_name type of the aircraft
160
-    * @return Array the aircraft thumbnail, orignal url and copyright
161
-    *
162
-    */
163
-    public function fromPlanespotters($aircraft_registration, $aircraft_name='') {
155
+	/**
156
+	 * Gets the aircraft image from Planespotters
157
+	 *
158
+	 * @param String $aircraft_registration the registration of the aircraft
159
+	 * @param String $aircraft_name type of the aircraft
160
+	 * @return Array the aircraft thumbnail, orignal url and copyright
161
+	 *
162
+	 */
163
+	public function fromPlanespotters($aircraft_registration, $aircraft_name='') {
164 164
 	$Common = new Common();
165 165
 	// If aircraft registration is only number, also check with aircraft model
166 166
 	if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
167
-	    $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
167
+		$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
168 168
 	} else {
169
-	    //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
170
-	    $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
169
+		//$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
170
+		$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
171 171
 	}
172 172
 	
173 173
 	$data = $Common->getData($url);
174 174
 	if ($xml = simplexml_load_string($data)) {
175
-	    if (isset($xml->channel->item)) {
175
+		if (isset($xml->channel->item)) {
176 176
 		$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
177 177
 		$image_url['thumbnail'] = $thumbnail_url;
178 178
 		$image_url['original'] = str_replace('thumbnail','original',$thumbnail_url);
@@ -180,31 +180,31 @@  discard block
 block discarded – undo
180 180
 		$image_url['source_website'] = trim((string)$xml->channel->item->link);
181 181
 		$image_url['source'] = 'planespotters';
182 182
 		return $image_url;
183
-	    }
183
+		}
184 184
 	} 
185 185
 	return false;
186
-    }
186
+	}
187 187
 
188
-    /**
189
-    * Gets the aircraft image from Deviantart
190
-    *
191
-    * @param String $aircraft_registration the registration of the aircraft
192
-    * @param String $aircraft_name type of the aircraft
193
-    * @return Array the aircraft thumbnail, orignal url and copyright
194
-    *
195
-    */
196
-    public function fromDeviantart($aircraft_registration, $aircraft_name='') {
188
+	/**
189
+	 * Gets the aircraft image from Deviantart
190
+	 *
191
+	 * @param String $aircraft_registration the registration of the aircraft
192
+	 * @param String $aircraft_name type of the aircraft
193
+	 * @return Array the aircraft thumbnail, orignal url and copyright
194
+	 *
195
+	 */
196
+	public function fromDeviantart($aircraft_registration, $aircraft_name='') {
197 197
 	$Common = new Common();
198 198
 	// If aircraft registration is only number, also check with aircraft model
199 199
 	if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
200
-	    $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name);
200
+		$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name);
201 201
 	} else {
202
-	    $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration;
202
+		$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration;
203 203
 	}
204 204
 	
205 205
 	$data = $Common->getData($url);
206 206
 	if ($xml = simplexml_load_string($data)) {
207
-	    if (isset($xml->channel->item->link)) {
207
+		if (isset($xml->channel->item->link)) {
208 208
 		$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
209 209
 		$image_url['thumbnail'] = $thumbnail_url;
210 210
 		$original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
 		$image_url['source_website'] = trim((string)$xml->channel->item->link);
214 214
 		$image_url['source'] = 'deviantart';
215 215
 		return $image_url;
216
-	    }
216
+		}
217 217
 	} 
218 218
 	return false;
219
-    }
219
+	}
220 220
 
221
-    /**
222
-    * Gets the aircraft image from JetPhotos
223
-    *
224
-    * @param String $aircraft_registration the registration of the aircraft
225
-    * @param String $aircraft_name type of the aircraft
226
-    * @return Array the aircraft thumbnail, orignal url and copyright
227
-    *
228
-    */
229
-    public function fromJetPhotos($aircraft_registration, $aircraft_name='') {
221
+	/**
222
+	 * Gets the aircraft image from JetPhotos
223
+	 *
224
+	 * @param String $aircraft_registration the registration of the aircraft
225
+	 * @param String $aircraft_name type of the aircraft
226
+	 * @return Array the aircraft thumbnail, orignal url and copyright
227
+	 *
228
+	 */
229
+	public function fromJetPhotos($aircraft_registration, $aircraft_name='') {
230 230
 	$Common = new Common();
231 231
 	$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
232 232
 	
@@ -235,19 +235,19 @@  discard block
 block discarded – undo
235 235
 	@$dom->loadHTML($data);
236 236
 	$all_pics = array();
237 237
 	foreach($dom->getElementsByTagName('img') as $image) {
238
-	    if ($image->getAttribute('itemprop') == "http://schema.org/image") {
238
+		if ($image->getAttribute('itemprop') == "http://schema.org/image") {
239 239
 		$all_pics[] = $image->getAttribute('src');
240
-	    }
240
+		}
241 241
 	}
242 242
 	$all_authors = array();
243 243
 	foreach($dom->getElementsByTagName('meta') as $author) {
244
-	    if ($author->getAttribute('itemprop') == "http://schema.org/author") {
244
+		if ($author->getAttribute('itemprop') == "http://schema.org/author") {
245 245
 		$all_authors[] = $author->getAttribute('content');
246
-	    }
246
+		}
247 247
 	}
248 248
 	$all_ref = array();
249 249
 	foreach($dom->getElementsByTagName('a') as $link) {
250
-	    $all_ref[] = $link->getAttribute('href');
250
+		$all_ref[] = $link->getAttribute('href');
251 251
 	}
252 252
 
253 253
 	if (isset($all_pics[0])) {
@@ -259,17 +259,17 @@  discard block
 block discarded – undo
259 259
 		return $image_url;
260 260
 	}
261 261
 	return false;
262
-    }
262
+	}
263 263
   
264
-    /**
265
-    * Gets the aircraft image from PlanePictures
266
-    *
267
-    * @param String $aircraft_registration the registration of the aircraft
268
-    * @param String $aircraft_name type of the aircraft
269
-    * @return Array the aircraft thumbnail, orignal url and copyright
270
-    *
271
-    */
272
-    public function fromPlanePictures($aircraft_registration, $aircraft_name='') {
264
+	/**
265
+	 * Gets the aircraft image from PlanePictures
266
+	 *
267
+	 * @param String $aircraft_registration the registration of the aircraft
268
+	 * @param String $aircraft_name type of the aircraft
269
+	 * @return Array the aircraft thumbnail, orignal url and copyright
270
+	 *
271
+	 */
272
+	public function fromPlanePictures($aircraft_registration, $aircraft_name='') {
273 273
 	$Common = new Common();
274 274
 	$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
275 275
 	
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
 	@$dom->loadHTML($data);
279 279
 	$all_pics = array();
280 280
 	foreach($dom->getElementsByTagName('img') as $image) {
281
-	    $all_pics[] = $image->getAttribute('src');
281
+		$all_pics[] = $image->getAttribute('src');
282 282
 	}
283 283
 	$all_links = array();
284 284
 	foreach($dom->getElementsByTagName('a') as $link) {
285
-	    $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
285
+		$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
286 286
 	}
287 287
 	if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1])) {
288 288
 		$image_url['thumbnail'] = 'http://www.planepictures.net'.$all_pics[1];
@@ -293,26 +293,26 @@  discard block
 block discarded – undo
293 293
 		return $image_url;
294 294
 	}
295 295
 	return false;
296
-    }
296
+	}
297 297
   
298
-    /**
299
-    * Gets the aircraft image from Flickr
300
-    *
301
-    * @param String $aircraft_registration the registration of the aircraft
302
-    * @param String $aircraft_name type of the aircraft
303
-    * @return Array the aircraft thumbnail, orignal url and copyright
304
-    *
305
-    */
306
-    public function fromFlickr($aircraft_registration,$aircraft_name='') {
298
+	/**
299
+	 * Gets the aircraft image from Flickr
300
+	 *
301
+	 * @param String $aircraft_registration the registration of the aircraft
302
+	 * @param String $aircraft_name type of the aircraft
303
+	 * @return Array the aircraft thumbnail, orignal url and copyright
304
+	 *
305
+	 */
306
+	public function fromFlickr($aircraft_registration,$aircraft_name='') {
307 307
 	$Common = new Common();
308 308
 
309
-	    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);
310
-	    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';
309
+		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);
310
+		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';
311 311
 	    
312 312
 	$data = $Common->getData($url);
313 313
 	
314 314
 	if ($xml = simplexml_load_string($data)) {
315
-	    if (isset($xml->channel->item)) {
315
+		if (isset($xml->channel->item)) {
316 316
 		$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
317 317
 		$image_url['thumbnail'] = $original_url;
318 318
 		$image_url['original'] = $original_url;
@@ -320,39 +320,39 @@  discard block
 block discarded – undo
320 320
 		$image_url['source_website'] = trim((string)$xml->channel->item->link);
321 321
 		$image_url['source'] = 'flickr';
322 322
 		return $image_url;
323
-	    }
323
+		}
324 324
 	} 
325 325
 	
326 326
 	return false;
327
-    }
327
+	}
328 328
 
329 329
 
330
-    public function fromIvaoMtl($aircraft_icao,$airline_icao) {
330
+	public function fromIvaoMtl($aircraft_icao,$airline_icao) {
331 331
 	$Common = new Common();
332 332
 	//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
333 333
 	if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) {
334
-	    $image_url['thumbnail'] = 'http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
335
-	    $image_url['original'] = 'http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
336
-	    $image_url['copyright'] = 'IVAO';
337
-	    $image_url['source_website'] = 'http://mtlcatalog.ivao.aero/';
338
-	    $image_url['source'] = 'ivao.aero';
339
-	    return $image_url;
334
+		$image_url['thumbnail'] = 'http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
335
+		$image_url['original'] = 'http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
336
+		$image_url['copyright'] = 'IVAO';
337
+		$image_url['source_website'] = 'http://mtlcatalog.ivao.aero/';
338
+		$image_url['source'] = 'ivao.aero';
339
+		return $image_url;
340 340
 	} else {
341
-	    return false;
341
+		return false;
342 342
 	}
343 343
     
344
-    }
344
+	}
345 345
     
346 346
     
347
-    /**
348
-    * Gets the aircraft image from Bing
349
-    *
350
-    * @param String $aircraft_registration the registration of the aircraft
351
-    * @param String $aircraft_name type of the aircraft
352
-    * @return Array the aircraft thumbnail, orignal url and copyright
353
-    *
354
-    */
355
-    public function fromBing($aircraft_registration,$aircraft_name='') {
347
+	/**
348
+	 * Gets the aircraft image from Bing
349
+	 *
350
+	 * @param String $aircraft_registration the registration of the aircraft
351
+	 * @param String $aircraft_name type of the aircraft
352
+	 * @return Array the aircraft thumbnail, orignal url and copyright
353
+	 *
354
+	 */
355
+	public function fromBing($aircraft_registration,$aircraft_name='') {
356 356
 	global $globalImageBingKey;
357 357
 	$Common = new Common();
358 358
 	if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
@@ -365,54 +365,54 @@  discard block
 block discarded – undo
365 365
 
366 366
 	$result = json_decode($data);
367 367
 	if (isset($result->d->results[0]->MediaUrl)) {
368
-	    $image_url['original'] = $result->d->results[0]->MediaUrl;
369
-	    $image_url['source_website'] = $result->d->results[0]->SourceUrl;
370
-	    // Thumbnail can't be used this way...
371
-	    // $image_url['thumbnail'] = $result->d->results[0]->Thumbnail->MediaUrl;
372
-	    $image_url['thumbnail'] = $result->d->results[0]->MediaUrl;
373
-	    $url = parse_url($image_url['source_website']);
374
-	    $image_url['copyright'] = $url['host'];
375
-	    $image_url['source'] = 'bing';
376
-	    return $image_url;
368
+		$image_url['original'] = $result->d->results[0]->MediaUrl;
369
+		$image_url['source_website'] = $result->d->results[0]->SourceUrl;
370
+		// Thumbnail can't be used this way...
371
+		// $image_url['thumbnail'] = $result->d->results[0]->Thumbnail->MediaUrl;
372
+		$image_url['thumbnail'] = $result->d->results[0]->MediaUrl;
373
+		$url = parse_url($image_url['source_website']);
374
+		$image_url['copyright'] = $url['host'];
375
+		$image_url['source'] = 'bing';
376
+		return $image_url;
377 377
 	}
378 378
 	return false;
379
-    }
379
+	}
380 380
 
381
-    /**
382
-    * Gets the aircraft image from airport-data
383
-    *
384
-    * @param String $aircraft_registration the registration of the aircraft
385
-    * @param String $aircraft_name type of the aircraft
386
-    * @return Array the aircraft thumbnail, orignal url and copyright
387
-    *
388
-    */
389
-    public function fromAirportData($aircraft_registration,$aircraft_name='') {
381
+	/**
382
+	 * Gets the aircraft image from airport-data
383
+	 *
384
+	 * @param String $aircraft_registration the registration of the aircraft
385
+	 * @param String $aircraft_name type of the aircraft
386
+	 * @return Array the aircraft thumbnail, orignal url and copyright
387
+	 *
388
+	 */
389
+	public function fromAirportData($aircraft_registration,$aircraft_name='') {
390 390
 	$Common = new Common();
391 391
 	$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
392 392
 	$data = $Common->getData($url);
393 393
 	$result = json_decode($data);
394 394
 	
395 395
 	if (isset($result->count) && $result->count > 0) {
396
-	    $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
397
-	    $image_url['source_website'] = $result->data[0]->link;
398
-	    $image_url['thumbnail'] = $result->data[0]->image;
399
-	    $image_url['copyright'] = $result->data[0]->photographer;
400
-	    $image_url['source'] = 'AirportData';
396
+		$image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
397
+		$image_url['source_website'] = $result->data[0]->link;
398
+		$image_url['thumbnail'] = $result->data[0]->image;
399
+		$image_url['copyright'] = $result->data[0]->photographer;
400
+		$image_url['source'] = 'AirportData';
401 401
 	
402
-	    return $image_url;
402
+		return $image_url;
403 403
 	}
404 404
 	return false;
405
-    }
405
+	}
406 406
 
407
-    /**
408
-    * Gets the aircraft image from WikiMedia
409
-    *
410
-    * @param String $aircraft_registration the registration of the aircraft
411
-    * @param String $aircraft_name type of the aircraft
412
-    * @return Array the aircraft thumbnail, orignal url and copyright
413
-    *
414
-    */
415
-    public function fromWikimedia($aircraft_registration,$aircraft_name='') {
407
+	/**
408
+	 * Gets the aircraft image from WikiMedia
409
+	 *
410
+	 * @param String $aircraft_registration the registration of the aircraft
411
+	 * @param String $aircraft_name type of the aircraft
412
+	 * @return Array the aircraft thumbnail, orignal url and copyright
413
+	 *
414
+	 */
415
+	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
416 416
 	$Common = new Common();
417 417
 	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);
418 418
 	else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
@@ -420,59 +420,59 @@  discard block
 block discarded – undo
420 420
 	$data = $Common->getData($url);
421 421
 	$result = json_decode($data);
422 422
 	if (isset($result->query->search[0]->title)) {
423
-	    $fileo = $result->query->search[0]->title;
424
-	    if (substr($fileo,-3) == 'pdf') return false;
425
-	    $file = urlencode($fileo);
426
-	    $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;
423
+		$fileo = $result->query->search[0]->title;
424
+		if (substr($fileo,-3) == 'pdf') return false;
425
+		$file = urlencode($fileo);
426
+		$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;
427 427
 
428
-	    $data2 = $Common->getData($url2);
429
-	    $result2 = json_decode($data2);
430
-	    if (isset($result2->query->pages)) {
428
+		$data2 = $Common->getData($url2);
429
+		$result2 = json_decode($data2);
430
+		if (isset($result2->query->pages)) {
431 431
 		foreach ($result2->query->pages as $page) {
432
-		    if (isset($page->imageinfo[0]->user)) {
432
+			if (isset($page->imageinfo[0]->user)) {
433 433
 			$image_url['copyright'] = 'Wikimedia, '.$page->imageinfo[0]->user;
434 434
 			$image_url['original'] = $page->imageinfo[0]->url;
435 435
 			$image_url['thumbnail'] = $page->imageinfo[0]->thumburl;
436 436
 			$image_url['source'] = 'wikimedia';
437 437
 			$image_url['source_website'] = 'http://commons.wikimedia.org/wiki/'.$fileo;
438 438
 			//return $image_url;
439
-		    }
439
+			}
440
+		}
440 441
 		}
441
-	    }
442 442
 	    
443
-	    if (isset($image_url['original'])) {
443
+		if (isset($image_url['original'])) {
444 444
 		$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&prop=imageinfo&iiprop=extmetadata&format=json&continue&titles='.$file;
445 445
 
446 446
 		$data2 = $Common->getData($url2);
447 447
 		$result2 = json_decode($data2);
448 448
 		if (isset($result2->query->pages)) {
449
-		    foreach ($result2->query->pages as $page) {
449
+			foreach ($result2->query->pages as $page) {
450 450
 			if (isset($page->imageinfo[0]->extmetadata->Artist)) {
451
-			    $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
452
-			    if (isset($page->imageinfo[0]->extmetadata->License->value)) {
453
-			        $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
454
-			    }
455
-			    $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
456
-			    return $image_url;
451
+				$image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
452
+				if (isset($page->imageinfo[0]->extmetadata->License->value)) {
453
+					$image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
454
+				}
455
+				$image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
456
+				return $image_url;
457
+			}
457 458
 			}
458
-		    }
459 459
 		}
460 460
 		return $image_url;
461
-	    }
461
+		}
462 462
 	    
463 463
 	}
464 464
 	return false;
465
-    }
465
+	}
466 466
 
467
-    /**
468
-    * Gets the aircraft image from custom url
469
-    *
470
-    * @param String $aircraft_registration the registration of the aircraft
471
-    * @param String $aircraft_name type of the aircraft
472
-    * @return Array the aircraft thumbnail, orignal url and copyright
473
-    *
474
-    */
475
-    public function fromCustomSource($aircraft_registration,$aircraft_name='') {
467
+	/**
468
+	 * Gets the aircraft image from custom url
469
+	 *
470
+	 * @param String $aircraft_registration the registration of the aircraft
471
+	 * @param String $aircraft_name type of the aircraft
472
+	 * @return Array the aircraft thumbnail, orignal url and copyright
473
+	 *
474
+	 */
475
+	public function fromCustomSource($aircraft_registration,$aircraft_name='') {
476 476
 	global $globalAircraftCustomSources;
477 477
 	//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
478 478
 	if (!empty($globalAircraftImageCustomSources)) {
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 		}
496 496
 		return false;
497 497
 	} else return false;
498
-    }
498
+	}
499 499
 
500 500
 
501 501
 
Please login to merge, or discard this patch.
require/class.Language.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
 	/**
78 78
 	* Returns list of available locales
79 79
 	*
80
-	* @return array
80
+	* @return string[]
81 81
 	 */
82 82
 	public function listLocaleDir()
83 83
 	{
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (!function_exists("gettext")) {
4
-        function _($text) {
5
-                return $text;
6
-        }
4
+		function _($text) {
5
+				return $text;
6
+		}
7 7
 } else {
8 8
 	if (isset($_COOKIE['language']) && $_COOKIE['language'] != 'en_GB' && (isset($globalTranslate) && $globalTranslate)) {
9 9
 		$Language = new Language();
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 			);
76 76
 
77 77
 	/**
78
-	* Returns list of available locales
79
-	*
80
-	* @return array
78
+	 * Returns list of available locales
79
+	 *
80
+	 * @return array
81 81
 	 */
82 82
 	public function listLocaleDir()
83 83
 	{
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 	}
104 104
 
105 105
 	/**
106
-	* Returns list of available languages
107
-	*
108
-	* @return array
106
+	 * Returns list of available languages
107
+	 *
108
+	 * @return array
109 109
 	 */
110 110
 	public function getLanguages()
111 111
 	{
Please login to merge, or discard this patch.