Untitled
By: a guest | Feb 9th, 2010 | Syntax:
None | Size: 0.96 KB | Hits: 24 | Expires: Never
function clean_post($post) {
$regex['c'] = '/([\s\w]{2,})/is';
$regex['l'] = '/(\w)\1{2,}/is';
$regex['i'] = '/\[(b|i|u|s|hr|sub|sup|img|media|snapback|spoiler|extract|anchor|twitter)\](.*?)\[\/\1\]/ims';
$regex['n'] = '/\[(url|list|email|topic|post|acronym|blog|entry|member)(?:.*?)\](.*?)\[\/\1\]/ims';
$regex['t'] = '/.*?(?:\[(?P<tag>quote|php|code|html|sql|xml).*?\])(?:.*?)(?:\[\/(?P=tag)\]).*?/ims';
$post = preg_replace($regex['c'], '$1', $post);
$post = preg_replace($regex['l'], '$1', $post);
$post = preg_replace($regex['i'], '$2', $post);
$post = preg_replace($regex['n'], '$2', $post);
while (preg_match($regex['t'], $post, $matches)) {
$post = str_replace($matches[0], '', $post);
}
$points = 0;
$length = strlen($post);
if ($length >= 80 && $length <= 199) {
$points = 1;
} elseif ($length >= 200 && $length <= 399) {
$points = 2;
} elseif ($length >= 400) {
$points = 3;
}
return array($points, $post);
}