Advertisement
wandrake

Untitled

Nov 2nd, 2013
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.69 KB | None | 0 0
  1.    function process_text($text, $br = true, $chars = true)                                
  2.    {                                                                                      
  3.        $search = array(                                                                  
  4.            '[url autourl=' . AUTOURL . ' nofollow=1]',                                    
  5.            '[/url autourl=' . AUTOURL .' nofollow=1]',                                    
  6.            '[email autourl=' . AUTOURL . ' nofollow=1]',                                  
  7.            '[/email autourl=' . AUTOURL . ' nofollow=1]'                                  
  8.        );                                                                                
  9.        $replace = array('', '', '', '');                                                  
  10.        $text = str_replace($search, $replace, $text);                                    
  11.        if($chars)                                                                        
  12.        {                                                                                  
  13.            $text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8');                          
  14.            $text = str_replace('&#', '&#', $text);                                    
  15.        }                                                                                  
  16.        else                                                                              
  17.        {                                                                                  
  18.            $text = str_replace(                                                          
  19.                array('&amp;', '>', '%3E', '<', '%3C', '"', '&amp;#'),                    
  20.                array('&amp;amp;', '&gt;', '&gt;', '&lt;', '&lt;', '&quot;', '&#'),        
  21.                $text                                                                      
  22.            );                                                                            
  23.        }                                                                                  
  24.        if($br)                                                                            
  25.        {                                                                                  
  26.            $text = str_replace("\n", "<br />\n", $text);                                  
  27.        }                                                                                  
  28.        return $text;                                                                      
  29.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement