Вход Регистрация
Файл: engine/classes/Text.php
Строк: 107
<?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('engine/files/data/antispam.db'))
            {
                
$antispam unserialize(file_get_contents('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 10242);
                
$size_ed 'Кб';
            }
            
            if (
$size >= 1024)
            {
                
$size round($size 10242);
                
$size_ed 'Мб';
            }

            if (
$size >= 1024)
            {
                
$size round($size 10242);
                
$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(13))
                {
                    case 
:
                        
$password .= $large [mt_rand(025)];
                            break;
                    case 
:
                        
$password .= $small [mt_rand(025)];
                            break;
                    case 
:
                        
$password .= $numbers [mt_rand(09)];
                            break;
                }
            }
            return 
$password;
        }

        static function 
antimat($str)
        {
            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]#',
            
'#[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>',
            
'<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);
                
            
$text preg_replace_callback('#[php](.*?)[/php]#s'
                
create_function('$match''return highlight_string(str_replace("<br />", "", htmlspecialchars_decode("$match[1]")), true);'), $text);

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

            
return $textpreg_replace($search$replace$text);
        }
    }
Онлайн: 1
Реклама