Completed
Push — master ( 2ae3e5...aafa66 )
by Yannick
29:36
created
aircraft-data.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 
12 12
 $from_archive = false;
13 13
 if (isset($_GET['ident'])) {
14
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
14
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
15 15
 	if (isset($_GET['currenttime'])) {
16
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
16
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
17 17
 		$currenttime = round($currenttime/1000);
18
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident,$currenttime);
18
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident, $currenttime);
19 19
 		if (empty($spotter_array)) {
20 20
 			$from_archive = true;
21
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident,$currenttime);
21
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident, $currenttime);
22 22
 		}
23 23
 	} else {
24 24
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident);
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	}
30 30
 }
31 31
 if (isset($_GET['flightaware_id'])) {
32
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
32
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
33 33
 	if (isset($_GET['currenttime'])) {
34
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
34
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
35 35
 		$currenttime = round($currenttime/1000);
36
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id,$currenttime);
36
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id, $currenttime);
37 37
 		if (empty($spotter_array)) {
38 38
 			$from_archive = true;
39 39
 //			$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
40
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id,$currenttime);
40
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id, $currenttime);
41 41
 		}
42 42
 	} else {
43 43
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
58 58
 	{
59 59
 		if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
60
-			$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
60
+			$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
61 61
 		} else $image = $spotter_item['image_thumbnail'];
62 62
 	}
63 63
 	/* else {
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
81 81
 		if (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
82 82
 			if ($spotter_item['departure_airport_time'] > 2460) {
83
-				print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>';
83
+				print '<br /><span class="time">'.date('H:m', $spotter_item['departure_airport_time']).'</span>';
84 84
 			} else {
85 85
 				print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>';
86 86
 			}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
90 90
 		if (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
91 91
 			if ($spotter_item['arrival_airport_time'] > 2460) {
92
-				print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>';
92
+				print '<br /><span class="time">'.date('H:m', $spotter_item['arrival_airport_time']).'</span>';
93 93
 			} else {
94 94
 				print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>';
95 95
 			}
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	print '<span>'._("Aircraft").'</span>';
109 109
 	if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
110 110
 	if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') {
111
-		$aircraft_names = explode('/',$spotter_item['aircraft_name']);
111
+		$aircraft_names = explode('/', $spotter_item['aircraft_name']);
112 112
 		if (count($aircraft_names) == 1) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
113 113
 		else print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].' ('.$spotter_item['aircraft_type'].')</a>';
114 114
 	} elseif (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>';
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	print '<div id ="altitude"><span>'._("Altitude").'</span>';
119 119
 	if (isset($globalGroundAltitude) && $globalGroundAltitude) {
120 120
 		try {
121
-			$groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']);
122
-		} catch(Exception $e) {
121
+			$groundAltitude = $Elevation->getElevation($spotter_item['latitude'], $spotter_item['longitude']);
122
+		} catch (Exception $e) {
123 123
 			// If catched not exist
124 124
 		}
125 125
 	}
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
 	if (isset($globalCam) && $globalCam) {
159 159
 		require_once(dirname(__FILE__).'/require/class.Common.php');
160 160
 		$Common = new Common();
161
-		$azimuth = round($Common->azimuth($globalCenterLatitude,$globalCenterLongitude,$spotter_item['latitude'],$spotter_item['longitude']));
162
-		$distance = $Common->distance($globalCenterLatitude,$globalCenterLongitude,$spotter_item['latitude'],$spotter_item['longitude'],'m');
163
-		$plunge = round($Common->plunge($globalCenterAltitude,$spotter_item['real_altitude'],$distance));
161
+		$azimuth = round($Common->azimuth($globalCenterLatitude, $globalCenterLongitude, $spotter_item['latitude'], $spotter_item['longitude']));
162
+		$distance = $Common->distance($globalCenterLatitude, $globalCenterLongitude, $spotter_item['latitude'], $spotter_item['longitude'], 'm');
163
+		$plunge = round($Common->plunge($globalCenterAltitude, $spotter_item['real_altitude'], $distance));
164 164
 		print '<div id="camcoordinates"><span>'._("Cam Coordinates").'</span>';
165 165
 		print 'azimuth: '.$azimuth;
166 166
 		print ' / ';
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
 		print '</div>';
171 171
 		//echo $Common->getData('http://127.0.0.1/camera.php?azimuth='.$azimuth.'&plunge='.$plunge,'get','','','','','','',false,true);
172 172
 		//echo $Common->getData('file://'.dirname(__FILE__).'/camera.php?azimuth='.$azimuth.'&plunge='.$plunge,'get','','','','','','',false,true);
173
-		echo $Common->getData('http://'.$_SERVER['SERVER_NAME'].'/camera.php?azimuth='.$azimuth.'&plunge='.$plunge,'get','','','','','','',false,true);
173
+		echo $Common->getData('http://'.$_SERVER['SERVER_NAME'].'/camera.php?azimuth='.$azimuth.'&plunge='.$plunge, 'get', '', '', '', '', '', '', false, true);
174 174
 	}
175 175
   
176 176
 	print '<div id="heading"><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>';
177 177
 	if (isset($spotter_item['verticalrate']) && $spotter_item['verticalrate'] != '') {
178 178
 		print '<div id="verticalrate"><span>'._("Vertical rate").'</span>';
179 179
 		if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
180
-			print $spotter_item['verticalrate']. ' ft/min';
180
+			print $spotter_item['verticalrate'].' ft/min';
181 181
 		} else {
182
-			print round($spotter_item['verticalrate']*0.3048). ' m/min';
182
+			print round($spotter_item['verticalrate']*0.3048).' m/min';
183 183
 		}
184 184
 		print '</div>';
185 185
 	}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	print '</div>';
215 215
 	if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
216 216
 	if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
217
-	if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
217
+	if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br/>', $spotter_item['acars']['message'])).'</div>';
218 218
 	if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
219 219
 	print '</div>';
220 220
 }
Please login to merge, or discard this patch.
Braces   +52 added lines, -19 removed lines patch added patch discarded remove patch
@@ -58,7 +58,9 @@  discard block
 block discarded – undo
58 58
 	{
59 59
 		if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
60 60
 			$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
61
-		} else $image = $spotter_item['image_thumbnail'];
61
+		} else {
62
+			$image = $spotter_item['image_thumbnail'];
63
+		}
62 64
 	}
63 65
 	/* else {
64 66
 		$image = "images/placeholder_thumb.png";
@@ -73,8 +75,12 @@  discard block
 block discarded – undo
73 75
 	}
74 76
 	print '<div class="right">';
75 77
 	print '<div class="callsign-details">';
76
-	if ($spotter_item['ident'] != 'Not Available') print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
77
-	if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
78
+	if ($spotter_item['ident'] != 'Not Available') {
79
+		print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
80
+	}
81
+	if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') {
82
+		print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
83
+	}
78 84
 	print '</div>';
79 85
 	if ($spotter_item['departure_airport'] != 'NA' && $spotter_item['arrival_airport'] != 'NA') {
80 86
 		print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
@@ -106,13 +112,21 @@  discard block
 block discarded – undo
106 112
 	print '</div>';
107 113
 	print '<div id="aircraft">';
108 114
 	print '<span>'._("Aircraft").'</span>';
109
-	if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
115
+	if (isset($spotter_item['aircraft_wiki'])) {
116
+		print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
117
+	}
110 118
 	if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') {
111 119
 		$aircraft_names = explode('/',$spotter_item['aircraft_name']);
112
-		if (count($aircraft_names) == 1) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
113
-		else print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].' ('.$spotter_item['aircraft_type'].')</a>';
114
-	} elseif (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>';
115
-	else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
120
+		if (count($aircraft_names) == 1) {
121
+			print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
122
+		} else {
123
+			print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].' ('.$spotter_item['aircraft_type'].')</a>';
124
+		}
125
+	} elseif (isset($spotter_item['aircraft_type'])) {
126
+		print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>';
127
+	} else {
128
+		print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
129
+	}
116 130
 	
117 131
 	print '</div>';
118 132
 	print '<div id ="altitude"><span>'._("Altitude").'</span>';
@@ -125,11 +139,17 @@  discard block
 block discarded – undo
125 139
 	}
126 140
 
127 141
 	if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
128
-		if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')';
129
-		else print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')';
142
+		if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
143
+			print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')';
144
+		} else {
145
+			print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')';
146
+		}
130 147
 	} else {
131
-		if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')';
132
-		else print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
148
+		if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
149
+			print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')';
150
+		} else {
151
+			print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
152
+		}
133 153
 	}
134 154
 
135 155
 	if (isset($groundAltitude) && $groundAltitude < $spotter_item['altitude']*30.48) {
@@ -143,7 +163,9 @@  discard block
 block discarded – undo
143 163
 		print '</i>';
144 164
 	}
145 165
 	print '</div>';
146
-	if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
166
+	if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') {
167
+		print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
168
+	}
147 169
 	print '<div id="speed"><span>'._("Speed").'</span>';
148 170
 	if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
149 171
 		print round($spotter_item['ground_speed']*1.15078).' mph';
@@ -185,8 +207,11 @@  discard block
 block discarded – undo
185 207
 	}
186 208
 	if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') {
187 209
 		print '<div id="pilot"><span>'._("Pilot").'</span>';
188
-		if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
189
-		else print $spotter_item['pilot_name'];
210
+		if (isset($spotter_item['pilot_id'])) {
211
+			print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
212
+		} else {
213
+			print $spotter_item['pilot_name'];
214
+		}
190 215
 		print '</div>';
191 216
 	}
192 217
 	if (isset($spotter_item['aircraft_owner']) && $spotter_item['aircraft_owner'] != '') {
@@ -212,10 +237,18 @@  discard block
 block discarded – undo
212 237
 	}
213 238
 	print '</div>';
214 239
 	print '</div>';
215
-	if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
216
-	if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
217
-	if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
218
-	if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
240
+	if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') {
241
+		print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
242
+	}
243
+	if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') {
244
+		print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
245
+	}
246
+	if (isset($spotter_item['acars']['message'])) {
247
+		print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
248
+	}
249
+	if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) {
250
+		print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
251
+	}
219 252
 	print '</div>';
220 253
 }
221 254
 ?>
Please login to merge, or discard this patch.
require/class.Common.php 3 patches
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 	//protected $cookies = array();
8 8
 	
9 9
 	/**
10
-	* Get data from form result
11
-	* @param String $url form URL
12
-	* @param String $type type of submit form method (get or post)
13
-	* @param String|Array $data values form post method
14
-	* @param Array $headers header to submit with the form
15
-	* @return String the result
16
-	*/
10
+	 * Get data from form result
11
+	 * @param String $url form URL
12
+	 * @param String $type type of submit form method (get or post)
13
+	 * @param String|Array $data values form post method
14
+	 * @param Array $headers header to submit with the form
15
+	 * @return String the result
16
+	 */
17 17
 	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false) {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
@@ -166,10 +166,10 @@  discard block
 block discarded – undo
166 166
 	}
167 167
 
168 168
 	/**
169
-	* Convert a HTML table to an array
170
-	* @param String $data HTML page
171
-	* @return Array array of the tables in HTML page
172
-	*/
169
+	 * Convert a HTML table to an array
170
+	 * @param String $data HTML page
171
+	 * @return Array array of the tables in HTML page
172
+	 */
173 173
 	public function table2array($data) {
174 174
 		if (!is_string($data)) return array();
175 175
 		if ($data == '') return array();
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
 	}
204 204
 	
205 205
 	/**
206
-	* Convert <p> part of a HTML page to an array
207
-	* @param String $data HTML page
208
-	* @return Array array of the <p> in HTML page
209
-	*/
206
+	 * Convert <p> part of a HTML page to an array
207
+	 * @param String $data HTML page
208
+	 * @return Array array of the <p> in HTML page
209
+	 */
210 210
 	public function text2array($data) {
211 211
 		$html = str_get_html($data);
212 212
 		if ($html === false) return array();
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
 	}
222 222
 
223 223
 	/**
224
-	* Give distance between 2 coordonnates
225
-	* @param Float $lat latitude of first point
226
-	* @param Float $lon longitude of first point
227
-	* @param Float $latc latitude of second point
228
-	* @param Float $lonc longitude of second point
229
-	* @param String $unit km else no unit used
230
-	* @return Float Distance in $unit
231
-	*/
224
+	 * Give distance between 2 coordonnates
225
+	 * @param Float $lat latitude of first point
226
+	 * @param Float $lon longitude of first point
227
+	 * @param Float $latc latitude of second point
228
+	 * @param Float $lonc longitude of second point
229
+	 * @param String $unit km else no unit used
230
+	 * @return Float Distance in $unit
231
+	 */
232 232
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233 233
 		if ($lat == $latc && $lon == $lonc) return 0;
234 234
 		$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;
@@ -246,12 +246,12 @@  discard block
 block discarded – undo
246 246
 	}
247 247
 
248 248
 	/**
249
-	* Give plunge between 2 altitudes and distance
250
-	* @param Float $initial_altitude altitude of first point in m
251
-	* @param Float $final_altitude altitude of second point in m
252
-	* @param String $distance distance between two points in m
253
-	* @return Float plunge
254
-	*/
249
+	 * Give plunge between 2 altitudes and distance
250
+	 * @param Float $initial_altitude altitude of first point in m
251
+	 * @param Float $final_altitude altitude of second point in m
252
+	 * @param String $distance distance between two points in m
253
+	 * @return Float plunge
254
+	 */
255 255
 	public function plunge($initial_altitude,$final_altitude,$distance) {
256 256
 		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
257 257
 		/*
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 	}
266 266
 
267 267
 	/**
268
-	* Give azimuth between 2 coordonnates
269
-	* @param Float $lat latitude of first point
270
-	* @param Float $lon longitude of first point
271
-	* @param Float $latc latitude of second point
272
-	* @param Float $lonc longitude of second point
273
-	* @return Float Azimuth
274
-	*/
268
+	 * Give azimuth between 2 coordonnates
269
+	 * @param Float $lat latitude of first point
270
+	 * @param Float $lon longitude of first point
271
+	 * @param Float $latc latitude of second point
272
+	 * @param Float $lonc longitude of second point
273
+	 * @return Float Azimuth
274
+	 */
275 275
 	public function azimuth($lat, $lon, $latc, $lonc) {
276 276
 		$dX = $latc - $lat;
277 277
 		$dY = $lonc - $lon;
@@ -282,11 +282,11 @@  discard block
 block discarded – undo
282 282
 	
283 283
 	
284 284
 	/**
285
-	* Check is distance realistic
286
-	* @param int $timeDifference the time between the reception of both messages
287
-	* @param float $distance distance covered
288
-	* @return whether distance is realistic
289
-	*/
285
+	 * Check is distance realistic
286
+	 * @param int $timeDifference the time between the reception of both messages
287
+	 * @param float $distance distance covered
288
+	 * @return whether distance is realistic
289
+	 */
290 290
 	public function withinThreshold ($timeDifference, $distance) {
291 291
 		$x = abs($timeDifference);
292 292
 		$d = abs($distance);
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 	}
337 337
 	
338 338
 	/**
339
-	* Copy folder contents
340
-	* @param       string   $source    Source path
341
-	* @param       string   $dest      Destination path
342
-	* @return      bool     Returns true on success, false on failure
343
-	*/
339
+	 * Copy folder contents
340
+	 * @param       string   $source    Source path
341
+	 * @param       string   $dest      Destination path
342
+	 * @return      bool     Returns true on success, false on failure
343
+	 */
344 344
 	public function xcopy($source, $dest)
345 345
 	{
346 346
 		$files = glob($source.'*.*');
@@ -352,20 +352,20 @@  discard block
 block discarded – undo
352 352
 	}
353 353
 	
354 354
 	/**
355
-	* Check if an url exist
356
-	* @param	String $url url to check
357
-	* @return	bool Return true on succes false on failure
358
-	*/
355
+	 * Check if an url exist
356
+	 * @param	String $url url to check
357
+	 * @return	bool Return true on succes false on failure
358
+	 */
359 359
 	public function urlexist($url){
360 360
 		$headers=get_headers($url);
361 361
 		return stripos($headers[0],"200 OK")?true:false;
362 362
 	}
363 363
 	
364 364
 	/**
365
-	* Convert hexa to string
366
-	* @param	String $hex data in hexa
367
-	* @return	String Return result
368
-	*/
365
+	 * Convert hexa to string
366
+	 * @param	String $hex data in hexa
367
+	 * @return	String Return result
368
+	 */
369 369
 	public function hex2str($hex) {
370 370
 		$str = '';
371 371
 		$hexln = strlen($hex);
@@ -374,10 +374,10 @@  discard block
 block discarded – undo
374 374
 	}
375 375
 	
376 376
 	/**
377
-	* Convert hexa color to rgb
378
-	* @param	String $hex data in hexa
379
-	* @return	String Return result
380
-	*/
377
+	 * Convert hexa color to rgb
378
+	 * @param	String $hex data in hexa
379
+	 * @return	String Return result
380
+	 */
381 381
 	public function hex2rgb($hex) {
382 382
 		$hex = str_replace('#','',$hex);
383 383
 		return sscanf($hex, "%02x%02x%02x"); 
@@ -455,9 +455,9 @@  discard block
 block discarded – undo
455 455
 	}
456 456
 	
457 457
 	/**
458
-	* Returns list of available locales
459
-	*
460
-	* @return array
458
+	 * Returns list of available locales
459
+	 *
460
+	 * @return array
461 461
 	 */
462 462
 	public function listLocaleDir()
463 463
 	{
@@ -556,100 +556,100 @@  discard block
 block discarded – undo
556 556
 	public function remove_accents($string) {
557 557
 		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
558 558
 		$chars = array(
559
-		    // Decompositions for Latin-1 Supplement
560
-		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
561
-		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
562
-		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
563
-		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
564
-		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
565
-		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
566
-		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
567
-		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
568
-		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
569
-		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
570
-		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
571
-		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
572
-		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
573
-		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
574
-		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
575
-		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
576
-		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
577
-		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
578
-		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
579
-		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
580
-		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
581
-		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
582
-		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
583
-		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
584
-		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
585
-		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
586
-		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
587
-		    chr(195).chr(191) => 'y',
588
-		    // Decompositions for Latin Extended-A
589
-		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
590
-		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
591
-		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
592
-		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
593
-		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
594
-		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
595
-		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
596
-		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
597
-		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
598
-		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
599
-		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
600
-		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
601
-		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
602
-		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
603
-		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
604
-		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
605
-		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
606
-		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
607
-		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
608
-		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
609
-		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
610
-		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
611
-		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
612
-		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
613
-		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
614
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
615
-		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
616
-		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
617
-		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
618
-		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
619
-		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
620
-		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
621
-		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
622
-		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
623
-		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
624
-		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
625
-		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
626
-		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
627
-		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
628
-		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
629
-		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
630
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
631
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
632
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
633
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
634
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
635
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
636
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
637
-		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
638
-		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
639
-		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
640
-		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
641
-		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
642
-		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
643
-		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
644
-		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
645
-		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
646
-		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
647
-		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
648
-		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
649
-		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
650
-		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
651
-		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
652
-		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
559
+			// Decompositions for Latin-1 Supplement
560
+			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
561
+			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
562
+			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
563
+			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
564
+			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
565
+			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
566
+			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
567
+			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
568
+			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
569
+			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
570
+			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
571
+			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
572
+			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
573
+			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
574
+			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
575
+			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
576
+			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
577
+			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
578
+			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
579
+			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
580
+			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
581
+			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
582
+			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
583
+			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
584
+			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
585
+			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
586
+			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
587
+			chr(195).chr(191) => 'y',
588
+			// Decompositions for Latin Extended-A
589
+			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
590
+			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
591
+			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
592
+			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
593
+			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
594
+			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
595
+			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
596
+			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
597
+			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
598
+			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
599
+			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
600
+			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
601
+			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
602
+			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
603
+			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
604
+			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
605
+			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
606
+			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
607
+			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
608
+			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
609
+			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
610
+			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
611
+			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
612
+			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
613
+			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
614
+			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
615
+			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
616
+			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
617
+			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
618
+			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
619
+			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
620
+			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
621
+			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
622
+			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
623
+			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
624
+			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
625
+			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
626
+			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
627
+			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
628
+			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
629
+			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
630
+			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
631
+			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
632
+			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
633
+			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
634
+			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
635
+			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
636
+			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
637
+			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
638
+			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
639
+			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
640
+			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
641
+			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
642
+			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
643
+			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
644
+			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
645
+			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
646
+			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
647
+			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
648
+			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
649
+			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
650
+			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
651
+			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
652
+			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
653 653
 		);
654 654
 		$string = strtr($string, $chars);
655 655
 		return $string;
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 			$dfX = $first_pass[$j][0];
791 791
 			$dfDiffLong = abs($dfX - $dfPrevX);
792 792
 			if ($dfDiffLong > $dfDiffSpace &&
793
-			    (($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
793
+				(($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
794 794
 			{
795 795
 				$bHasBigDiff = true;
796 796
 			} else if ($dfDiffLong > $dfMaxSmallDiffLong) {
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
 					$dfX2 = floatval($first_pass[$k][0]);
811 811
 					$dfY2 = floatval($first_pass[$k][1]);
812 812
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
813
-					    $k+1 < count($first_pass) &&
814
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
813
+						$k+1 < count($first_pass) &&
814
+						$first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
815 815
 					{
816 816
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
817 817
 						$k++;
@@ -819,8 +819,8 @@  discard block
 block discarded – undo
819 819
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
820 820
 						continue;
821 821
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
822
-					    $k+1 < $first_pass_ln &&
823
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
822
+						$k+1 < $first_pass_ln &&
823
+						$first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
824 824
 					{
825 825
 						$poNewLS[] = array(180, $first_pass[$k][1]);
826 826
 						$k++;
Please login to merge, or discard this patch.
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 	* @param Array $headers header to submit with the form
15 15
 	* @return String the result
16 16
 	*/
17
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false) {
17
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '', $sizelimit = false, $async = false) {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
20 20
 		curl_setopt($ch, CURLOPT_URL, $url);
21 21
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
22
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
22
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
23 23
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
24 24
 			}
25 25
 		}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30 30
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
31 31
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
32
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
32
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
33 33
 		//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');
34 34
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
35 35
 		if ($useragent == '') {
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41 41
 		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
42
-		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
42
+		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback"));
43 43
 		if ($type == 'post') {
44 44
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
45 45
 			if (is_array($data)) {
46 46
 				curl_setopt($ch, CURLOPT_POST, count($data));
47 47
 				$data_string = '';
48
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
48
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
49 49
 				rtrim($data_string, '&');
50 50
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
51 51
 			} else {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		}
58 58
 		if ($cookie != '') {
59 59
 			if (is_array($cookie)) {
60
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
60
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
61 61
 			} else {
62 62
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
63 63
 			}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		if ($sizelimit === true) {
69 69
 			curl_setopt($ch, CURLOPT_BUFFERSIZE, 128);
70 70
 			curl_setopt($ch, CURLOPT_NOPROGRESS, false);
71
-			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr,$downloadsize, $downloaded, $uploadsize, $uploaded){
71
+			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr, $downloadsize, $downloaded, $uploadsize, $uploaded) {
72 72
 				return ($downloaded > (3*1024)) ? 1 : 0;
73 73
 			});
74 74
 		}
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 		$result = curl_exec($ch);
80 80
 		$info = curl_getinfo($ch);
81 81
 		curl_close($ch);
82
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
82
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
83 83
 			echo "Cloudflare Detected\n";
84 84
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
85 85
 			$useragent = UAgent::random();
86 86
 			cloudflare::useUserAgent($useragent);
87 87
 			if ($clearanceCookie = cloudflare::bypass($url)) {
88
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
88
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
89 89
 			}
90 90
 		} else {
91 91
 			return $result;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
110 110
 		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
111 111
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
112
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
112
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
113 113
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
114 114
 			}
115 115
 		}
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
 		fclose($fp);
125 125
 	}
126 126
 
127
-	public static function gunzip($in_file,$out_file_name = '') {
127
+	public static function gunzip($in_file, $out_file_name = '') {
128 128
 		//echo $in_file.' -> '.$out_file_name."\n";
129 129
 		$buffer_size = 4096; // read 4kb at a time
130 130
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
131 131
 		if ($in_file != '' && file_exists($in_file)) {
132 132
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
133
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
134
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
133
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
134
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
135 135
 			else {
136 136
 				echo 'gzopen not available';
137 137
 				die;
138 138
 			}
139 139
 			$out_file = fopen($out_file_name, 'wb'); 
140
-			while(!gzeof($file)) {
140
+			while (!gzeof($file)) {
141 141
 				fwrite($out_file, gzread($file, $buffer_size));
142 142
 			}  
143 143
 			fclose($out_file);
@@ -145,19 +145,19 @@  discard block
 block discarded – undo
145 145
 		}
146 146
 	}
147 147
 
148
-	public static function bunzip2($in_file,$out_file_name = '') {
148
+	public static function bunzip2($in_file, $out_file_name = '') {
149 149
 		//echo $in_file.' -> '.$out_file_name."\n";
150 150
 		$buffer_size = 4096; // read 4kb at a time
151 151
 		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
152 152
 		if ($in_file != '' && file_exists($in_file)) {
153 153
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
154
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
154
+			if (function_exists('bzopen')) $file = bzopen($in_file, 'rb');
155 155
 			else {
156 156
 				echo 'bzopen not available';
157 157
 				die;
158 158
 			}
159 159
 			$out_file = fopen($out_file_name, 'wb'); 
160
-			while(!feof($file)) {
160
+			while (!feof($file)) {
161 161
 				fwrite($out_file, bzread($file, $buffer_size));
162 162
 			}  
163 163
 			fclose($out_file);
@@ -175,27 +175,27 @@  discard block
 block discarded – undo
175 175
 		if ($data == '') return array();
176 176
 		$html = str_get_html($data);
177 177
 		if ($html === false) return array();
178
-		$tabledata=array();
179
-		foreach($html->find('tr') as $element)
178
+		$tabledata = array();
179
+		foreach ($html->find('tr') as $element)
180 180
 		{
181 181
 			$td = array();
182
-			foreach( $element->find('th') as $row)
182
+			foreach ($element->find('th') as $row)
183 183
 			{
184 184
 				$td [] = trim($row->plaintext);
185 185
 			}
186
-			$td=array_filter($td);
186
+			$td = array_filter($td);
187 187
 			$tabledata[] = $td;
188 188
 
189 189
 			$td = array();
190 190
 			$tdi = array();
191
-			foreach( $element->find('td') as $row)
191
+			foreach ($element->find('td') as $row)
192 192
 			{
193 193
 				$td [] = trim($row->plaintext);
194 194
 				$tdi [] = trim($row->innertext);
195 195
 			}
196
-			$td=array_filter($td);
197
-			$tdi=array_filter($tdi);
198
-			$tabledata[]=array_merge($td,$tdi);
196
+			$td = array_filter($td);
197
+			$tdi = array_filter($tdi);
198
+			$tabledata[] = array_merge($td, $tdi);
199 199
 		}
200 200
 		$html->clear();
201 201
 		unset($html);
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 	public function text2array($data) {
211 211
 		$html = str_get_html($data);
212 212
 		if ($html === false) return array();
213
-		$tabledata=array();
214
-		foreach($html->find('p') as $element)
213
+		$tabledata = array();
214
+		foreach ($html->find('p') as $element)
215 215
 		{
216 216
 			$tabledata [] = trim($element->plaintext);
217 217
 		}
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 	*/
232 232
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233 233
 		if ($lat == $latc && $lon == $lonc) return 0;
234
-		$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;
234
+		$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;
235 235
 		if ($unit == "km") {
236
-			return round($dist * 1.609344);
236
+			return round($dist*1.609344);
237 237
 		} elseif ($unit == "m") {
238
-			return round($dist * 1.609344 * 1000);
238
+			return round($dist*1.609344*1000);
239 239
 		} elseif ($unit == "mile" || $unit == "mi") {
240 240
 			return round($dist);
241 241
 		} elseif ($unit == "nm") {
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	* @param String $distance distance between two points in m
253 253
 	* @return Float plunge
254 254
 	*/
255
-	public function plunge($initial_altitude,$final_altitude,$distance) {
256
-		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
255
+	public function plunge($initial_altitude, $final_altitude, $distance) {
256
+		$plunge = rad2deg(asin(($final_altitude - $initial_altitude)/$distance));
257 257
 		/*
258 258
 		$siter = 6378137.0 + $initial_altitude;
259 259
 		$planer = 6378137.0 + $final_altitude;
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
 	public function azimuth($lat, $lon, $latc, $lonc) {
276 276
 		$dX = $latc - $lat;
277 277
 		$dY = $lonc - $lon;
278
-		$azimuth = rad2deg(atan2($dY,$dX));
279
-		if ($azimuth < 0) return $azimuth+360;
278
+		$azimuth = rad2deg(atan2($dY, $dX));
279
+		if ($azimuth < 0) return $azimuth + 360;
280 280
 		return $azimuth;
281 281
 	}
282 282
 	
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	* @param float $distance distance covered
288 288
 	* @return whether distance is realistic
289 289
 	*/
290
-	public function withinThreshold ($timeDifference, $distance) {
290
+	public function withinThreshold($timeDifference, $distance) {
291 291
 		$x = abs($timeDifference);
292 292
 		$d = abs($distance);
293 293
 		if ($x == 0 || $d == 0) return true;
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
 		return ($array !== array_values($array));
304 304
 	}
305 305
 
306
-	public function isInteger($input){
306
+	public function isInteger($input) {
307 307
 		//return(ctype_digit(strval($input)));
308
-		return preg_match('/^-?[0-9]+$/', (string)$input) ? true : false;
308
+		return preg_match('/^-?[0-9]+$/', (string) $input) ? true : false;
309 309
 	}
310 310
 
311 311
 
312
-	public function convertDec($dms,$latlong) {
312
+	public function convertDec($dms, $latlong) {
313 313
 		if ($latlong == 'latitude') {
314 314
 			$deg = substr($dms, 0, 2);
315 315
 			$min = substr($dms, 2, 4);
@@ -317,10 +317,10 @@  discard block
 block discarded – undo
317 317
 			$deg = substr($dms, 0, 3);
318 318
 			$min = substr($dms, 3, 5);
319 319
 		}
320
-		return $deg+(($min*60)/3600);
320
+		return $deg + (($min*60)/3600);
321 321
 	}
322 322
 	
323
-	public function convertDM($coord,$latlong) {
323
+	public function convertDM($coord, $latlong) {
324 324
 		if ($latlong == 'latitude') {
325 325
 			if ($coord < 0) $NSEW = 'S';
326 326
 			else $NSEW = 'N';
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
 		}
331 331
 		$coord = abs($coord);
332 332
 		$deg = floor($coord);
333
-		$coord = ($coord-$deg)*60;
333
+		$coord = ($coord - $deg)*60;
334 334
 		$min = $coord;
335
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
335
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
336 336
 	}
337 337
 	
338 338
 	/**
@@ -344,8 +344,8 @@  discard block
 block discarded – undo
344 344
 	public function xcopy($source, $dest)
345 345
 	{
346 346
 		$files = glob($source.'*.*');
347
-		foreach($files as $file){
348
-			$file_to_go = str_replace($source,$dest,$file);
347
+		foreach ($files as $file) {
348
+			$file_to_go = str_replace($source, $dest, $file);
349 349
 			copy($file, $file_to_go);
350 350
 		}
351 351
 		return true;
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 	* @param	String $url url to check
357 357
 	* @return	bool Return true on succes false on failure
358 358
 	*/
359
-	public function urlexist($url){
360
-		$headers=get_headers($url);
361
-		return stripos($headers[0],"200 OK")?true:false;
359
+	public function urlexist($url) {
360
+		$headers = get_headers($url);
361
+		return stripos($headers[0], "200 OK") ?true:false;
362 362
 	}
363 363
 	
364 364
 	/**
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	public function hex2str($hex) {
370 370
 		$str = '';
371 371
 		$hexln = strlen($hex);
372
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
372
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
373 373
 		return $str;
374 374
 	}
375 375
 	
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 	* @return	String Return result
380 380
 	*/
381 381
 	public function hex2rgb($hex) {
382
-		$hex = str_replace('#','',$hex);
382
+		$hex = str_replace('#', '', $hex);
383 383
 		return sscanf($hex, "%02x%02x%02x"); 
384 384
 	}
385 385
 	
@@ -387,33 +387,33 @@  discard block
 block discarded – undo
387 387
 		//difference in longitudinal coordinates
388 388
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
389 389
 		//difference in the phi of latitudinal coordinates
390
-		$dPhi = log(tan(deg2rad($lat2) / 2 + M_PI / 4) / tan(deg2rad($lat1) / 2 + M_PI / 4));
390
+		$dPhi = log(tan(deg2rad($lat2)/2 + M_PI/4)/tan(deg2rad($lat1)/2 + M_PI/4));
391 391
 		//we need to recalculate $dLon if it is greater than pi
392
-		if(abs($dLon) > M_PI) {
393
-			if($dLon > 0) {
394
-				$dLon = (2 * M_PI - $dLon) * -1;
392
+		if (abs($dLon) > M_PI) {
393
+			if ($dLon > 0) {
394
+				$dLon = (2*M_PI - $dLon)*-1;
395 395
 			} else {
396
-				$dLon = 2 * M_PI + $dLon;
396
+				$dLon = 2*M_PI + $dLon;
397 397
 			}
398 398
 		}
399 399
 		//return the angle, normalized
400
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
400
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
401 401
 	}
402 402
 
403
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) {
403
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) {
404 404
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
405
-		$a = -($lon2-$lon1);
405
+		$a = -($lon2 - $lon1);
406 406
 		$b = $lat2 - $lat1;
407
-		$c = -($a*$lat1+$b*$lon1);
408
-		$d = $a*$lat3+$b*$lon3+$c;
407
+		$c = -($a*$lat1 + $b*$lon1);
408
+		$d = $a*$lat3 + $b*$lon3 + $c;
409 409
 		if ($d > -$approx && $d < $approx) return true;
410 410
 		else return false;
411 411
 	}
412 412
 	
413 413
 	public function array_merge_noappend() {
414 414
 		$output = array();
415
-		foreach(func_get_args() as $array) {
416
-			foreach($array as $key => $value) {
415
+		foreach (func_get_args() as $array) {
416
+			foreach ($array as $key => $value) {
417 417
 				$output[$key] = isset($output[$key]) ?
418 418
 				array_merge($output[$key], $value) : $value;
419 419
 			}
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 		return $result;
478 478
 	}
479 479
 
480
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){
480
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') {
481 481
 		global $globalMapRefresh;
482 482
 		if ($seconds == '') {
483 483
 			$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
@@ -488,27 +488,27 @@  discard block
 block discarded – undo
488 488
 		$latitude = deg2rad($latitude);
489 489
 		$longitude = deg2rad($longitude);
490 490
 		$bearing = deg2rad($heading); 
491
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
492
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
493
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
491
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
492
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
493
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
494 494
 	}
495 495
 	
496
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
496
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
497 497
 		// distance in meter
498 498
 		$R = 6378.14;
499
-		$latitude1 = $latitude * (M_PI/180);
500
-		$longitude1 = $longitude * (M_PI/180);
501
-		$brng = $bearing * (M_PI/180);
499
+		$latitude1 = $latitude*(M_PI/180);
500
+		$longitude1 = $longitude*(M_PI/180);
501
+		$brng = $bearing*(M_PI/180);
502 502
 		$d = $distance;
503 503
 
504 504
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
505
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
505
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
506 506
 
507
-		$latitude2 = $latitude2 * (180/M_PI);
508
-		$longitude2 = $longitude2 * (180/M_PI);
507
+		$latitude2 = $latitude2*(180/M_PI);
508
+		$longitude2 = $longitude2*(180/M_PI);
509 509
 
510
-		$flat = round ($latitude2,6);
511
-		$flong = round ($longitude2,6);
510
+		$flat = round($latitude2, 6);
511
+		$flong = round($longitude2, 6);
512 512
 /*
513 513
 		$dx = $distance*cos($bearing);
514 514
 		$dy = $distance*sin($bearing);
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 		$flong = $longitude + $dlong;
518 518
 		$flat = $latitude + $dlat;
519 519
 */
520
-		return array('latitude' => $flat,'longitude' => $flong);
520
+		return array('latitude' => $flat, 'longitude' => $flong);
521 521
 	}
522 522
 
523 523
 	/**
@@ -531,14 +531,14 @@  discard block
 block discarded – undo
531 531
 	 * @param integer $level GZIP compression level (default: 9)
532 532
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
533 533
 	 */
534
-	public function gzCompressFile($source, $level = 9){ 
535
-		$dest = $source . '.gz'; 
536
-		$mode = 'wb' . $level; 
534
+	public function gzCompressFile($source, $level = 9) { 
535
+		$dest = $source.'.gz'; 
536
+		$mode = 'wb'.$level; 
537 537
 		$error = false; 
538 538
 		if ($fp_out = gzopen($dest, $mode)) { 
539
-			if ($fp_in = fopen($source,'rb')) { 
539
+			if ($fp_in = fopen($source, 'rb')) { 
540 540
 				while (!feof($fp_in)) 
541
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
541
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
542 542
 				fclose($fp_in); 
543 543
 			} else {
544 544
 				$error = true; 
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 	} 
555 555
 	
556 556
 	public function remove_accents($string) {
557
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
557
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
558 558
 		$chars = array(
559 559
 		    // Decompositions for Latin-1 Supplement
560 560
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
612 612
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
613 613
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
614
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
614
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
615 615
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
616 616
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
617 617
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -627,13 +627,13 @@  discard block
 block discarded – undo
627 627
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
628 628
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
629 629
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
630
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
631
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
632
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
633
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
634
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
635
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
636
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
630
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
631
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
632
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
633
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
634
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
635
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
636
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
637 637
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
638 638
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
639 639
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
668 668
 			if (is_numeric($string[$i]) && $concat_flag) {
669 669
 				$int .= $string[$i];
670
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
670
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
671 671
 				$concat_flag = false;
672 672
 			}
673 673
 		}
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 			$slice = array_slice($arr, $offset + 1, $length);
714 714
 			return implode("", $slice);
715 715
 		} else {
716
-			return mb_substr($string,$offset,$length,'UTF-8');
716
+			return mb_substr($string, $offset, $length, 'UTF-8');
717 717
 		}
718 718
 	}
719 719
 
@@ -723,14 +723,14 @@  discard block
 block discarded – undo
723 723
 		//NOTE: use a trailing slash for folders!!!
724 724
 		//see http://bugs.php.net/bug.php?id=27609
725 725
 		//see http://bugs.php.net/bug.php?id=30931
726
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
726
+		if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path
727 727
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
728 728
 		else if (is_dir($path))
729 729
 			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
730 730
 		// check tmp file for read/write capabilities
731 731
 		$rm = file_exists($path);
732 732
 		$f = @fopen($path, 'a');
733
-		if ($f===false)
733
+		if ($f === false)
734 734
 			return false;
735 735
 		fclose($f);
736 736
 		if (!$rm)
@@ -749,29 +749,29 @@  discard block
 block discarded – undo
749 749
 	 * @param Integer $offset Controls the likelyhood that lines will be split which cross the dateline
750 750
 	 * @return Array Coordinate of the route
751 751
 	*/
752
-	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
753
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
752
+	public function greatcircle($begin_lat, $begin_lon, $end_lat, $end_lon, $nbpts = 20, $offset = 10) {
753
+		if ($nbpts <= 2) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
754 754
 		$sx = deg2rad($begin_lon);
755 755
 		$sy = deg2rad($begin_lat);
756 756
 		$ex = deg2rad($end_lon);
757 757
 		$ey = deg2rad($end_lat);
758 758
 		$w = $sx - $ex;
759 759
 		$h = $sy - $ey;
760
-		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
760
+		$z = pow(sin($h/2.0), 2) + cos($sy)*cos($ey)*pow(sin($w/2.0), 2);
761 761
 		$g = 2.0*asin(sqrt($z));
762
-		if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
762
+		if ($g == M_PI || is_nan($g)) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
763 763
 		$first_pass = array();
764
-		$delta = 1.0/($nbpts-1);
765
-		for ($i =0; $i < $nbpts; ++$i) {
764
+		$delta = 1.0/($nbpts - 1);
765
+		for ($i = 0; $i < $nbpts; ++$i) {
766 766
 			$step = $delta*$i;
767
-			$A = sin((1 - $step) * $g) / sin($g);
768
-			$B = sin($step * $g) / sin($g);
769
-			$x = $A * cos($sy) * cos($sx) + $B * cos($ey) * cos($ex);
770
-			$y = $A * cos($sy) * sin($sx) + $B * cos($ey) * sin($ex);
771
-			$z = $A * sin($sy) + $B * sin($ey);
767
+			$A = sin((1 - $step)*$g)/sin($g);
768
+			$B = sin($step*$g)/sin($g);
769
+			$x = $A*cos($sy)*cos($sx) + $B*cos($ey)*cos($ex);
770
+			$y = $A*cos($sy)*sin($sx) + $B*cos($ey)*sin($ex);
771
+			$z = $A*sin($sy) + $B*sin($ey);
772 772
 			$lat = rad2deg(atan2($z, sqrt(pow($x, 2) + pow($y, 2))));
773 773
 			$lon = rad2deg(atan2($y, $x));
774
-			$first_pass[] = array($lon,$lat);
774
+			$first_pass[] = array($lon, $lat);
775 775
 		}
776 776
 		$bHasBigDiff = false;
777 777
 		$dfMaxSmallDiffLong = 0;
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 		// https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342
787 787
 		$first_pass_ln = count($first_pass);
788 788
 		for ($j = 1; $j < $first_pass_ln; ++$j) {
789
-			$dfPrevX = $first_pass[$j-1][0];
789
+			$dfPrevX = $first_pass[$j - 1][0];
790 790
 			$dfX = $first_pass[$j][0];
791 791
 			$dfDiffLong = abs($dfX - $dfPrevX);
792 792
 			if ($dfDiffLong > $dfDiffSpace &&
@@ -804,14 +804,14 @@  discard block
 block discarded – undo
804 804
 			//$poMulti[] = $poNewLS;
805 805
 			for ($k = 0; $k < $first_pass_ln; ++$k) {
806 806
 				$dfX0 = floatval($first_pass[$k][0]);
807
-				if ($k > 0 &&  abs($dfX0 - $first_pass[$k-1][0]) > $dfDiffSpace) {
808
-					$dfX1 = floatval($first_pass[$k-1][0]);
809
-					$dfY1 = floatval($first_pass[$k-1][1]);
807
+				if ($k > 0 && abs($dfX0 - $first_pass[$k - 1][0]) > $dfDiffSpace) {
808
+					$dfX1 = floatval($first_pass[$k - 1][0]);
809
+					$dfY1 = floatval($first_pass[$k - 1][1]);
810 810
 					$dfX2 = floatval($first_pass[$k][0]);
811 811
 					$dfY2 = floatval($first_pass[$k][1]);
812 812
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
813
-					    $k+1 < count($first_pass) &&
814
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
813
+					    $k + 1 < count($first_pass) &&
814
+					    $first_pass[$k - 1][0] > -180 && $first_pass[$k - 1][0] < $dfRightBorderX)
815 815
 					{
816 816
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
817 817
 						$k++;
@@ -819,8 +819,8 @@  discard block
 block discarded – undo
819 819
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
820 820
 						continue;
821 821
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
822
-					    $k+1 < $first_pass_ln &&
823
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
822
+					    $k + 1 < $first_pass_ln &&
823
+					    $first_pass[$k - 1][0] > $dfLeftBorderX && $first_pass[$k - 1][0] < 180)
824 824
 					{
825 825
 						$poNewLS[] = array(180, $first_pass[$k][1]);
826 826
 						$k++;
@@ -843,12 +843,12 @@  discard block
 block discarded – undo
843 843
 					}
844 844
 					if ($dfX1 <= 180 && $dfX2 >= 180 && $dfX1 < $dfX2)
845 845
 					{
846
-						$dfRatio = (180 - $dfX1) / ($dfX2 - $dfX1);
847
-						$dfY = $dfRatio * $dfY2 + (1 - $dfRatio) * $dfY1;
848
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
846
+						$dfRatio = (180 - $dfX1)/($dfX2 - $dfX1);
847
+						$dfY = $dfRatio*$dfY2 + (1 - $dfRatio)*$dfY1;
848
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
849 849
 						$poMulti[] = $poNewLS;
850 850
 						$poNewLS = array();
851
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
851
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
852 852
 						//$poMulti[] = $poNewLS;
853 853
 					} else {
854 854
 						//$poNewLS[] = array();
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 			$poNewLS0 = array();
867 867
 			//$poMulti[] = $poNewLS0;
868 868
 			for ($l = 0; $l < $first_pass_ln; ++$l) {
869
-				$poNewLS0[] = array($first_pass[$l][0],$first_pass[$l][1]);
869
+				$poNewLS0[] = array($first_pass[$l][0], $first_pass[$l][1]);
870 870
 			}
871 871
 			$poMulti[] = $poNewLS0;
872 872
 		}
Please login to merge, or discard this patch.
Braces   +110 added lines, -48 removed lines patch added patch discarded remove patch
@@ -37,8 +37,11 @@  discard block
 block discarded – undo
37 37
 		} else {
38 38
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
39 39
 		}
40
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
40
+		if ($timeout == '') {
41
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
42
+		} else {
43
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
44
+		}
42 45
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
43 46
 		if ($type == 'post') {
44 47
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -51,7 +54,9 @@  discard block
 block discarded – undo
51 54
 			} else {
52 55
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
53 56
 			}
54
-		} elseif ($type != 'get' && $type != '') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
57
+		} elseif ($type != 'get' && $type != '') {
58
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
59
+		}
55 60
 		if ($headers != '') {
56 61
 			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
57 62
 		}
@@ -95,8 +100,9 @@  discard block
 block discarded – undo
95 100
 	private function curlResponseHeaderCallback($ch, $headerLine) {
96 101
 		//global $cookies;
97 102
 		$cookies = array();
98
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
99
-			$cookies[] = $cookie;
103
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
104
+					$cookies[] = $cookie;
105
+		}
100 106
 		return strlen($headerLine); // Needed by curl
101 107
 	}
102 108
 
@@ -107,7 +113,9 @@  discard block
 block discarded – undo
107 113
 		curl_setopt($ch, CURLOPT_URL, $url);
108 114
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
109 115
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
110
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
116
+		if ($referer != '') {
117
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
118
+		}
111 119
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
112 120
 			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
113 121
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
@@ -119,7 +127,9 @@  discard block
 block discarded – undo
119 127
 		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');
120 128
 		curl_setopt($ch, CURLOPT_FILE, $fp);
121 129
 		curl_exec($ch);
122
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
130
+		if (curl_errno($ch) && $globalDebug) {
131
+			echo 'Download error: '.curl_error($ch);
132
+		}
123 133
 		curl_close($ch);
124 134
 		fclose($fp);
125 135
 	}
@@ -127,12 +137,16 @@  discard block
 block discarded – undo
127 137
 	public static function gunzip($in_file,$out_file_name = '') {
128 138
 		//echo $in_file.' -> '.$out_file_name."\n";
129 139
 		$buffer_size = 4096; // read 4kb at a time
130
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
140
+		if ($out_file_name == '') {
141
+			$out_file_name = str_replace('.gz', '', $in_file);
142
+		}
131 143
 		if ($in_file != '' && file_exists($in_file)) {
132 144
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
133
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
134
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
135
-			else {
145
+			if (function_exists('gzopen')) {
146
+				$file = gzopen($in_file,'rb');
147
+			} elseif (function_exists('gzopen64')) {
148
+				$file = gzopen64($in_file,'rb');
149
+			} else {
136 150
 				echo 'gzopen not available';
137 151
 				die;
138 152
 			}
@@ -148,11 +162,14 @@  discard block
 block discarded – undo
148 162
 	public static function bunzip2($in_file,$out_file_name = '') {
149 163
 		//echo $in_file.' -> '.$out_file_name."\n";
150 164
 		$buffer_size = 4096; // read 4kb at a time
151
-		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
165
+		if ($out_file_name == '') {
166
+			$out_file_name = str_replace('.bz2', '', $in_file);
167
+		}
152 168
 		if ($in_file != '' && file_exists($in_file)) {
153 169
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
154
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
155
-			else {
170
+			if (function_exists('bzopen')) {
171
+				$file = bzopen($in_file,'rb');
172
+			} else {
156 173
 				echo 'bzopen not available';
157 174
 				die;
158 175
 			}
@@ -171,10 +188,16 @@  discard block
 block discarded – undo
171 188
 	* @return Array array of the tables in HTML page
172 189
 	*/
173 190
 	public function table2array($data) {
174
-		if (!is_string($data)) return array();
175
-		if ($data == '') return array();
191
+		if (!is_string($data)) {
192
+			return array();
193
+		}
194
+		if ($data == '') {
195
+			return array();
196
+		}
176 197
 		$html = str_get_html($data);
177
-		if ($html === false) return array();
198
+		if ($html === false) {
199
+			return array();
200
+		}
178 201
 		$tabledata=array();
179 202
 		foreach($html->find('tr') as $element)
180 203
 		{
@@ -209,7 +232,9 @@  discard block
 block discarded – undo
209 232
 	*/
210 233
 	public function text2array($data) {
211 234
 		$html = str_get_html($data);
212
-		if ($html === false) return array();
235
+		if ($html === false) {
236
+			return array();
237
+		}
213 238
 		$tabledata=array();
214 239
 		foreach($html->find('p') as $element)
215 240
 		{
@@ -230,7 +255,9 @@  discard block
 block discarded – undo
230 255
 	* @return Float Distance in $unit
231 256
 	*/
232 257
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233
-		if ($lat == $latc && $lon == $lonc) return 0;
258
+		if ($lat == $latc && $lon == $lonc) {
259
+			return 0;
260
+		}
234 261
 		$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;
235 262
 		if ($unit == "km") {
236 263
 			return round($dist * 1.609344);
@@ -276,7 +303,9 @@  discard block
 block discarded – undo
276 303
 		$dX = $latc - $lat;
277 304
 		$dY = $lonc - $lon;
278 305
 		$azimuth = rad2deg(atan2($dY,$dX));
279
-		if ($azimuth < 0) return $azimuth+360;
306
+		if ($azimuth < 0) {
307
+			return $azimuth+360;
308
+		}
280 309
 		return $azimuth;
281 310
 	}
282 311
 	
@@ -290,10 +319,16 @@  discard block
 block discarded – undo
290 319
 	public function withinThreshold ($timeDifference, $distance) {
291 320
 		$x = abs($timeDifference);
292 321
 		$d = abs($distance);
293
-		if ($x == 0 || $d == 0) return true;
322
+		if ($x == 0 || $d == 0) {
323
+			return true;
324
+		}
294 325
 		// may be due to Internet jitter; distance is realistic
295
-		if ($x < 0.7 && $d < 2000) return true;
296
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
326
+		if ($x < 0.7 && $d < 2000) {
327
+			return true;
328
+		} else {
329
+			return $d/$x < 1500*0.27778;
330
+		}
331
+		// 1500 km/h max
297 332
 	}
298 333
 
299 334
 
@@ -322,11 +357,17 @@  discard block
 block discarded – undo
322 357
 	
323 358
 	public function convertDM($coord,$latlong) {
324 359
 		if ($latlong == 'latitude') {
325
-			if ($coord < 0) $NSEW = 'S';
326
-			else $NSEW = 'N';
360
+			if ($coord < 0) {
361
+				$NSEW = 'S';
362
+			} else {
363
+				$NSEW = 'N';
364
+			}
327 365
 		} else {
328
-			if ($coord < 0) $NSEW = 'W';
329
-			else $NSEW = 'E';
366
+			if ($coord < 0) {
367
+				$NSEW = 'W';
368
+			} else {
369
+				$NSEW = 'E';
370
+			}
330 371
 		}
331 372
 		$coord = abs($coord);
332 373
 		$deg = floor($coord);
@@ -369,7 +410,9 @@  discard block
 block discarded – undo
369 410
 	public function hex2str($hex) {
370 411
 		$str = '';
371 412
 		$hexln = strlen($hex);
372
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
413
+		for($i=0;$i<$hexln;$i+=2) {
414
+			$str .= chr(hexdec(substr($hex,$i,2)));
415
+		}
373 416
 		return $str;
374 417
 	}
375 418
 	
@@ -406,8 +449,11 @@  discard block
 block discarded – undo
406 449
 		$b = $lat2 - $lat1;
407 450
 		$c = -($a*$lat1+$b*$lon1);
408 451
 		$d = $a*$lat3+$b*$lon3+$c;
409
-		if ($d > -$approx && $d < $approx) return true;
410
-		else return false;
452
+		if ($d > -$approx && $d < $approx) {
453
+			return true;
454
+		} else {
455
+			return false;
456
+		}
411 457
 	}
412 458
 	
413 459
 	public function array_merge_noappend() {
@@ -466,7 +512,9 @@  discard block
 block discarded – undo
466 512
 			return $result;
467 513
 		}
468 514
 		$handle = @opendir('./locale');
469
-		if ($handle === false) return $result;
515
+		if ($handle === false) {
516
+			return $result;
517
+		}
470 518
 		while (false !== ($file = readdir($handle))) {
471 519
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
472 520
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -537,8 +585,9 @@  discard block
 block discarded – undo
537 585
 		$error = false; 
538 586
 		if ($fp_out = gzopen($dest, $mode)) { 
539 587
 			if ($fp_in = fopen($source,'rb')) { 
540
-				while (!feof($fp_in)) 
541
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
588
+				while (!feof($fp_in)) {
589
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
590
+				}
542 591
 				fclose($fp_in); 
543 592
 			} else {
544 593
 				$error = true; 
@@ -547,14 +596,17 @@  discard block
 block discarded – undo
547 596
 		} else {
548 597
 			$error = true; 
549 598
 		}
550
-		if ($error)
551
-			return false; 
552
-		else
553
-			return $dest; 
599
+		if ($error) {
600
+					return false;
601
+		} else {
602
+					return $dest;
603
+		}
554 604
 	} 
555 605
 	
556 606
 	public function remove_accents($string) {
557
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
607
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
608
+			return $string;
609
+		}
558 610
 		$chars = array(
559 611
 		    // Decompositions for Latin-1 Supplement
560 612
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -678,7 +730,9 @@  discard block
 block discarded – undo
678 730
 		$ip = gethostbyname($host);
679 731
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
680 732
 		$r = @socket_connect($s, $ip, $port);
681
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
733
+		if (!socket_set_nonblock($s)) {
734
+			echo "Unable to set nonblock on socket\n";
735
+		}
682 736
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
683 737
 			return $s;
684 738
 		}
@@ -723,18 +777,22 @@  discard block
 block discarded – undo
723 777
 		//NOTE: use a trailing slash for folders!!!
724 778
 		//see http://bugs.php.net/bug.php?id=27609
725 779
 		//see http://bugs.php.net/bug.php?id=30931
726
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
780
+		if ($path{strlen($path)-1}=='/') {
781
+			// recursively return a temporary file path
727 782
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
728
-		else if (is_dir($path))
729
-			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
783
+		} else if (is_dir($path)) {
784
+					return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
785
+		}
730 786
 		// check tmp file for read/write capabilities
731 787
 		$rm = file_exists($path);
732 788
 		$f = @fopen($path, 'a');
733
-		if ($f===false)
734
-			return false;
789
+		if ($f===false) {
790
+					return false;
791
+		}
735 792
 		fclose($f);
736
-		if (!$rm)
737
-			unlink($path);
793
+		if (!$rm) {
794
+					unlink($path);
795
+		}
738 796
 		return true;
739 797
 	}
740 798
 	
@@ -750,7 +808,9 @@  discard block
 block discarded – undo
750 808
 	 * @return Array Coordinate of the route
751 809
 	*/
752 810
 	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
753
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
811
+		if ($nbpts <= 2) {
812
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
813
+		}
754 814
 		$sx = deg2rad($begin_lon);
755 815
 		$sy = deg2rad($begin_lat);
756 816
 		$ex = deg2rad($end_lon);
@@ -759,7 +819,9 @@  discard block
 block discarded – undo
759 819
 		$h = $sy - $ey;
760 820
 		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
761 821
 		$g = 2.0*asin(sqrt($z));
762
-		if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
822
+		if ($g == M_PI || is_nan($g)) {
823
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
824
+		}
763 825
 		$first_pass = array();
764 826
 		$delta = 1.0/($nbpts-1);
765 827
 		for ($i =0; $i < $nbpts; ++$i) {
Please login to merge, or discard this patch.