250 |
kaklik |
1 |
<?php |
|
|
2 |
/* $Id: sanitizing.lib.php,v 2.2 2005/11/17 13:12:58 cybot_tm Exp $ */ |
|
|
3 |
// vim: expandtab sw=4 ts=4 sts=4: |
|
|
4 |
|
|
|
5 |
/** |
|
|
6 |
* Sanitizes $message, taking into account our special codes |
|
|
7 |
* for formatting |
|
|
8 |
* |
|
|
9 |
* @param string the message |
|
|
10 |
* |
|
|
11 |
* @return string the sanitized message |
|
|
12 |
* |
|
|
13 |
* @access public |
|
|
14 |
*/ |
|
|
15 |
function PMA_sanitize($message) |
|
|
16 |
{ |
|
|
17 |
$replace_pairs = array( |
|
|
18 |
'<' => '<', |
|
|
19 |
'>' => '>', |
|
|
20 |
'[i]' => '<em>', // deprecated by em |
|
|
21 |
'[/i]' => '</em>', // deprecated by em |
|
|
22 |
'[em]' => '<em>', |
|
|
23 |
'[/em]' => '</em>', |
|
|
24 |
'[b]' => '<strong>', // deprecated by strong |
|
|
25 |
'[/b]' => '</strong>', // deprecated by strong |
|
|
26 |
'[strong]' => '<strong>', |
|
|
27 |
'[/strong]' => '</strong>', |
|
|
28 |
'[tt]' => '<code>', // deprecated by CODE or KBD |
|
|
29 |
'[/tt]' => '</code>', // deprecated by CODE or KBD |
|
|
30 |
'[code]' => '<code>', |
|
|
31 |
'[/code]' => '</code>', |
|
|
32 |
'[kbd]' => '<kbd>', |
|
|
33 |
'[/kbd]' => '</kbd>', |
|
|
34 |
'[br]' => '<br />', |
|
|
35 |
'[/a]' => '</a>', |
|
|
36 |
); |
|
|
37 |
return preg_replace('/\[a@([^"@]*)@([^]"]*)\]/', '<a href="\1" target="\2">', strtr($message, $replace_pairs)); |
|
|
38 |
} |
|
|
39 |
|
|
|
40 |
?> |