Вход Регистрация
Файл: engine/classes/text.class.php
Строк: 104
<?php

    
Class text
    
{
        static function 
output($str, $set = array('html' => true, 'bbcode' => true, 'smiles' => true, 'br' => true))
        {
            if (
$set['html'])
                
$str = htmlspecialchars($str);
        
            if (
$set['br'])
            {
                
$str = nl2br($str);
                
//$str = str_replace(PHP_EOL, '<br />', $str); 
            
}
            
            

            if (
$set['bbcode'])
            {
                
//$tmp_str = $str;
                
$str = self::bbcode($str);
            }   
            
                
            if (
$set['smiles'])// && $tmp_str == $str)
                
$str = self::smiles($str);

           
/**
            * Антиспам. Разрешается использовать только в SecWind
            */

            
if (file_exists(H . 'engine/files/data/antispam.db'))
            {
                
$antispam = unserialize(file_get_contents(H . 'engine/files/data/antispam.db'));
                
$str = str_replace(array_keys($antispam), array_values($antispam), $str);
            }

            return 
$str;
        }

        static function 
size_data($size = 0)
        {
            
$size_ed = 'б';
            if (
$size >= 1024)
            {
                
$size = round($size / 1024, 2);
                
$size_ed = 'Кб';
            }
            
            if (
$size >= 1024)
            {
                
$size = round($size / 1024, 2);
                
$size_ed = 'Мб';
            }

            if (
$size >= 1024)
            {
                
$size = round($size / 1024, 2);
                
$size_ed = 'Гб';
            }
            
            return 
$size . ' ' . $size_ed;
        }

        static function 
smiles($msg)
        {
            static 
$cache = array();
            if (empty(
$cache))
            {
                global 
$sql;
                
$query = mysqli_query($sql->db, 'SELECT * FROM `smiles` WHERE `type` = "smile"');
                if (
$sql->num_rows())
                {
                    while(
$smiles = $sql->fetch($query)){
                    
$cache[$smiles['symbol']] = '<img src="/style/smiles/'.$smiles['name'].'.gif"/>';
                    }
                }
            }
            return 
strtr($msg, $cache);
        }

        static function 
passgen($len = 12)
        {
            
$password = '';
            
$small = 'abcdefghijklmnopqrstuvwxyz';
            
$large = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
            
$numbers = '1234567890';
            for (
$i = 0; $i < $len; $i++)
            {
                switch (
mt_rand(1, 3))
                {
                    case 
3 :
                        
$password .= $large [mt_rand(0, 25)];
                            break;
                    case 
2 :
                        
$password .= $small [mt_rand(0, 25)];
                            break;
                    case 
1 :
                        
$password .= $numbers [mt_rand(0, 9)];
                            break;
                }
            }
            return 
$password;
        }

        static function 
antimat($str, $user)
        {
            include_once 
H.'engine/functions/censure.php';
            if (
$censure = censure($str))
            {
                return 
$censure;
            }
            else
                return 
false;
        }

        static function 
bbcode($text)
        {
            
$search = array(
            
'#[b](.+?)[/b]#',
            
'#[i](.+?)[/i]#',
            
'#[u](.+?)[/u]#',
            
'#[del](.+?)[/del]#',
            
'#[color=(green|lime|red|blue|yellow|purple|gold|black|silver|gray|white)](.+?)[/color]#',
            
'#[quote](.+?)[/quote]#',
            
'#[php](.*?)[/php]#se',
            
'#[youtube](.*?)[/youtube]#s',
            
'#[vk](.*?)[/vk]#s',
            
'#[spoiler](.*?)[/spoiler]#s',
            
'#[offtop](.*?)[/offtop]#s',
            
            );

            
$replace = array(
            
'<span style="font-weight: bold">$1</span>',
            
'<span style="font-style:italic">$1</span>',
            
'<span style="text-decoration:underline">$1</span>',
            
'<span style="text-decoration:line-through">$1</span>',
            
'<span style="color:$1">$2</span>',
            
'<div class="quote">$1</div>',
            
"''.highlight_string(str_replace('<br />', '', htmlspecialchars_decode('$1')), 1).''",
            
'<object width="40%"><param name="movie" value="http://www.youtube.com/v/1?rel=1&amp;color1=000&amp;color2=000&amp;border=1&amp;fs=1"></param> <param name="allowFullScreen" value="true"></param> <embed src="http://www.youtube.com/v/1?rel=1&amp;color1=000&amp;color2=000&amp;border=1&amp;fs=1" type="application/x-shockwave-flash" allowfullscreen="true"></embed></object>',
            
'<object width="40%"><iframe src="1" frameborder="0"></iframe></object>',
            
'<div><div class="quote" style="cursor:pointer;" onclick="var _n=this.parentNode.getElementsByTagName('div')[1];if(_n.style.display=='none'){_n.style.display='';}else{_n.style.display='none';}">Спойлер:</div><div style="display:none">1</div></div>',
            
'<div style="color:#ccc;margin:1px;padding:2px;border:1px dashed #ccc">Оффтоп:<br />1</div>',
            );
            
            
$text = preg_replace($search, $replace, $text);
            
$text = str_replace("‮",' ', $text);
            
            
$text = preg_replace_callback('#[url=([-a-z0-9._~:/?#@!$&'()*+,;=%]+)](.+?)[/url]#i', 
                
create_function('$match', 'return "<a href='".str_ireplace('javascript:', 'js', strip_tags($match[1]))."' title='".htmlspecialchars(strip_tags($match[2]))."'>".htmlspecialchars(strip_tags($match[2]))."</a>";'), $text);

            
//[img=img link]title[/img]
            //$text = preg_replace('/[img=([-a-z0-9._~:/?#@!$&'()*+,;=%]+)](.+?)[/img]/si', '<img src="1" alt="2" title="2" />', $text);

            
return $text; preg_replace($search, $replace, $text);
        }
    }
Онлайн: 2
Реклама