Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Feb 9th, 2010 | Syntax: None | Size: 0.96 KB | Hits: 24 | Expires: Never
Copy text to clipboard
  1. function clean_post($post) {
  2.         $regex['c']  = '/([\s\w]{2,})/is';
  3.         $regex['l'] = '/(\w)\1{2,}/is';
  4.         $regex['i']  = '/\[(b|i|u|s|hr|sub|sup|img|media|snapback|spoiler|extract|anchor|twitter)\](.*?)\[\/\1\]/ims';
  5.         $regex['n'] = '/\[(url|list|email|topic|post|acronym|blog|entry|member)(?:.*?)\](.*?)\[\/\1\]/ims';
  6.         $regex['t']  = '/.*?(?:\[(?P<tag>quote|php|code|html|sql|xml).*?\])(?:.*?)(?:\[\/(?P=tag)\]).*?/ims';  
  7.        
  8.         $post = preg_replace($regex['c'], '$1', $post);
  9.         $post = preg_replace($regex['l'], '$1', $post);
  10.         $post = preg_replace($regex['i'], '$2', $post);
  11.         $post = preg_replace($regex['n'], '$2', $post);
  12.         while    (preg_match($regex['t'], $post, $matches)) {
  13.                 $post = str_replace($matches[0], '', $post);
  14.         }
  15.                
  16.         $points = 0;
  17.         $length = strlen($post);
  18.        
  19.         if ($length >= 80 && $length <= 199) {
  20.                 $points = 1;
  21.         } elseif ($length >= 200 && $length <= 399) {
  22.                 $points = 2;
  23.         } elseif ($length >= 400) {
  24.                 $points = 3;
  25.         }
  26.         return array($points, $post);
  27. }