Exemplo n.º 1
0
 function _filter_text($body, $length = 0)
 {
     return _check_words_length(preg_replace("/([^\\s]+)\r\n/i", "\$1 \r\n", $body), $length);
 }
Exemplo n.º 2
0
 /**
  * Process text to show
  */
 function _process_text($body = '', $no_smilies = false, $smilies_as_image = false)
 {
     if (empty($body)) {
         return '';
     }
     $this->_preload_data();
     $body = str_replace(['<', '>'], ['&lt;', '&gt;'], $body);
     if ($this->FILTER_BAD_WORDS) {
         if (!isset($GLOBALS['BAD_WORDS_ARRAY'])) {
             $Q = db()->query('SELECT word FROM ' . db('badwords') . '');
             while ($A = db()->fetch_assoc($Q)) {
                 $GLOBALS['BAD_WORDS_ARRAY'] = $A['word'];
             }
         }
         $body = str_replace($GLOBALS['BAD_WORDS_ARRAY'], '', $body);
     }
     if ($this->CHECK_WORDS_LENGTH) {
         $body = _check_words_length($body);
     }
     if ($this->ENABLE_BB_CODES) {
         if (false !== strpos($body, '[')) {
             if ($this->CHECK_CODES_IF_CLOSED) {
                 $body = $this->_force_close_bb_codes($body);
             }
             $body = preg_replace(array_keys($this->_preg_bb_codes), array_values($this->_preg_bb_codes), $body);
             if ($this->USE_HIGHLIGHT) {
                 $body = preg_replace_callback('/\\[sql\\](.*?)\\[\\/sql\\]/ims', function ($m) {
                     return _class_safe('text_highlight', 'classes/common/')->_regex_sql_tag(stripslashes($m[1]));
                 }, $body);
                 $body = preg_replace_callback('/\\[html\\](.*?)\\[\\/html\\]/ims', function ($m) {
                     return _class_safe('text_highlight', 'classes/common/')->_regex_html_tag(stripslashes($m[1]));
                 }, $body);
             }
             $_this = $this;
             $body = preg_replace_callback('/\\[csv\\](.*?)\\[\\/csv\\]/ims', function ($m) use($_this) {
                 return $_this->_parse_csv_bb_code($m[1]);
             }, $body);
         }
         if ($this->ENABLE_SMILIES && is_array($GLOBALS['_smiles_array']) && empty($no_smilies)) {
             if (!empty($GLOBALS['_SMILIES_CACHE'])) {
                 $this->_smilies_replace =& $GLOBALS['_SMILIES_CACHE'];
             } else {
                 $smilies_as_image = 0;
                 if ($this->SMILIES_AS_IMAGES) {
                     $smilies_as_image = true;
                 }
                 foreach ((array) $GLOBALS['_smiles_array'] as $smile_info) {
                     $replace = ['img_src' => WEB_PATH . $this->SMILIES_DIR . $smile_info['url'], 'img_alt' => _prepare_html($smile_info['emoticon']), 'css_class' => $this->CSS_CLASSES['smile'], 'text' => _prepare_html($smile_info['code']), 'as_image' => intval($smilies_as_image)];
                     $this->_smilies_replace[$smile_info['code']] = tpl()->parse('system/smile_item', $replace);
                 }
                 $GLOBALS['_SMILIES_CACHE'] = $this->_smilies_replace;
             }
         }
         if (!empty($this->_smilies_replace)) {
             $body = str_replace(array_keys($this->_smilies_replace), array_values($this->_smilies_replace), $body);
         }
     }
     $body = nl2br($body);
     return $body;
 }