Файл: core/functions.php
Строк: 510
<?php
/*
* @author mides <Mike Osendowski>
* @link http://midwm.org
* @copyright 2011-2014
*/
function is_auth() {
global $config;
static $u = 0;
if (empty($u)) {
if (isset($_SESSION['suser']) and isset($_SESSION['skey'])) {
$user = DB::run()->queryFetch("select * from `users` where `username` = ? limit 1;", array(check($_SESSION['suser'])));
if (!empty($user['id'])) {
if ($_SESSION['skey'] == hash('sha512', md5(md5($user['password'].$config['keypass'])))) {
$u = $user;
}
}
}
}
return $u;
}
function access($access, $userid = FALSE) {
if ($userid)
{
$user = DB::run()->queryFetch("select `access` from `users` where `id` = ?;", array($userid));
$accessRange = explode(',', $user['access']);
if (in_array($access, $accessRange) or $user['access'] == 2) {
return true;
}
}
else
{
global $u;
if (is_auth()) {
$accessRange = explode(',', $u['access']);
if (in_array($access, $accessRange) or $u['access'] == 2) {
return true;
}
}
return false;
}
}
function is_admin($access) {
if (is_auth())
{
global $u;
static $a = 0;
if ($u['access'] >= $access)
{
$a = 1;
}
}
return $a;
}
function check($msg) {
if (is_array($msg)) {
foreach($msg as $key => $val) {
$msg[$key] = check($val);
}
} else {
$msg = htmlspecialchars($msg);
$search = array('|', ''', '$', '\', '^', '%', '`', " ", "x00", "x1A", chr(226) . chr(128) . chr(174));
$replace = array('|', ''', '$', '\', '^', '%', '`', '', '', '', '');
$msg = str_replace($search, $replace, $msg);
$msg = stripslashes(trim($msg));
}
return $msg;
}
function detectMob() {
/*
* http://detectmobilebrowsers.com/
* setcookie 1 for web, 2 for mobile
*/
$useragent = check($_SERVER['HTTP_USER_AGENT']);
if (preg_match('/(android|bbd+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i',substr($useragent,0,4)))
{
$theme = 2;
}
else
{
$theme = 1;
}
setcookie("theme", $theme, TIME + 3600 * 24 * 365, '/', '');
return $theme;
}
function redirect($url) {
header('Location: '.$url);
exit();
}
function utf_lower($str) {
if (function_exists('mb_strtolower')) return mb_strtolower($str, 'utf-8');
$arraytolower = array('А' => 'а', 'Б' => 'б', 'В' => 'в', 'Г' => 'г', 'Д' => 'д', 'Е' => 'е', 'Ё' => 'ё', 'Ж' => 'ж', 'З' => 'з', 'И' => 'и', 'Й' => 'й', 'К' => 'к', 'Л' => 'л', 'М' => 'м', 'Н' => 'н', 'О' => 'о', 'П' => 'п', 'Р' => 'р', 'С' => 'с', 'Т' => 'т', 'У' => 'у', 'Ф' => 'ф', 'Х' => 'х', 'Ц' => 'ц', 'Ч' => 'ч', 'Ш' => 'ш', 'Щ' => 'щ', 'Ь' => 'ь', 'Ъ' => 'ъ', 'Ы' => 'ы', 'Э' => 'э', 'Ю' => 'ю', 'Я' => 'я',
'A' => 'a', 'B' => 'b', 'C' => 'c', 'D' => 'd', 'E' => 'e', 'I' => 'i', 'F' => 'f', 'G' => 'g', 'H' => 'h', 'J' => 'j', 'K' => 'k', 'L' => 'l', 'M' => 'm', 'N' => 'n', 'O' => 'o', 'P' => 'p', 'Q' => 'q', 'R' => 'r', 'S' => 's', 'T' => 't', 'U' => 'u', 'V' => 'v', 'W' => 'w', 'X' => 'x', 'Y' => 'y', 'Z' => 'z');
return strtr($str, $arraytolower);
}
function genRandStr($length = "") {
if (empty($length)) {
$length = mt_rand(10, 12);
}
$salt = str_split('aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789');
$makepass = "";
for ($i = 0; $i < $length; $i++) {
$makepass .= $salt[array_rand($salt)];
}
return $makepass;
}
function sitedate($timestamp, $format = NULL) {
global $config;
global $lang;
if (!is_numeric($timestamp)) {
$timestamp = TIME;
}
if (empty($format)) {
$format = "d.m.y - H:i";
}
$shift = $config['timeshift'] * 3600;
$datestamp = date($format, $timestamp + $shift);
$today = date("d.m.y", TIME + $shift);
$yesterday = date("d.m.y", strtotime("-1 day") + $shift);
$datestamp = str_replace($today, $lang['Today'], $datestamp);
$datestamp = str_replace($yesterday, $lang['Yesterday'], $datestamp);
$search = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$replace = array('Января', 'Февраля', 'Марта', 'Апреля', 'Мая', 'Июня', 'Июля', 'Августа', 'Сентября', 'Октября', 'Ноября', 'Декабря');
$datestamp = str_replace($search, $replace, $datestamp);
return $datestamp;
}
function online($userid) {
if ($userid > 0)
{
$queryOnl = DB::run()->querySingle("select count(`id`) from `online` where `userid` = ?;", array($userid));
if ($queryOnl) {
return '<font color="green">[On]</font>';
}
return '<font color="red">[Off]</font>';
}
return FALSE;
}
function subtok($string, $chr, $pos, $len = null) {
return implode($chr, array_slice(explode($chr, $string), $pos, $len));
}
function getUserAgent() {
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$agent = check($_SERVER['HTTP_USER_AGENT']);
if (stripos($agent, 'Avant Browser') !== false) {
return 'Avant Browser';
} elseif (stripos($agent, 'Acoo Browser') !== false) {
return 'Acoo Browser';
} elseif (stripos($agent, 'MyIE2') !== false) {
return 'MyIE2';
} elseif (preg_match('|Iron/([0-9a-z.]*)|i', $agent, $pocket)) {
return 'SRWare Iron '.subtok($pocket[1], '.', 0, 2);
} elseif (preg_match('|Chrome/([0-9a-z.]*)|i', $agent, $pocket)) {
return 'Chrome '.subtok($pocket[1], '.', 0, 3);
} elseif (preg_match('#(Maxthon|NetCaptor)( [0-9a-z.]*)?#i', $agent, $pocket)) {
return $pocket[1] . $pocket[2];
} elseif (stripos($agent, 'Safari') !== false && preg_match('|Version/([0-9]{1,2}.[0-9]{1,2})|i', $agent, $pocket)) {
return 'Safari '.subtok($pocket[1], '.', 0, 3);
} elseif (preg_match('#(NetFront|K-Meleon|Netscape|Galeon|Epiphany|Konqueror|Safari|Opera Mini|Opera Mobile)/([0-9a-z.]*)#i', $agent, $pocket)) {
return $pocket[1].' '.subtok($pocket[2], '.', 0, 2);
} elseif (stripos($agent, 'Opera') !== false && preg_match('|Version/([0-9]{1,2}.[0-9]{1,2})|i', $agent, $pocket)) {
return 'Opera '.$pocket[1];
} elseif (preg_match('|Opera[/ ]([0-9a-z.]*)|i', $agent, $pocket)) {
return 'Opera '.subtok($pocket[1], '.', 0, 2);
} elseif (preg_match('|Orca/([ 0-9a-z.]*)|i', $agent, $pocket)) {
return 'Orca '.subtok($pocket[1], '.', 0, 2);
} elseif (preg_match('#(SeaMonkey|Firefox|GranParadiso|Minefield|Shiretoko)/([0-9a-z.]*)#i', $agent, $pocket)) {
return $pocket[1].' '.subtok($pocket[2], '.', 0, 3);
} elseif (preg_match('|rv:([0-9a-z.]*)|i', $agent, $pocket) && strpos($agent, 'Mozilla/') !== false) {
return 'Mozilla '.subtok($pocket[1], '.', 0, 2);
} elseif (preg_match('|Lynx/([0-9a-z.]*)|i', $agent, $pocket)) {
return 'Lynx '.subtok($pocket[1], '.', 0, 2);
} elseif (preg_match('|MSIE ([0-9a-z.]*)|i', $agent, $pocket)) {
return 'IE '.subtok($pocket[1], '.', 0, 2);
} else {
$agent = preg_replace('|http://|i', '', $agent);
$agent = strtok($agent, '( ');
$agent = substr($agent, 0, 22);
$agent = subtok($agent, '.', 0, 2);
if (!empty($agent)) {
return $agent;
}
}
}
return 'Unknown';
}
function pagin($page, $link, $pages) {
if ($pages > 1) {
echo '<div class="pagin">';
for ($k = 1; $k <= $pages; $k++) {
if ( $k == 1 or $k == $pages or 2 >= ($page - $k) and -2 <= ($page - $k) ) {
if ($k == $page) {
$write = ' <b>'.$k.'</b> ';
} else {
$write = '<a href="'.HTTPHOME.$link.'/page'.$k.'">'.$k.'</a>';
}
echo $write;
}
}
echo '</div>';
}
}
function GetDomain($ur) {
$nowww = str_replace('www.', '', $ur);
$domain = parse_url($nowww);
if (!empty($domain["host"]))
{
return $domain["host"];
}
else
{
return $domain["path"];
}
}
function username0($userid) {
if ($userid == 0)
{
$return = 'Guest';
}
else
{
$userF = DB::run()->queryFetch("select `username` from `users` where `id` = ?;", array($userid));
if ($userF)
{
return $userF['username'];
}
else
{
return 'Deleted';
}
}
return $return;
}
/*function newtitle($newtitle) {
global $lang;
if (substr($newtitle, 0, 5) == 'LANG.')
{
$str = str_replace('LANG.', '', $newtitle);
$return = $lang[$str];
}
else
{
$return = $newtitle;
}
return $return;
}*/
function ob_processing($str) {
global $config;
global $u;
global $lang;
if (isset($config['newtitle'])) {
$str = str_replace('{TITLE}', $config['newtitle'].' - '.$config['title'], $str);
} else {
$str = str_replace('{TITLE}', $config['title'], $str);
}
$str = str_replace('{HOME}', HOME, $str);
$str = str_replace('{HTTPHOME}', HTTPHOME, $str);
$str = preg_replace('#{LANG.(.*?)}#ie', '$lang{"$1"}', $str);
$str = str_replace('{USERNAME}', $u['username'], $str);
/*
* Check if folder with images of the current theme exists
* if it doesnt, then default theme images folder is used
*
* Проверяем, существует ли папка с изображениями текущей темы,
* если нет, тогда папка стандартной темы используется
*/
$defaultThemePrefix = substr($config['theme'], 0, 3);
switch ($defaultThemePrefix)
{
case 'web': $defaultTheme = 'web_default'; break;
default: $defaultTheme = 'mobile_default'; break;
}
$imgpath = HTTPHOME.'themes/'.(file_exists(LEVEL.'themes/'.$config['theme'].'/images/') ? $config['theme'] : $defaultTheme).'/images/';
$str = str_replace('{IMGPATH}', $imgpath, $str);
return $str;
}
function username($userid, $type = 0, $link = false) {
global $config;
/*
* Check if folder with images of the current theme exists
* if it doesnt, then default theme images folder is used
*
* Проверяем, существует ли папка с изображениями текущей темы,
* если нет, тогда папка стандартной темы используется
*/
$defaultThemePrefix = substr($config['theme'], 0, 3);
switch ($defaultThemePrefix)
{
case 'web': $defaultTheme = 'web_default'; break;
default: $defaultTheme = 'mobile_default'; break;
}
$iconpath = HTTPHOME.'themes/'.(file_exists(LEVEL.'themes/'.$config['theme'].'/user_icons/') ? $config['theme'] : $defaultTheme).'/user_icons/';
$userF = DB::run()->queryFetch("select `id`, `username`, `access`, `gender` from `users` where `id` = ?;", array($userid));
// types: 0 "just username from DB", 1 "username + color", 2 "icon, username & color"
// типы: 0 "просто логин с БД", 1 "логин + цвет", 2 "иконка, логин и цвет"
if ($userid == 0) {
switch ($type) {
case '2': $username = '<img src="'.$iconpath.'guest.png" alt="guest"> Guest'; break;
default: $username = 'Гость'; break;
}
} elseif ($userid == -1) {
switch ($type) {
case '2': $username = '<img src="'.$iconpath.'system.png" alt="system"> System'; break;
default: $username = 'System'; break;
}
} else {
if ($userF) {
switch ($type) {
case 1:
switch ($userF['access']) {
case '1': $username = '<font color="green">'.$userF['username'].'</font>'; break;
case '2': $username = '<font color="blue">'.$userF['username'].'</font>'; break;
case '3': $username = '<font color="red">'.$userF['username'].'</font>'; break;
case '4': $username = '<font color="red">'.$userF['username'].'</font>'; break;
default: $username = $userF['username']; break;
}
break;
case 2:
switch ($userF['access']) {
case '1': $username = '<img src="'.$iconpath.'user_gender'.$userF['gender'].'.png" alt=""> <font color="green">'.$userF['username'].'</font>'; break;
case 2: $username = '<img src="'.$iconpath.'moder_gender'.$userF['gender'].'.png" alt=""> <font color="blue">'.$userF['username'].'</font>'; break;
case 3: $username = '<img src="'.$iconpath.'admin_gender'.$userF['gender'].'.png" alt=""> <font color="red">'.$userF['username'].'</font>'; break;
case 4: $username = '<img src="'.$iconpath.'admin_gender'.$userF['gender'].'.png" alt=""> <font color="red">'.$userF['username'].'</font>'; break;
default: $username = '<img src="'.$iconpath.'user_gender'.$userF['gender'].'.png" alt=""> '.$userF['username']; break;
}
break;
default:
$username = $userF['username'];
break;
}
} else {
switch ($type) {
case '1': $username = '<font color="grey">Deleted</font>'; break;
case '2': $username = '<img src="'.$iconpath.'guest.png" alt="guest"> <font color="grey">Deleted</font>'; break;
default: $username = 'Deleted'; break;
}
}
}
return $link ? '<a href="/user'.$userF['id'].'">'.$username.'</a>' : $username;
}
function username2($userid) {
$userF = DB::run()->queryFetch("select `username`, `access` from `".DBprefix."users` where `id` = ?;", array($userid));
if ($userF)
{
switch ($userF['access'])
{
case 2: $return = '<img src="'.LEVEL.'/images/admin.png"> <font color="red">'.$userF['username'].'</font>'; break;
case 1: $return = '<img src="'.LEVEL.'/images/moder.png"> <font color="green">'.$userF['username'].'</font>'; break;
default: $return = $userF['username']; break;
}
return $return;
}
return FALSE;
}
function smiles($str) {
$totalcount = 0;
$query = DB::run()->query("SELECT `file`, `code` FROM `emoticons` ORDER BY LENGTH(`code`) DESC;");
while ($data = $query->Fetch() )
{
$countemot = substr_count($str, $data['code']);
if ($totalcount < 7 && $countemot < 7)
{
$str = str_replace($data['code'], '<img src="../../../images/emoticons/'.$data['file'].'" alt="smile">', $str, $count);
$totalcount = $totalcount + $count;
}
}
return $str;
}
function nosmiles($string) {
//$string = preg_replace('|<img src="../images/smiles/(.*?).gif" alt="smile" /> |', ':$1', $string);
$string = preg_replace('|<img src="../../../images/emoticons/(.*?).gif" alt="smile">|', ':$1', $string);
return $string;
}
function highlight_code($code) {
$code = nosmiles($code);
$code = strtr($code, array('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"', '$'=>'$', '%'=>'%', '''=>"'", '\'=>'\', '^'=>'^', '`'=>'`', '|' => '|', '<br />'=>"rn"));
$code = highlight_string($code, true);
$code = strtr($code, array("rn"=>'<br>', '://'=>'://', '$'=>'$', "'"=>''', '%'=>'%', '\'=>'\', '`'=>'`', '^'=>'^', '|'=>'|'));
$code = '<span class="code">'.$code.'</span>';
return $code;
}
function br($msg) {
$msg = preg_replace('"rn"', '<br />', $msg);
return $msg;
}
function bb($msg, $len = 90) {
$msg = preg_replace('#[code](.*?)[/code]#ie', 'highlight_code("1")', $msg);
$msg = preg_replace_callback('~[url=((https?|ftp)://.+?)](.+?)[/url]|((https?|ftp)://[0-9a-zа-яё/.;?=()_-&%#]+)~ui', 'url_replace', $msg);
$msg = preg_replace('#[big](.*?)[/big]#si', '<big>1</big>', $msg);
$msg = preg_replace('#[b](.*?)[/b]#si', '<b>1</b>', $msg);
$msg = preg_replace('#[i](.*?)[/i]#si', '<i>1</i>', $msg);
$msg = preg_replace('#[u](.*?)[/u]#si', '<u>1</u>', $msg);
$msg = preg_replace('#[small](.*?)[/small]#si', '<small>1</small>', $msg);
$msg = preg_replace('#[red](.*?)[/red]#si', '<span style="color:#ff0000">1</span>', $msg);
$msg = preg_replace('#[green](.*?)[/green]#si', '<span style="color:#00cc00">1</span>', $msg);
$msg = preg_replace('#[blue](.*?)[/blue]#si', '<span style="color:#0000ff">1</span>', $msg);
$msg = preg_replace('#[q](.*?)[/q]#si', '<div class="quote">1</div>', $msg);
$msg = preg_replace('#[del](.*?)[/del]#si', '<del>1</del>', $msg);
return $msg;
}
function url_replace($m) {
global $config;
if (!isset($m[4])) {
$target = (strpos($m[1], HOME) === false) ? ' target="_blank"' : '';
return '<a href="'.$m[1].'"'.$target.'>'.check(rawurldecode(html_entity_decode($m[3], ENT_QUOTES, 'utf-8'))).'</a>';
} else {
$target = (strpos($m[4], HOME) === false) ? ' target="_blank"' : '';
return '<a href="'.$m[4].'"'.$target.'>'.check(rawurldecode(html_entity_decode($m[4], ENT_QUOTES, 'utf-8'))).'</a>';
}
}
function str_to_en($string) {
$converter = array(
'а' => 'a', 'б' => 'b', 'в' => 'v',
'г' => 'g', 'д' => 'd', 'е' => 'e',
'ё' => 'e', 'ж' => 'zh', 'з' => 'z',
'и' => 'i', 'й' => 'y', 'к' => 'k',
'л' => 'l', 'м' => 'm', 'н' => 'n',
'о' => 'o', 'п' => 'p', 'р' => 'r',
'с' => 's', 'т' => 't', 'у' => 'u',
'ф' => 'f', 'х' => 'h', 'ц' => 'c',
'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sch',
'ь' => 'b', 'ы' => 'y', 'ъ' => 'b',
'э' => 'e', 'ю' => 'yu', 'я' => 'ya',
'А' => 'A', 'Б' => 'B', 'В' => 'V',
'Г' => 'G', 'Д' => 'D', 'Е' => 'E',
'Ё' => 'E', 'Ж' => 'Zh', 'З' => 'Z',
'И' => 'I', 'Й' => 'Y', 'К' => 'K',
'Л' => 'L', 'М' => 'M', 'Н' => 'N',
'О' => 'O', 'П' => 'P', 'Р' => 'R',
'С' => 'S', 'Т' => 'T', 'У' => 'U',
'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C',
'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sch',
'Ь' => 'b', 'Ы' => 'Y', 'Ъ' => 'b',
'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya',
'1' => '1'
);
$output = strtr($string, $converter);
$output = preg_replace('/[^a-z0-9а-яё]+/iu', '', $output);
return $output;
}
function note() {
if (isset($_SESSION['note']))
{
echo '<b>'.$_SESSION['note'].'</b><br>';
unset($_SESSION['note']);
}
}
function note2() {
if (isset($_SESSION['note2']))
{
echo '<b>'.$_SESSION['note2'].'</b><br>';
unset($_SESSION['note2']);
}
}
function findpagebyid($postid) {
global $config;
$post = DB::run()->query("select `threadid` from `forum_posts` where `id` = ?;", array($postid));
$totalPosts = DB::run()->query("select count(`id`) from `forum_posts` where `threadid` = ?;", array($post['threadid']));
$totalPages = ceil($totalPosts / $config['ipp']);
DB::run()->query("select * from `forum_posts` where `threadid` = ?;", array($post['id']));
}
function size($size) {
if ($size > 0 && $size < 1000)
{
$return = $size.' B';
}
elseif ($size > 1000 && $size < 1000 * 1000)
{
$kb = round($size / 1000, 2);
$return = $kb.' Kb';
}
elseif ($size > 1000 * 1000)
{
$mb = round($size / (1000 * 1000), 2);
$return = $mb.' Mb';
}
return $return;
}