Completed
Push — master ( b282d7...87953e )
by Yannick
08:34
created

Common::urlexist()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
require_once(dirname(__FILE__).'/libs/simple_html_dom.php');
3
require_once(dirname(__FILE__).'/libs/uagent/uagent.php');
4
5
class Common {
6
	//protected $cookies = array();
7
	
8
	/**
9
	* Get data from form result
10
	* @param String $url form URL
11
	* @param String $type type of submit form method (get or post)
12
	* @param String|Array $data values form post method
13
	* @param Array $headers header to submit with the form
14
	* @return String the result
15
	*/
16
	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
17
		$ch = curl_init();
18
		curl_setopt($ch, CURLOPT_URL, $url);
19
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
20
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
21
		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
22
		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
23
		//curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
24
//		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
25
		if ($useragent == '') {
26
			curl_setopt($ch, CURLOPT_USERAGENT, UAgent::random());
27
		} else {
28
			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
29
		}
30
		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
31
		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
32
		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
33
		if ($type == 'post') {
34
			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
35
			if (is_array($data)) {
36
				curl_setopt($ch, CURLOPT_POST, count($data));
37
				$data_string = '';
38
				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
39
				rtrim($data_string, '&');
40
				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
41
			} else {
42
				curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
43
			}
44
		}
45
		if ($headers != '') {
46
			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
47
		}
48
		if ($cookie != '') {
49
			if (is_array($cookie)) {
50
				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
51
			} else {
52
				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
53
			}
54
		}
55
		if ($referer != '') {
56
			curl_setopt($ch, CURLOPT_REFERER, $referer);
57
		}
58
		$result = curl_exec($ch);
59
		$info = curl_getinfo($ch);
60
		curl_close($ch);
61
		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
62
			echo "Cloudflare Detected\n";
63
			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
64
			$useragent = UAgent::random();
65
			cloudflare::useUserAgent($useragent);
66
			if ($clearanceCookie = cloudflare::bypass($url)) {
67
				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
68
			}
69
		} else {
70
		    return $result;
71
		}
72
	}
73
	
74
	private function curlResponseHeaderCallback($ch, $headerLine) {
75
		//global $cookies;
76
		$cookies = array();
77
		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
78
			$cookies[] = $cookie;
79
		return strlen($headerLine); // Needed by curl
80
	}
81
82
	public static function download($url, $file, $referer = '') {
83
		global $globalDebug;
84
		$fp = fopen($file, 'w');
85
		$ch = curl_init();
86
		curl_setopt($ch, CURLOPT_URL, $url);
87
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
88
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
89
		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
90
		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
91
		curl_setopt($ch, CURLOPT_FILE, $fp);
92
		curl_exec($ch);
93
		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
94
		curl_close($ch);
95
		fclose($fp);
96
	}
97
	
98
	/**
99
	* Convert a HTML table to an array
100
	* @param String $data HTML page
101
	* @return Array array of the tables in HTML page
102
	*/
103
	public function table2array($data) {
104
		if (!is_string($data)) return array();
105
		if ($data == '') return array();
106
		$html = str_get_html($data);
107
		if ($html === false) return array();
108
		$tabledata=array();
109
		foreach($html->find('tr') as $element)
110
		{
111
			$td = array();
112
			foreach( $element->find('th') as $row)
113
			{
114
				$td [] = trim($row->plaintext);
115
			}
116
			$td=array_filter($td);
117
			$tabledata[] = $td;
118
119
			$td = array();
120
			$tdi = array();
121
			foreach( $element->find('td') as $row)
122
			{
123
				$td [] = trim($row->plaintext);
124
				$tdi [] = trim($row->innertext);
125
			}
126
			$td=array_filter($td);
127
			$tdi=array_filter($tdi);
128
			$tabledata[]=array_merge($td,$tdi);
129
		}
130
		$html->clear();
131
		unset($html);
132
		return(array_filter($tabledata));
133
	}
134
	
135
	/**
136
	* Convert <p> part of a HTML page to an array
137
	* @param String $data HTML page
138
	* @return Array array of the <p> in HTML page
139
	*/
140
	public function text2array($data) {
141
		$html = str_get_html($data);
142
		if ($html === false) return array();
143
		$tabledata=array();
144
		foreach($html->find('p') as $element)
145
		{
146
			$tabledata [] = trim($element->plaintext);
147
		}
148
		$html->clear();
149
		unset($html);
150
		return(array_filter($tabledata));
151
	}
152
153
	/**
154
	* Give distance between 2 coordonnates
155
	* @param Float $lat latitude of first point
156
	* @param Float $lon longitude of first point
157
	* @param Float $latc latitude of second point
158
	* @param Float $lonc longitude of second point
159
	* @param String $unit km else no unit used
160
	* @return Float Distance in $unit
161
	*/
162
	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
163
		if ($lat == $latc && $lon == $lonc) return 0;
164
		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
165
		if ($unit == "km") {
166
			return round($dist * 1.609344);
167
		} elseif ($unit == "m") {
168
			return round($dist * 1.609344 * 1000);
169
		} elseif ($unit == "mile" || $unit == "mi") {
170
			return round($dist);
171
		} elseif ($unit == "nm") {
172
			return round($dist*0.868976);
173
		} else {
174
			return round($dist);
175
		}
176
	}
177
178
	/**
179
	* Check is distance realistic
180
	* @param int $timeDifference the time between the reception of both messages
181
	* @param float $distance distance covered
182
	* @return whether distance is realistic
183
	*/
184
	public function withinThreshold ($timeDifference, $distance) {
185
		$x = abs($timeDifference);
186
		$d = abs($distance);
187
		if ($x == 0 || $d == 0) return true;
188
		// may be due to Internet jitter; distance is realistic
189
		if ($x < 0.7 && $d < 2000) return true;
190
		else return $d/$x < 1500*0.27778; // 1500 km/h max
191
	}
192
193
194
	// Check if an array is assoc
195
	public function isAssoc($array)
196
	{
197
		return ($array !== array_values($array));
198
	}
199
200
	public function isInteger($input){
201
	    return(ctype_digit(strval($input)));
202
	}
203
204
205
	public function convertDec($dms,$latlong) {
206
		if ($latlong == 'latitude') {
207
			$deg = substr($dms, 0, 2);
208
			$min = substr($dms, 2, 4);
209
		} else {
210
			$deg = substr($dms, 0, 3);
211
			$min = substr($dms, 3, 5);
212
		}
213
		return $deg+(($min*60)/3600);
214
	}
215
	
216
	/**
217
	* Copy folder contents
218
	* @param       string   $source    Source path
219
	* @param       string   $dest      Destination path
220
	* @return      bool     Returns true on success, false on failure
221
	*/
222
	public function xcopy($source, $dest)
223
	{
224
		$files = glob($source.'*.*');
225
		foreach($files as $file){
226
			$file_to_go = str_replace($source,$dest,$file);
227
			copy($file, $file_to_go);
228
		}
229
		return true;
230
	}
231
	
232
	/**
233
	* Check if an url exist
234
	* @param	String $url url to check
235
	* @return	bool Return true on succes false on failure
236
	*/
237
	public function urlexist($url){
238
		$headers=get_headers($url);
239
		return stripos($headers[0],"200 OK")?true:false;
240
	}
241
	
242
	/**
243
	* Convert hexa to string
244
	* @param	String $hex data in hexa
245
	* @return	String Return result
246
	*/
247
	public function hex2str($hex) {
248
		$str = '';
249
		$hexln = strlen($hex);
250
		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
251
		return $str;
252
	}
253
	
254
	
255
	public function getHeading($lat1, $lon1, $lat2, $lon2) {
256
		//difference in longitudinal coordinates
257
		$dLon = deg2rad($lon2) - deg2rad($lon1);
258
		//difference in the phi of latitudinal coordinates
259
		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
260
		//we need to recalculate $dLon if it is greater than pi
261
		if(abs($dLon) > pi()) {
262
			if($dLon > 0) {
263
				$dLon = (2 * pi() - $dLon) * -1;
264
			} else {
265
				$dLon = 2 * pi() + $dLon;
266
			}
267
		}
268
		//return the angle, normalized
269
		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
270
	}
271
	
272
	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.1) {
273
		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
274
		$a = -($lon2-$lon1);
275
		$b = $lat2 - $lat1;
276
		$c = -($a*$lat1+$b*$lon1);
277
		$d = $a*$lat3+$b*$lon3+$c;
278
		if ($d > -$approx && $d < $approx) return true;
279
		else return false;
280
	}
281
	
282
	public function array_merge_noappend() {
283
		$output = array();
284
		foreach(func_get_args() as $array) {
285
			foreach($array as $key => $value) {
286
				$output[$key] = isset($output[$key]) ?
287
				array_merge($output[$key], $value) : $value;
288
			}
289
		}
290
		return $output;
291
	}
292
	
293
294
	public function arr_diff($arraya, $arrayb) {
295
		foreach ($arraya as $keya => $valuea) {
296
			if (in_array($valuea, $arrayb)) {
297
				unset($arraya[$keya]);
298
			}
299
		}
300
		return $arraya;
301
	}
302
303
	/*
304
	* Check if a key exist in an array
305
	* Come from http://stackoverflow.com/a/19420866
306
	* @param Array array to check
307
	* @param String key to check
308
	* @return Bool true if exist, else false
309
	*/
310
	public function multiKeyExists(array $arr, $key) {
311
		// is in base array?
312
		if (array_key_exists($key, $arr)) {
313
			return true;
314
		}
315
		// check arrays contained in this array
316
		foreach ($arr as $element) {
317
			if (is_array($element)) {
318
				if ($this->multiKeyExists($element, $key)) {
319
					return true;
320
				}
321
			}
322
		}
323
		return false;
324
	}
325
	
326
	/**
327
	* Returns list of available locales
328
	*
329
	* @return array
330
	 */
331
	public function listLocaleDir()
332
	{
333
		$result = array('en');
334
		if (!is_dir('./locale')) {
335
			return $result;
336
		}
337
		$handle = @opendir('./locale');
338
		if ($handle === false) return $result;
339
		while (false !== ($file = readdir($handle))) {
340
			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
341
			if ($file != "." && $file != ".." && @file_exists($path)) {
342
				$result[] = $file;
343
			}
344
		}
345
		closedir($handle);
346
		return $result;
347
	}
348
349
	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){
350
		global $globalMapRefresh;
351
		$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
352
		$r = 6378;
353
		$latitude = deg2rad($latitude);
354
		$longitude = deg2rad($longitude);
355
		$bearing = deg2rad($heading); 
356
		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
357
		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
358
		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
359
	}
360
	
361
	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
362
		// distance in meter
363
		$R = 6378.14;
364
		$latitude1 = $latitude * (M_PI/180);
365
		$longitude1 = $longitude * (M_PI/180);
366
		$brng = $bearing * (M_PI/180);
367
		$d = $distance;
368
369
		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
370
		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
371
372
		$latitude2 = $latitude2 * (180/M_PI);
373
		$longitude2 = $longitude2 * (180/M_PI);
374
375
		$flat = round ($latitude2,6);
376
		$flong = round ($longitude2,6);
377
/*
378
		$dx = $distance*cos($bearing);
379
		$dy = $distance*sin($bearing);
380
		$dlong = $dx/(111320*cos($latitude));
381
		$dlat = $dy/110540;
382
		$flong = $longitude + $dlong;
383
		$flat = $latitude + $dlat;
384
*/
385
		return array('latitude' => $flat,'longitude' => $flong);
386
	}
387
388
	/**
389
	 * GZIPs a file on disk (appending .gz to the name)
390
	 *
391
	 * From http://stackoverflow.com/questions/6073397/how-do-you-create-a-gz-file-using-php
392
	 * Based on function by Kioob at:
393
	 * http://www.php.net/manual/en/function.gzwrite.php#34955
394
	 * 
395
	 * @param string $source Path to file that should be compressed
396
	 * @param integer $level GZIP compression level (default: 9)
397
	 * @return string New filename (with .gz appended) if success, or false if operation fails
398
	 */
399
	public function gzCompressFile($source, $level = 9){ 
400
		$dest = $source . '.gz'; 
401
		$mode = 'wb' . $level; 
402
		$error = false; 
403
		if ($fp_out = gzopen($dest, $mode)) { 
404
			if ($fp_in = fopen($source,'rb')) { 
405
				while (!feof($fp_in)) 
406
					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
407
				fclose($fp_in); 
408
			} else {
409
				$error = true; 
410
			}
411
			gzclose($fp_out); 
412
		} else {
413
			$error = true; 
414
		}
415
		if ($error)
416
			return false; 
417
		else
418
			return $dest; 
419
	} 
420
	
421
	public function remove_accents($string) {
422
		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
423
		$chars = array(
424
		    // Decompositions for Latin-1 Supplement
425
		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
426
		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
427
		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
428
		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
429
		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
430
		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
431
		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
432
		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
433
		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
434
		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
435
		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
436
		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
437
		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
438
		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
439
		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
440
		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
441
		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
442
		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
443
		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
444
		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
445
		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
446
		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
447
		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
448
		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
449
		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
450
		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
451
		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
452
		    chr(195).chr(191) => 'y',
453
		    // Decompositions for Latin Extended-A
454
		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
455
		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
456
		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
457
		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
458
		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
459
		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
460
		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
461
		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
462
		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
463
		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
464
		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
465
		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
466
		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
467
		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
468
		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
469
		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
470
		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
471
		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
472
		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
473
		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
474
		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
475
		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
476
		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
477
		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
478
		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
479
		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
480
		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
481
		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
482
		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
483
		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
484
		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
485
		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
486
		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
487
		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
488
		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
489
		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
490
		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
491
		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
492
		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
493
		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
494
		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
495
		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
496
		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
497
		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
498
		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
499
		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
500
		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
501
		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
502
		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
503
		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
504
		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
505
		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
506
		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
507
		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
508
		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
509
		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
510
		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
511
		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
512
		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
513
		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
514
		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
515
		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
516
		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
517
		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
518
		);
519
		$string = strtr($string, $chars);
520
		return $string;
521
	}
522
}
523
?>