<?
/***************************************************************************
 *                              obmen.php
 *                            -------------------
 *  Полнлценный модуль Файлобменника под phpBB-WAP
 *	Автор модуля: SatanHell
 *  2011 год
 ***************************************************************************/

function fsize($size)
{
$size = empty($size) ? '0' : $size;
if($size < 1024)
{
$asize = $size.' байт';
}
elseif($size < 1048576 AND $size >= 1024)
{
$asize = round($size/1024,2).' кб';
}
elseif($size < 1073741824 AND $size >= 1048576)
{
$asize = round($size/1024/1024, 2).' мб';
}
else
{
$asize = round($size/1024/1024/1024, 2).' гб';
}
return $asize;
}

//-узнаем формат файла---------------------------//

function ext_file($file)
{
return pathinfo($file, PATHINFO_EXTENSION);
}


//-фильтруем данные---------------------------//

function text_obmen($text)
{
$text = htmlspecialchars($text);
$text = nl2br($text);
return $text;
}

function text_obmen_form($text)
{
$text = htmlspecialchars($text);
return $text;
}

function tags($message)
{
$message = preg_replace('#\[big\](.*?)\[/big\]#si', '<big>\1</big>', $message);

$message = preg_replace('#\[b\](.*?)\[/b\]#si', '<b>\1</b>', $message);

$message = preg_replace('#\[i\](.*?)\[/i\]#si', '<i>\1</i>', $message);

$message = preg_replace('#\[u\](.*?)\[/u\]#si', '<u>\1</u>', $message);

$message = preg_replace('#\[small\](.*?)\[/small\]#si', '<small>\1</small>', $message);

$message = preg_replace('#\[red\](.*?)\[/red\]#si', '<span style="color: #FF0000;">\1</span>', $message);

$message = preg_replace('#\[green\](.*?)\[/green\]#si', '<span style="color: #00FF00;">\1</span>', $message);

$message = preg_replace('#\[blue\](.*?)\[/blue\]#si', '<span style="color: #0000FF;">\1</span>', $message);

$message = preg_replace('#\[yellow\](.*?)\[/yellow\]#si', '<span style="color: #FFFF00;">\1</span>', $message);

$message = preg_replace('#\[q\](.*?)\[/q\]#si', '<q>\1</q>', $message);

$message = preg_replace('#\[del\](.*?)\[/del\]#si', '<del>\1</del>', $message);

$message = preg_replace('#\[url=(http://.+?)\](.+?)\[\/url\]#si', '<a href="\1">\2</a>', $message); 

return $message;
}

function obmen_smiles($sm)
{
$query = 'SELECT * FROM `phpbb_smilies`';
$sql = mysql_query($query);
$row = mysql_fetch_assoc($sql);
do
{
$sm=str_replace($row['code'], '<img src="images/smiles/'.$row
['smile_url'].'" alt="'.$row['code'].'" />',$sm);
}
while ($row = mysql_fetch_array ($sql));
return $sm;
}

function strlen2($str)
{
$rus=array('й','ц','у','к','е','н','г','ш','щ','з','х','ъ','ф','ы','в','а','п','р','о','л','д','ж','э','я','ч','с','м','и','т','ь','б','ю','Й','Ц','У','К','Е','Н','Г','Ш','Щ','З','Х','Ъ','Ф','Ы','В','А','П','Р','О','Л','Д','Ж','Э','Я','Ч','С','М','И','Т','Ь','Б','Ю');
return strlen(str_replace($rus, '0', $str));
}

?>