139 |
root |
1 |
<?php |
|
|
2 |
// +----------------------------------------------------------------------+ |
|
|
3 |
// | PHP Version 4 | |
|
|
4 |
// +----------------------------------------------------------------------+ |
|
|
5 |
// | Copyright (c) 1997-2004 The PHP Group | |
|
|
6 |
// +----------------------------------------------------------------------+ |
|
|
7 |
// | This source file is subject to version 3.0 of the PHP license, | |
|
|
8 |
// | that is bundled with this package in the file LICENSE, and is | |
|
|
9 |
// | available at through the world-wide-web at | |
|
|
10 |
// | http://www.php.net/license/3_0.txt. | |
|
|
11 |
// | If you did not receive a copy of the PHP license and are unable to | |
|
|
12 |
// | obtain it through the world-wide-web, please send a note to | |
|
|
13 |
// | license@php.net so we can mail you a copy immediately. | |
|
|
14 |
// +----------------------------------------------------------------------+ |
|
|
15 |
// | Authors: David Irvine <dave@codexweb.co.za> | |
|
|
16 |
// | Aidan Lister <aidan@php.net> | |
|
|
17 |
// +----------------------------------------------------------------------+ |
|
|
18 |
// |
|
|
19 |
// $Id: html_entity_decode.php,v 1.8 2005/12/07 21:08:57 aidan Exp $ |
|
|
20 |
|
|
|
21 |
|
|
|
22 |
if (!defined('ENT_NOQUOTES')) { |
|
|
23 |
define('ENT_NOQUOTES', 0); |
|
|
24 |
} |
|
|
25 |
|
|
|
26 |
if (!defined('ENT_COMPAT')) { |
|
|
27 |
define('ENT_COMPAT', 2); |
|
|
28 |
} |
|
|
29 |
|
|
|
30 |
if (!defined('ENT_QUOTES')) { |
|
|
31 |
define('ENT_QUOTES', 3); |
|
|
32 |
} |
|
|
33 |
|
|
|
34 |
|
|
|
35 |
/** |
|
|
36 |
* Replace html_entity_decode() |
|
|
37 |
* |
|
|
38 |
* @category PHP |
|
|
39 |
* @package PHP_Compat |
|
|
40 |
* @link http://php.net/function.html_entity_decode |
|
|
41 |
* @author David Irvine <dave@codexweb.co.za> |
|
|
42 |
* @author Aidan Lister <aidan@php.net> |
|
|
43 |
* @version $Revision: 1.8 $ |
|
|
44 |
* @since PHP 4.3.0 |
|
|
45 |
* @internal Setting the charset will not do anything |
|
|
46 |
* @require PHP 4.0.0 (user_error) |
|
|
47 |
*/ |
|
|
48 |
if (!function_exists('html_entity_decode')) { |
|
|
49 |
function html_entity_decode($string, $quote_style = ENT_COMPAT, $charset = null) |
|
|
50 |
{ |
|
|
51 |
if (!is_int($quote_style)) { |
|
|
52 |
user_error('html_entity_decode() expects parameter 2 to be long, ' . |
|
|
53 |
gettype($quote_style) . ' given', E_USER_WARNING); |
|
|
54 |
return; |
|
|
55 |
} |
|
|
56 |
|
|
|
57 |
$trans_tbl = get_html_translation_table(HTML_ENTITIES); |
|
|
58 |
$trans_tbl = array_flip($trans_tbl); |
|
|
59 |
|
|
|
60 |
// Add single quote to translation table; |
|
|
61 |
$trans_tbl['''] = '\''; |
|
|
62 |
|
|
|
63 |
// Not translating double quotes |
|
|
64 |
if ($quote_style & ENT_NOQUOTES) { |
|
|
65 |
// Remove double quote from translation table |
|
|
66 |
unset($trans_tbl['"']); |
|
|
67 |
} |
|
|
68 |
|
|
|
69 |
return strtr($string, $trans_tbl); |
|
|
70 |
} |
|
|
71 |
} |
|
|
72 |
|
130 |
kaklik |
73 |
?> |