<?php
function size($size)
{
if ($size >= 1048576000)
{
$size = round(($size / 1073741824), 2) . " Gb";
}
elseif ($size >= 1024000)
{
$size = round(($size / 1048576), 2) . " Mb";
}
elseif ($size >= 1000)
{
$size = round(($size / 1024), 2) . " Kb";
}
else
{
$size = round($size) . " B";
}
return $size;
}
function data($time)
{
$month = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
$month_rus = array('Янв','Фев','Мар','Апр','Мая','Июн','Июл','Авг','Сент','Окт','Ноя','Дек');
$timep = date("j M Y - H:i:s", $time);
$timep = str_replace($month,$month_rus,$timep);
return $timep;
}
function navigation($total,$page,$url)
{
if($page-1 > 0)
{
$left='<a href="'.$url.''.($page-1).'"><-Пред.</a>';
}
else
{
$left = '<-Пред.';
}
if($page+1 > 0 AND $page < $total)
{
$right = '<a href="'.$url.''.($page+1).'">След.-></a>';
}
else
{
$right = 'След.->';
}
if($page-3 > 0)
{
$first='<a href="'.$url.'1">1</a>..';
}
if($page-2 > 0)
{
$page2left='<a href="'.$url.''.($page-2).'">'.($page-2).'</a>,';
}
if($page-1 > 0)
{
$page1left='<a href="'.$url.''.($page-1).'">'.($page-1).'</a>,';
}
if($page+1 <= $total)
{
$page1right=',<a href="'.$url.''.($page+1).'">'.($page + 1).'</a>';
}
if($page+2 <= $total)
{
$page2right=',<a href="'.$url.''.($page+2).'">'.($page + 2).'</a>';
}
if($page+3 <= $total)
{
$page3right='..<a href="'.$url.''.($total).'">'.($total).'</a>';
}
return '<div class="navigation">'.$left.' | '.$right.'<hr>Страницы:<br/>'.$first.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$page3right.'</div>';
}
function level($user_data,$level,$url)
{
if($user_data AND $user_data['level'] < $level OR !$user_data)
{
header("Location: http://".$url);
exit;
}
}
function filterIn($mysqli,$text)
{
$text = mysqli_real_escape_string($mysqli,$text);
return $text;
}
function filterOut($text)
{
$text = str_replace("\'", "'", $text);
$text = str_replace('\\', "\", $text);
$text = str_replace("|", "I", $text);
$text = str_replace("||", "I", $text);
$text = str_replace("/\\\$/", "$", $text);
$text = htmlspecialchars($text);
return $text;
}
function bbCodes($text) /*некоторая часть с JohnCms 4.3.0*/
{
$search = array(
'#\[b](.+?)\[/b]#is', // Жирный
'#\[i](.+?)\[/i]#is', // Курсив
'#\[red](.+?)\[/red]#is', // Красный
'#\[green](.+?)\[/green]#is', // Зеленый
'#\[blue](.+?)\[/blue]#is' // Синий
);
$replace = array(
'<span style="font-weight: bold">$1</span>', // Жирный
'<span style="font-style:italic">$1</span>', // Курсив
'<span style="color:red">$1</span>', // Красный
'<span style="color:green">$1</span>', // Зеленый
'<span style="color:blue">$1</span>' // Синий
);
return preg_replace($search, $replace, $text);
}
?>