Файл: system/classes/Filter.php
Строк: 37
<?php
class Filter
{
static function strlen($var)
{
return strlen(trim($var));
}
static function bbcode($var)
{
$bbcode['/[br]/isU']='<br />';
$bbcode['/[i](.+)[/i]/isU'] = '<em>$1</em>';
$bbcode['/[b](.+)[/b]/isU'] = '<strong>$1</strong>';
$bbcode['/[u](.+)[/u]/isU'] = '<span style="text-decoration:underline;">$1</span>';
$bbcode['/[size=([0-9]+)](.+)[/size]/isU'] = '<span style="font-size:$1px;">$2</span>';
$bbcode['/[color=([A-z]+)](.+)[/color]/isU'] ='<span style="color:$1;">$2</span>';
$bbcode['/[img](.+)[/img]/isU'] = '<a href="$1" target="_blank"><img weight="200px" height="200px" src="$1" alt="img"></a>';
$bbcode['/[urls?=s?(['"]?)(?:http://)?(.*?)1](.*?)[/url]/isU'] = '<a href="http://$2" target="_blank"> $3 </a> ';
$bbcode['~(https?|ftps?)://([a-z0-9./-?_=&;]*)(s|$)~iu'] = '<a href="$1://$2" target="_blank"> $2 </a> ';
if (count($bbcode))
{
$var = preg_replace(array_keys($bbcode), array_values($bbcode), $var);
}
return $var;
}
static function text($var)
{
return htmlspecialchars($var);
}
static function output($var)
{
$var = self::bbcode(self::text($var));
$var = preg_replace("#((<br( ?/?)>)|n|r)+#i", "<br />", $var);
return $var;
}
static function encode($var)
{
return md5(md5(base64_encode($var)));
}
}