/\[a@([^"@]*)@([^]"]*)\]/PHPMYADMIN中的
完整的函数是:function PMA_sanitize($message)
{
$replace_pairs = array(
'<' => '<',
'>' => '>',
'' => '<em>', // deprecated by em
'' => '</em>', // deprecated by em
'[em]' => '<em>',
'[/em]' => '</em>',
'' => '<strong>', // deprecated by strong
'' => '</strong>', // deprecated by strong
'[strong]' => '<strong>',
'[/strong]' => '</strong>',
'[tt]' => '<code>', // deprecated by CODE or KBD
'[/tt]' => '</code>', // deprecated by CODE or KBD
'[code]' => '<code>',
'' => '</code>',
'[kbd]' => '<kbd>',
'[/kbd]' => '</kbd>',
'[br]' => '<br />',
'[/a]' => '</a>',
'[sup]' => '<sup>',
'[/sup]' => '</sup>',
);
$message = strtr($message, $replace_pairs); $pattern = '/\[a@([^"@]*)@([^]"]*)\]/'; if (preg_match_all($pattern, $message, $founds, PREG_SET_ORDER)) {
$valid_links = array(
'http', // default http:// links (and https://)
'./Do', // ./Documentation
); foreach ($founds as $found) {
// only http... and ./Do... allowed
if (! in_array(substr($found[1], 0, 4), $valid_links)) {
return $message;
}
// a-z and _ allowed in target
if (! empty($found[2]) && preg_match('/[^a-z_]+/i', $found[2])) {
return $message;
}
} $message = preg_replace($pattern, '<a href="\1" target="\2">', $message);
} return $message;
}
[/code]
完整的函数是:function PMA_sanitize($message)
{
$replace_pairs = array(
'<' => '<',
'>' => '>',
'' => '<em>', // deprecated by em
'' => '</em>', // deprecated by em
'[em]' => '<em>',
'[/em]' => '</em>',
'' => '<strong>', // deprecated by strong
'' => '</strong>', // deprecated by strong
'[strong]' => '<strong>',
'[/strong]' => '</strong>',
'[tt]' => '<code>', // deprecated by CODE or KBD
'[/tt]' => '</code>', // deprecated by CODE or KBD
'[code]' => '<code>',
'' => '</code>',
'[kbd]' => '<kbd>',
'[/kbd]' => '</kbd>',
'[br]' => '<br />',
'[/a]' => '</a>',
'[sup]' => '<sup>',
'[/sup]' => '</sup>',
);
$message = strtr($message, $replace_pairs); $pattern = '/\[a@([^"@]*)@([^]"]*)\]/'; if (preg_match_all($pattern, $message, $founds, PREG_SET_ORDER)) {
$valid_links = array(
'http', // default http:// links (and https://)
'./Do', // ./Documentation
); foreach ($founds as $found) {
// only http... and ./Do... allowed
if (! in_array(substr($found[1], 0, 4), $valid_links)) {
return $message;
}
// a-z and _ allowed in target
if (! empty($found[2]) && preg_match('/[^a-z_]+/i', $found[2])) {
return $message;
}
} $message = preg_replace($pattern, '<a href="\1" target="\2">', $message);
} return $message;
}
[/code]
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货