Completed
Push — master ( 583e49...31027a )
by Yannick
30:38
created
require/class.Common.php 2 patches
Indentation   +161 added lines, -161 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,25 +246,25 @@  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
 		return $plunge;
258 258
 	}
259 259
 
260 260
 	/**
261
-	* Give azimuth between 2 coordonnates
262
-	* @param Float $lat latitude of first point
263
-	* @param Float $lon longitude of first point
264
-	* @param Float $latc latitude of second point
265
-	* @param Float $lonc longitude of second point
266
-	* @return Float Azimuth
267
-	*/
261
+	 * Give azimuth between 2 coordonnates
262
+	 * @param Float $lat latitude of first point
263
+	 * @param Float $lon longitude of first point
264
+	 * @param Float $latc latitude of second point
265
+	 * @param Float $lonc longitude of second point
266
+	 * @return Float Azimuth
267
+	 */
268 268
 	public function azimuth($lat, $lon, $latc, $lonc) {
269 269
 		$dX = $latc - $lat;
270 270
 		$dY = $lonc - $lon;
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 	
276 276
 	
277 277
 	/**
278
-	* Check is distance realistic
279
-	* @param int $timeDifference the time between the reception of both messages
280
-	* @param float $distance distance covered
281
-	* @return whether distance is realistic
282
-	*/
278
+	 * Check is distance realistic
279
+	 * @param int $timeDifference the time between the reception of both messages
280
+	 * @param float $distance distance covered
281
+	 * @return whether distance is realistic
282
+	 */
283 283
 	public function withinThreshold ($timeDifference, $distance) {
284 284
 		$x = abs($timeDifference);
285 285
 		$d = abs($distance);
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	}
298 298
 
299 299
 	public function isInteger($input){
300
-	    return(ctype_digit(strval($input)));
300
+		return(ctype_digit(strval($input)));
301 301
 	}
302 302
 
303 303
 
@@ -328,11 +328,11 @@  discard block
 block discarded – undo
328 328
 	}
329 329
 	
330 330
 	/**
331
-	* Copy folder contents
332
-	* @param       string   $source    Source path
333
-	* @param       string   $dest      Destination path
334
-	* @return      bool     Returns true on success, false on failure
335
-	*/
331
+	 * Copy folder contents
332
+	 * @param       string   $source    Source path
333
+	 * @param       string   $dest      Destination path
334
+	 * @return      bool     Returns true on success, false on failure
335
+	 */
336 336
 	public function xcopy($source, $dest)
337 337
 	{
338 338
 		$files = glob($source.'*.*');
@@ -344,20 +344,20 @@  discard block
 block discarded – undo
344 344
 	}
345 345
 	
346 346
 	/**
347
-	* Check if an url exist
348
-	* @param	String $url url to check
349
-	* @return	bool Return true on succes false on failure
350
-	*/
347
+	 * Check if an url exist
348
+	 * @param	String $url url to check
349
+	 * @return	bool Return true on succes false on failure
350
+	 */
351 351
 	public function urlexist($url){
352 352
 		$headers=get_headers($url);
353 353
 		return stripos($headers[0],"200 OK")?true:false;
354 354
 	}
355 355
 	
356 356
 	/**
357
-	* Convert hexa to string
358
-	* @param	String $hex data in hexa
359
-	* @return	String Return result
360
-	*/
357
+	 * Convert hexa to string
358
+	 * @param	String $hex data in hexa
359
+	 * @return	String Return result
360
+	 */
361 361
 	public function hex2str($hex) {
362 362
 		$str = '';
363 363
 		$hexln = strlen($hex);
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 	}
367 367
 	
368 368
 	/**
369
-	* Convert hexa color to rgb
370
-	* @param	String $hex data in hexa
371
-	* @return	String Return result
372
-	*/
369
+	 * Convert hexa color to rgb
370
+	 * @param	String $hex data in hexa
371
+	 * @return	String Return result
372
+	 */
373 373
 	public function hex2rgb($hex) {
374 374
 		$hex = str_replace('#','',$hex);
375 375
 		return sscanf($hex, "%02x%02x%02x"); 
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
 	}
448 448
 	
449 449
 	/**
450
-	* Returns list of available locales
451
-	*
452
-	* @return array
450
+	 * Returns list of available locales
451
+	 *
452
+	 * @return array
453 453
 	 */
454 454
 	public function listLocaleDir()
455 455
 	{
@@ -548,100 +548,100 @@  discard block
 block discarded – undo
548 548
 	public function remove_accents($string) {
549 549
 		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
550 550
 		$chars = array(
551
-		    // Decompositions for Latin-1 Supplement
552
-		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
553
-		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
554
-		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
555
-		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
556
-		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
557
-		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
558
-		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
559
-		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
560
-		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
561
-		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
562
-		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
563
-		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
564
-		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
565
-		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
566
-		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
567
-		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
568
-		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
569
-		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
570
-		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
571
-		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
572
-		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
573
-		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
574
-		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
575
-		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
576
-		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
577
-		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
578
-		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
579
-		    chr(195).chr(191) => 'y',
580
-		    // Decompositions for Latin Extended-A
581
-		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
582
-		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
583
-		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
584
-		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
585
-		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
586
-		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
587
-		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
588
-		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
589
-		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
590
-		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
591
-		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
592
-		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
593
-		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
594
-		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
595
-		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
596
-		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
597
-		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
598
-		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
599
-		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
600
-		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
601
-		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
602
-		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
603
-		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
604
-		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
605
-		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
606
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
607
-		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
608
-		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
609
-		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
610
-		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
611
-		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
612
-		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
613
-		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
614
-		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
615
-		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
616
-		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
617
-		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
618
-		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
619
-		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
620
-		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
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',
629
-		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
630
-		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
631
-		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
632
-		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
633
-		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
634
-		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
635
-		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
636
-		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
637
-		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
638
-		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
639
-		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
640
-		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
641
-		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
642
-		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
643
-		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
644
-		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
551
+			// Decompositions for Latin-1 Supplement
552
+			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
553
+			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
554
+			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
555
+			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
556
+			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
557
+			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
558
+			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
559
+			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
560
+			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
561
+			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
562
+			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
563
+			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
564
+			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
565
+			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
566
+			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
567
+			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
568
+			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
569
+			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
570
+			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
571
+			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
572
+			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
573
+			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
574
+			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
575
+			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
576
+			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
577
+			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
578
+			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
579
+			chr(195).chr(191) => 'y',
580
+			// Decompositions for Latin Extended-A
581
+			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
582
+			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
583
+			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
584
+			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
585
+			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
586
+			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
587
+			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
588
+			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
589
+			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
590
+			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
591
+			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
592
+			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
593
+			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
594
+			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
595
+			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
596
+			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
597
+			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
598
+			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
599
+			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
600
+			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
601
+			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
602
+			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
603
+			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
604
+			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
605
+			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
606
+			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
607
+			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
608
+			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
609
+			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
610
+			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
611
+			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
612
+			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
613
+			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
614
+			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
615
+			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
616
+			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
617
+			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
618
+			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
619
+			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
620
+			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
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',
629
+			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
630
+			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
631
+			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
632
+			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
633
+			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
634
+			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
635
+			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
636
+			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
637
+			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
638
+			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
639
+			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
640
+			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
641
+			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
642
+			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
643
+			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
644
+			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
645 645
 		);
646 646
 		$string = strtr($string, $chars);
647 647
 		return $string;
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 			$dfX = $first_pass[$j][0];
783 783
 			$dfDiffLong = abs($dfX - $dfPrevX);
784 784
 			if ($dfDiffLong > $dfDiffSpace &&
785
-			    (($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
785
+				(($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
786 786
 			{
787 787
 				$bHasBigDiff = true;
788 788
 			} else if ($dfDiffLong > $dfMaxSmallDiffLong) {
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
 					$dfX2 = floatval($first_pass[$k][0]);
803 803
 					$dfY2 = floatval($first_pass[$k][1]);
804 804
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
805
-					    $k+1 < count($first_pass) &&
806
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
805
+						$k+1 < count($first_pass) &&
806
+						$first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
807 807
 					{
808 808
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
809 809
 						$k++;
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
812 812
 						continue;
813 813
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
814
-					    $k+1 < $first_pass_ln &&
815
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
814
+						$k+1 < $first_pass_ln &&
815
+						$first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
816 816
 					{
817 817
 						$poNewLS[] = array(180, $first_pass[$k][1]);
818 818
 						$k++;
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 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)
@@ -741,29 +741,29 @@  discard block
 block discarded – undo
741 741
 	 * @param Integer $offset Controls the likelyhood that lines will be split which cross the dateline
742 742
 	 * @return Array Coordinate of the route
743 743
 	*/
744
-	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
745
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
744
+	public function greatcircle($begin_lat, $begin_lon, $end_lat, $end_lon, $nbpts = 20, $offset = 10) {
745
+		if ($nbpts <= 2) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
746 746
 		$sx = deg2rad($begin_lon);
747 747
 		$sy = deg2rad($begin_lat);
748 748
 		$ex = deg2rad($end_lon);
749 749
 		$ey = deg2rad($end_lat);
750 750
 		$w = $sx - $ex;
751 751
 		$h = $sy - $ey;
752
-		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
752
+		$z = pow(sin($h/2.0), 2) + cos($sy)*cos($ey)*pow(sin($w/2.0), 2);
753 753
 		$g = 2.0*asin(sqrt($z));
754
-		if ($g == pi() || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
754
+		if ($g == pi() || is_nan($g)) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
755 755
 		$first_pass = array();
756
-		$delta = 1.0/($nbpts-1);
757
-		for ($i =0; $i < $nbpts; ++$i) {
756
+		$delta = 1.0/($nbpts - 1);
757
+		for ($i = 0; $i < $nbpts; ++$i) {
758 758
 			$step = $delta*$i;
759
-			$A = sin((1 - $step) * $g) / sin($g);
760
-			$B = sin($step * $g) / sin($g);
761
-			$x = $A * cos($sy) * cos($sx) + $B * cos($ey) * cos($ex);
762
-			$y = $A * cos($sy) * sin($sx) + $B * cos($ey) * sin($ex);
763
-			$z = $A * sin($sy) + $B * sin($ey);
759
+			$A = sin((1 - $step)*$g)/sin($g);
760
+			$B = sin($step*$g)/sin($g);
761
+			$x = $A*cos($sy)*cos($sx) + $B*cos($ey)*cos($ex);
762
+			$y = $A*cos($sy)*sin($sx) + $B*cos($ey)*sin($ex);
763
+			$z = $A*sin($sy) + $B*sin($ey);
764 764
 			$lat = rad2deg(atan2($z, sqrt(pow($x, 2) + pow($y, 2))));
765 765
 			$lon = rad2deg(atan2($y, $x));
766
-			$first_pass[] = array($lon,$lat);
766
+			$first_pass[] = array($lon, $lat);
767 767
 		}
768 768
 		$bHasBigDiff = false;
769 769
 		$dfMaxSmallDiffLong = 0;
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 		// https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342
779 779
 		$first_pass_ln = count($first_pass);
780 780
 		for ($j = 1; $j < $first_pass_ln; ++$j) {
781
-			$dfPrevX = $first_pass[$j-1][0];
781
+			$dfPrevX = $first_pass[$j - 1][0];
782 782
 			$dfX = $first_pass[$j][0];
783 783
 			$dfDiffLong = abs($dfX - $dfPrevX);
784 784
 			if ($dfDiffLong > $dfDiffSpace &&
@@ -796,14 +796,14 @@  discard block
 block discarded – undo
796 796
 			//$poMulti[] = $poNewLS;
797 797
 			for ($k = 0; $k < $first_pass_ln; ++$k) {
798 798
 				$dfX0 = floatval($first_pass[$k][0]);
799
-				if ($k > 0 &&  abs($dfX0 - $first_pass[$k-1][0]) > $dfDiffSpace) {
800
-					$dfX1 = floatval($first_pass[$k-1][0]);
801
-					$dfY1 = floatval($first_pass[$k-1][1]);
799
+				if ($k > 0 && abs($dfX0 - $first_pass[$k - 1][0]) > $dfDiffSpace) {
800
+					$dfX1 = floatval($first_pass[$k - 1][0]);
801
+					$dfY1 = floatval($first_pass[$k - 1][1]);
802 802
 					$dfX2 = floatval($first_pass[$k][0]);
803 803
 					$dfY2 = floatval($first_pass[$k][1]);
804 804
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
805
-					    $k+1 < count($first_pass) &&
806
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
805
+					    $k + 1 < count($first_pass) &&
806
+					    $first_pass[$k - 1][0] > -180 && $first_pass[$k - 1][0] < $dfRightBorderX)
807 807
 					{
808 808
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
809 809
 						$k++;
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
812 812
 						continue;
813 813
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
814
-					    $k+1 < $first_pass_ln &&
815
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
814
+					    $k + 1 < $first_pass_ln &&
815
+					    $first_pass[$k - 1][0] > $dfLeftBorderX && $first_pass[$k - 1][0] < 180)
816 816
 					{
817 817
 						$poNewLS[] = array(180, $first_pass[$k][1]);
818 818
 						$k++;
@@ -835,12 +835,12 @@  discard block
 block discarded – undo
835 835
 					}
836 836
 					if ($dfX1 <= 180 && $dfX2 >= 180 && $dfX1 < $dfX2)
837 837
 					{
838
-						$dfRatio = (180 - $dfX1) / ($dfX2 - $dfX1);
839
-						$dfY = $dfRatio * $dfY2 + (1 - $dfRatio) * $dfY1;
840
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
838
+						$dfRatio = (180 - $dfX1)/($dfX2 - $dfX1);
839
+						$dfY = $dfRatio*$dfY2 + (1 - $dfRatio)*$dfY1;
840
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
841 841
 						$poMulti[] = $poNewLS;
842 842
 						$poNewLS = array();
843
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
843
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
844 844
 						//$poMulti[] = $poNewLS;
845 845
 					} else {
846 846
 						//$poNewLS[] = array();
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 			$poNewLS0 = array();
859 859
 			//$poMulti[] = $poNewLS0;
860 860
 			for ($l = 0; $l < $first_pass_ln; ++$l) {
861
-				$poNewLS0[] = array($first_pass[$l][0],$first_pass[$l][1]);
861
+				$poNewLS0[] = array($first_pass[$l][0], $first_pass[$l][1]);
862 862
 			}
863 863
 			$poMulti[] = $poNewLS0;
864 864
 		}
Please login to merge, or discard this patch.