为了方便采集入库的时候不过滤到HTML.
function FormatString($source, $para)
{
/* 方便HTML入库
if (strpos($para, ’[html-format]’) !== false) {
$source = htmlspecialchars($source);
//if (version_compare(PHP_VERSION, ’5.4.0′) >= 0) {
// $source = htmlspecialchars($source, (ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE), ”UTF-8”);
//} else {
// $source = htmlspecialchars($source, ENT_COMPAT, ”UTF-8”);
//}
}
if (strpos($para, ’[nohtml]’) !== false) {
$source = preg_replace(”/<([^<>]*)>/si”, ”", $source);
$source = str_replace(”<”, ”˂”, $source);
$source = str_replace(”>”, ”˃”, $source);
}
if (strpos($para, ’[noscript]’) !== false) {
$class = new XssHtml($source);
$source = trim($class->getHtml());
}
if (strpos($para, ’[enter]’) !== false) {
$source = str_replace(”\r\n”, ”
“, $source);
$source = str_replace(”\n”, ”
“, $source);
$source = str_replace(”\r”, ”
“, $source);
$source = preg_replace(”/(<br\/>)+/”, ”
“, $source);
}
if (strpos($para, ’[noenter]’) !== false) {
$source = str_replace(”\r\n”, ”", $source);
$source = str_replace(”\n”, ”", $source);
$source = str_replace(”\r”, ”", $source);
}
if (strpos($para, ’[filename]’) !== false) {
$source = str_replace(array(”/”, ”#”, ”$”, ”\\”, ”:”, ”?”, ”*”, ”\”", ”<”, ”>”, ”|”, ” ”), array(”"), $source);
}
if (strpos($para, ’[normalname]’) !== false) {
$source = str_replace(array(”#”, ”$”, ”(”, ”)”, ”*”, ”+”, ”[”, ”]”, ”{”, ”}”, ”?”, ”\\”, ”^”, ”|”, ”:”, ”‘”, ”\”", ”;”, ”@”, ”~”, ”=”, ”%”, ”&”), array(”"), $source);
}
*/
return $source;
}