<?php
# 4ekiss (ICQ: 8311156);
defined('MP3') or die('Access Denied');

$time = time();
list($generic_msec,$generic_sec)=explode(chr(32),microtime());
$generic_time=$generic_sec+$generic_msec;

# Вывод размера файла
function formatsize($size){

if($size >= 1073741824)
$size = round($size/1073741824*100) / 100 .' Гб';
elseif($size >= 1048576)
$size = round($size/1048576*100) / 100 .' Мб';
elseif($size >= 1024)
$size = round($size/1024*100) / 100 .' Кб';
else $size = round($size).' б';

return $size;
}

# Транслит (массив)
$translate = array(
"A"=>"А","a"=>"а","B"=>"Б","b"=>"б","V"=>"В",
"v"=>"в","G"=>"Г","g"=>"г","D"=>"Д","d"=>"д",
"E"=>"Е","e"=>"е","yo"=>"Ё","Zh"=>"Ж","zh"=>"ж",
"Z"=>"З","z"=>"з","I"=>"И","i"=>"и","J"=>"Й",
"j"=>"й","K"=>"К","k"=>"к","L"=>"Л","l"=>"л",
"M"=>"М","m"=>"м","N"=>"Н","n"=>"н","O"=>"О",
"o"=>"о","P"=>"П","p"=>"п","R"=>"Р","r"=>"р",
"S"=>"С","s"=>"с","T"=>"Т","t"=>"т","U"=>"У",
"u"=>"у","F"=>"Ф","f"=>"ф","H"=>"Х","h"=>"х",
"C"=>"Ц","c"=>"ц","Ch"=>"Ч","ch"=>"ч","Sh"=>"Ш",
"sh"=>"ш","Sch"=>"Щ","sch"=>"щ","''"=>"ъ",
"Y"=>"Ы","y"=>"ы","'"=>"ь","Ye"=>"Э",
"ye"=>"э","Yu"=>"Ю","yu"=>"ю","Ya"=>"Я","ya"=>"я",
"Yo"=>"ё");

# Экранирование символов
function check($text){
$text = trim((string)$text);
$text = htmlentities($text, ENT_QUOTES, 'UTF-8');

return $text;
}

# Функция для отправки POST данных
function Send_Post($post_url, $post_data, $refer){
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $refer);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, 'Opera/9.80 (Windows NT 5.1; U; ru) Presto/2.2.15 Version/10.00');

$data = curl_exec($ch);
curl_close($ch);
return $data;
}

# Функция для отправки GET данных
function Send_Get($get_url, $refer, $head=false){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $get_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if($head){
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
}
curl_setopt($ch, CURLOPT_REFERER, $refer);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, 'Opera/9.80 (Windows NT 5.1; U; ru) Presto/2.2.15 Version/10.00');

$data = curl_exec($ch);
curl_close ($ch);
return $data;
}

# Функция перекодировки
function encoding($text, $to){

if($to=='UTF-8') $text = mb_convert_encoding($text, 'UTF-8', 'Windows-1251');
else $text = mb_convert_encoding($text, 'Windows-1251', 'UTF-8');

return $text;
}

# Функция постраничной навигации
function pages($page, $total, $href, $num){

if ($total > $page + $num || $page){
echo '<div>';

if ($page) echo '<a href="'.$href.'page='.($page-$num).'">&lt;-Назад</a> ';
else echo '&lt;-Назад';

echo ' | ';

if ($total > $page + $num)
echo ' <a href="'.$href.'page='.($page + $num).'">Далее-&gt;</a>';
else echo 'Далее-&gt;';

echo '<br/>Страницы:';
$minus = $page-($num*3);
$plus = $page+($num*4);

if($minus<$total && $minus>0) echo ' <a href="'.$href.'page=0">1</a> ... ';

for($i=$minus; $i<$plus;){

if($i<$total && $i>=0){

$ii = floor(1+$i/$num);

if ($page==$i) echo ' <b>['.$ii.']</b>';
else echo ' <a href="'.$href.'page='.$i.'">'.$ii.'</a>';
}
$i=$i+$num;
}

if($plus<$total){
$whole = ceil($total/$num);
echo ' ... <a href="'.$href.'page='.($whole*$num-$num).'">'.$whole.'</a>';
}

echo '</div><div><form action="'.$href.'" method="post">Страница: <input type="text" name="go" value="'.floor(1+$page/$num).'" size="2" /><input type="submit" value="&gt;&gt;"/></form></div>';
}
}

?>