Completed
Push — master ( 6ab92f...6e8bf5 )
by Yannick
36:39
created
require/class.Common.php 1 patch
Spacing   +92 added lines, -92 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
 		return $plunge;
258 258
 	}
259 259
 
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	public function azimuth($lat, $lon, $latc, $lonc) {
269 269
 		$dX = $latc - $lat;
270 270
 		$dY = $lonc - $lon;
271
-		$azimuth = rad2deg(atan2($dY,$dX));
272
-		if ($azimuth < 0) return $azimuth+360;
271
+		$azimuth = rad2deg(atan2($dY, $dX));
272
+		if ($azimuth < 0) return $azimuth + 360;
273 273
 		return $azimuth;
274 274
 	}
275 275
 	
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	* @param float $distance distance covered
281 281
 	* @return whether distance is realistic
282 282
 	*/
283
-	public function withinThreshold ($timeDifference, $distance) {
283
+	public function withinThreshold($timeDifference, $distance) {
284 284
 		$x = abs($timeDifference);
285 285
 		$d = abs($distance);
286 286
 		if ($x == 0 || $d == 0) return true;
@@ -296,12 +296,12 @@  discard block
 block discarded – undo
296 296
 		return ($array !== array_values($array));
297 297
 	}
298 298
 
299
-	public function isInteger($input){
299
+	public function isInteger($input) {
300 300
 	    return(ctype_digit(strval($input)));
301 301
 	}
302 302
 
303 303
 
304
-	public function convertDec($dms,$latlong) {
304
+	public function convertDec($dms, $latlong) {
305 305
 		if ($latlong == 'latitude') {
306 306
 			$deg = substr($dms, 0, 2);
307 307
 			$min = substr($dms, 2, 4);
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
 			$deg = substr($dms, 0, 3);
310 310
 			$min = substr($dms, 3, 5);
311 311
 		}
312
-		return $deg+(($min*60)/3600);
312
+		return $deg + (($min*60)/3600);
313 313
 	}
314 314
 	
315
-	public function convertDM($coord,$latlong) {
315
+	public function convertDM($coord, $latlong) {
316 316
 		if ($latlong == 'latitude') {
317 317
 			if ($coord < 0) $NSEW = 'S';
318 318
 			else $NSEW = 'N';
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 		}
323 323
 		$coord = abs($coord);
324 324
 		$deg = floor($coord);
325
-		$coord = ($coord-$deg)*60;
325
+		$coord = ($coord - $deg)*60;
326 326
 		$min = $coord;
327
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
327
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
328 328
 	}
329 329
 	
330 330
 	/**
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	public function xcopy($source, $dest)
337 337
 	{
338 338
 		$files = glob($source.'*.*');
339
-		foreach($files as $file){
340
-			$file_to_go = str_replace($source,$dest,$file);
339
+		foreach ($files as $file) {
340
+			$file_to_go = str_replace($source, $dest, $file);
341 341
 			copy($file, $file_to_go);
342 342
 		}
343 343
 		return true;
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 	* @param	String $url url to check
349 349
 	* @return	bool Return true on succes false on failure
350 350
 	*/
351
-	public function urlexist($url){
352
-		$headers=get_headers($url);
353
-		return stripos($headers[0],"200 OK")?true:false;
351
+	public function urlexist($url) {
352
+		$headers = get_headers($url);
353
+		return stripos($headers[0], "200 OK") ?true:false;
354 354
 	}
355 355
 	
356 356
 	/**
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	public function hex2str($hex) {
362 362
 		$str = '';
363 363
 		$hexln = strlen($hex);
364
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
364
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
365 365
 		return $str;
366 366
 	}
367 367
 	
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	* @return	String Return result
372 372
 	*/
373 373
 	public function hex2rgb($hex) {
374
-		$hex = str_replace('#','',$hex);
374
+		$hex = str_replace('#', '', $hex);
375 375
 		return sscanf($hex, "%02x%02x%02x"); 
376 376
 	}
377 377
 	
@@ -379,33 +379,33 @@  discard block
 block discarded – undo
379 379
 		//difference in longitudinal coordinates
380 380
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
381 381
 		//difference in the phi of latitudinal coordinates
382
-		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
382
+		$dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4));
383 383
 		//we need to recalculate $dLon if it is greater than pi
384
-		if(abs($dLon) > pi()) {
385
-			if($dLon > 0) {
386
-				$dLon = (2 * pi() - $dLon) * -1;
384
+		if (abs($dLon) > pi()) {
385
+			if ($dLon > 0) {
386
+				$dLon = (2*pi() - $dLon)*-1;
387 387
 			} else {
388
-				$dLon = 2 * pi() + $dLon;
388
+				$dLon = 2*pi() + $dLon;
389 389
 			}
390 390
 		}
391 391
 		//return the angle, normalized
392
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
392
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
393 393
 	}
394 394
 
395
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) {
395
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) {
396 396
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
397
-		$a = -($lon2-$lon1);
397
+		$a = -($lon2 - $lon1);
398 398
 		$b = $lat2 - $lat1;
399
-		$c = -($a*$lat1+$b*$lon1);
400
-		$d = $a*$lat3+$b*$lon3+$c;
399
+		$c = -($a*$lat1 + $b*$lon1);
400
+		$d = $a*$lat3 + $b*$lon3 + $c;
401 401
 		if ($d > -$approx && $d < $approx) return true;
402 402
 		else return false;
403 403
 	}
404 404
 	
405 405
 	public function array_merge_noappend() {
406 406
 		$output = array();
407
-		foreach(func_get_args() as $array) {
408
-			foreach($array as $key => $value) {
407
+		foreach (func_get_args() as $array) {
408
+			foreach ($array as $key => $value) {
409 409
 				$output[$key] = isset($output[$key]) ?
410 410
 				array_merge($output[$key], $value) : $value;
411 411
 			}
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 		return $result;
470 470
 	}
471 471
 
472
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){
472
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') {
473 473
 		global $globalMapRefresh;
474 474
 		if ($seconds == '') {
475 475
 			$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
@@ -480,27 +480,27 @@  discard block
 block discarded – undo
480 480
 		$latitude = deg2rad($latitude);
481 481
 		$longitude = deg2rad($longitude);
482 482
 		$bearing = deg2rad($heading); 
483
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
484
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
485
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
483
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
484
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
485
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
486 486
 	}
487 487
 	
488
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
488
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
489 489
 		// distance in meter
490 490
 		$R = 6378.14;
491
-		$latitude1 = $latitude * (M_PI/180);
492
-		$longitude1 = $longitude * (M_PI/180);
493
-		$brng = $bearing * (M_PI/180);
491
+		$latitude1 = $latitude*(M_PI/180);
492
+		$longitude1 = $longitude*(M_PI/180);
493
+		$brng = $bearing*(M_PI/180);
494 494
 		$d = $distance;
495 495
 
496 496
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
497
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
497
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
498 498
 
499
-		$latitude2 = $latitude2 * (180/M_PI);
500
-		$longitude2 = $longitude2 * (180/M_PI);
499
+		$latitude2 = $latitude2*(180/M_PI);
500
+		$longitude2 = $longitude2*(180/M_PI);
501 501
 
502
-		$flat = round ($latitude2,6);
503
-		$flong = round ($longitude2,6);
502
+		$flat = round($latitude2, 6);
503
+		$flong = round($longitude2, 6);
504 504
 /*
505 505
 		$dx = $distance*cos($bearing);
506 506
 		$dy = $distance*sin($bearing);
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		$flong = $longitude + $dlong;
510 510
 		$flat = $latitude + $dlat;
511 511
 */
512
-		return array('latitude' => $flat,'longitude' => $flong);
512
+		return array('latitude' => $flat, 'longitude' => $flong);
513 513
 	}
514 514
 
515 515
 	/**
@@ -523,14 +523,14 @@  discard block
 block discarded – undo
523 523
 	 * @param integer $level GZIP compression level (default: 9)
524 524
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
525 525
 	 */
526
-	public function gzCompressFile($source, $level = 9){ 
527
-		$dest = $source . '.gz'; 
528
-		$mode = 'wb' . $level; 
526
+	public function gzCompressFile($source, $level = 9) { 
527
+		$dest = $source.'.gz'; 
528
+		$mode = 'wb'.$level; 
529 529
 		$error = false; 
530 530
 		if ($fp_out = gzopen($dest, $mode)) { 
531
-			if ($fp_in = fopen($source,'rb')) { 
531
+			if ($fp_in = fopen($source, 'rb')) { 
532 532
 				while (!feof($fp_in)) 
533
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
533
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
534 534
 				fclose($fp_in); 
535 535
 			} else {
536 536
 				$error = true; 
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	} 
547 547
 	
548 548
 	public function remove_accents($string) {
549
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
549
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
550 550
 		$chars = array(
551 551
 		    // Decompositions for Latin-1 Supplement
552 552
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
604 604
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
605 605
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
606
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
606
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
607 607
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
608 608
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
609 609
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -619,13 +619,13 @@  discard block
 block discarded – undo
619 619
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
620 620
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
621 621
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
622
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
623
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
624
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
625
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
626
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
627
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
628
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
622
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
623
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
624
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
625
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
626
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
627
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
628
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
629 629
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
630 630
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
631 631
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
660 660
 			if (is_numeric($string[$i]) && $concat_flag) {
661 661
 				$int .= $string[$i];
662
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
662
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
663 663
 				$concat_flag = false;
664 664
 			}
665 665
 		}
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 			$slice = array_slice($arr, $offset + 1, $length);
706 706
 			return implode("", $slice);
707 707
 		} else {
708
-			return mb_substr($string,$offset,$length,'UTF-8');
708
+			return mb_substr($string, $offset, $length, 'UTF-8');
709 709
 		}
710 710
 	}
711 711
 
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 		//NOTE: use a trailing slash for folders!!!
716 716
 		//see http://bugs.php.net/bug.php?id=27609
717 717
 		//see http://bugs.php.net/bug.php?id=30931
718
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
718
+		if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path
719 719
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
720 720
 		else if (is_dir($path))
721 721
 			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
722 722
 		// check tmp file for read/write capabilities
723 723
 		$rm = file_exists($path);
724 724
 		$f = @fopen($path, 'a');
725
-		if ($f===false)
725
+		if ($f === false)
726 726
 			return false;
727 727
 		fclose($f);
728 728
 		if (!$rm)
Please login to merge, or discard this patch.