Файл: system/sys_func.php
Строк: 698
<?
session_start();
if (!isset($_SESSION['user_id'])) {
$IP = $_SERVER['REMOTE_ADDR'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$time = time();
$w = mysql_query("SELECT * FROM `guests` WHERE `ip` = '$IP'");
if (mysql_num_rows($w) == 0) {
mysql_query("INSERT INTO `guests` ( `ip` , `browser` , `time`) VALUES ('$IP', '$browser', '". $time ."')");
} elseif (mysql_num_rows($w) > 0) {
mysql_query("UPDATE `guests` SET `browser` = '$browser', `time` = '". $time ."' WHERE `ip` = '$IP'");
}
if (isset($_COOKIE['login']) && isset($_COOKIE['pass'])) {
$login = mysql_real_escape_string($_COOKIE['login']);
$pass = mysql_real_escape_string($_COOKIE['pass']);
$sql = mysql_query("SELECT `id` FROM `users` WHERE `login` = '". $login ."' AND `pass` = '". $pass ."' LIMIT 1");
if (mysql_num_rows($sql) == 1) {
$user = mysql_fetch_assoc($sql);
$_SESSION['user_id'] = $user['id'];
}
}
}
if (isset($_SESSION['user_id'])) {
$sql = mysql_query("SELECT * FROM `users` WHERE `id` = '". $_SESSION['user_id'] ."'");
if (mysql_num_rows($sql) != 1) {
header('Location: /?logout');
exit;
}
$user = mysql_fetch_assoc($sql);
mysql_query("UPDATE `users` SET `time_last` = '". time() ."' WHERE `id` = '". $user['id'] ."' LIMIT 1");
} else {
$user = NULL;
}
function html($var) {
$return = mysql_real_escape_string(htmlspecialchars($var));
return $return;
}
// Время
function ptime($time = NULL) {
ini_set('date.timezone', 'Europe/Moscow');
if ($time == NULL) $time = time();
$full_time = date('d.m.Y', $time);
$date = date('d.m.Y', $time);
$timep = date('H:i', $time);
if ($date == date('d.m.Y')) $full_time = date('H:i', $time);
if ($date == date('d.m.Y', time()-60*60*24)) $full_time = date('Вчера, H:i', $time);
return $full_time;
}
// Низ сайта
function foot() {
$users147_on = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `time_last` > ". (time()-600) .""), 0);
if (isset($_SESSION['user_id'])) {
if ($_SERVER['PHP_SELF'] != '/index.php') {
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `rekl` WHERE `pos` = 'foot' AND `time` > '". time() ."'"), 0);
if ($count != 0) {
echo '<div class="rekl">';
$q = mysql_query("SELECT * FROM `rekl` WHERE `pos` = 'foot' AND `time` > '". time() ."' ORDER BY `id` ASC");
while ($rekl = mysql_fetch_assoc($q)) {
echo '<a href="http://'. $rekl['url'] .'">'. $rekl['name'] .'</a><br>';
}
echo '</div>';
}
echo '<div class="foot">
<a href="http://masteram.us/id580">SBeka</a>
<a href="/pages/users/?menu=online">Онлайн: '.$users147_on.'</a>
<a href="/pages/help.php">Помощь</a>
<a href="/exit.php">Выход</a><br>
</div>
</div>
</body>';
exit;
} else {
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `rekl` WHERE `pos` = 'foot' AND `time` > '". time() ."'"), 0);
if ($count != 0) {
echo '<div class="rekl">';
$q = mysql_query("SELECT * FROM `rekl` WHERE `pos` = 'foot' AND `time` > '". time() ."' ORDER BY `id` ASC");
while ($rekl = mysql_fetch_assoc($q)) {
echo '<a href="http://'. $rekl['url'] .'">'. $rekl['name'] .'</a><br>';
}
echo '</div>';
}
echo '<div class="foot">
<a href="http://masteram.us/id580">SBeka</a>
<a href="/pages/users/?menu=online">Онлайн: '.$users147_on.'</a>
<a href="/pages/help.php">Помощь</a>
<a href="/exit.php">Выход</a><br>
</div>
</div>
</body>';
exit;
}
}else{
echo '<div class="foot">
<a href="http://masteram.us/id580">SBeka</a>
<a href="/pages/users/?menu=online">Онлайн: '.$users147_on.'</a>
<a href="/pages/help.php">Помощь</a>
<a href="/login.php">Вход</a><br>
</div>
</div>
</body>';
exit;
}
}
//настройки сайта
$onpage = 5;//сообщений в странице
// Постраничная навигация
function page($k_page = 1) {
$page = 1;
if (isset($_GET['page'])) {
if ($_GET['page'] == 'end') $page = intval($k_page);
elseif (is_numeric($_GET['page'])) $page = intval($_GET['page']);
}
if ($page < 1) $page = 1;
if ($page > $k_page) $page = $k_page;
return $page;
}
function k_page($k_post = 0, $k_p_str = 10) {
if ($k_post != 0) {
$v_pages = ceil($k_post/$k_p_str);
return $v_pages;
}
else return 1;
}
function str($link = '?', $k_page = 1, $page = 1) {
if ($page < 1) $page = 1;
echo '<form class="post" method="get" action="'. $link .'?page=">';
if ($page > 1) echo '<a href="'. $link .'page='. ($page - 1) .'" title="Предыдущая страница (№'. ($page - 1) .')"><span style="color:#000;">←</span> Назад</a> ';
if ($page > 1 && $page < $k_page) echo '<span style="color:#000;">|</span>';
if ($page < $k_page)echo ' <a href="'. $link .'page='. ($page + 1) .'" title="Следующая страница (№'. ($page + 1) .')">Вперед <span style="color:#000;">→</span></a>';
echo '<br>';
if ($page != 1) echo '<a href="'. $link .'page=1" title="Страница №1"><span class="unsel">1</span></a>';
else echo '<span class="sel">1</span>';
for ($ot = -3; $ot <= 3; $ot++) {
if ($page + $ot > 1 && $page + $ot < $k_page) {
if ($ot == -3 && $page + $ot > 3) echo " ..";
if ($ot != 0) echo ' <a href="'. $link .'page='. ($page + $ot) .'" title="Страница №'. ($page + $ot) .'"><span class="unsel">'. ($page + $ot) .'</span></a>';
else echo ' <span class="sel">'. ($page + $ot) .'</span>';
if ($ot == 3 && $page + $ot < $k_page - 1) echo ' ..';
}
}
if ($page != $k_page) echo ' <a href="'. $link .'page=end" title="Страница №'. $k_page .'"><span class="unsel">'. $k_page .'</span></a>';
elseif ($k_page > 1)echo ' <span class="sel">'. $k_page .'</span>';
echo '<br><input type="text" size="3" name="page" /> <input value="GO!" type="submit" /></form>';
}
// Смайлы
function smiles($msg) {
$msg = strtr($msg, array(':)' => '<img src="/design/smiles/smile.png" alt="smile" />',
':-)' => '<img src="/design/smiles/smile.png" alt="smile" />',
':(' => '<img src="/design/smiles/sad.png" alt="smile" />',
':-(' => '<img src="/design/smiles/sad.png" alt="smile" />',
':D' => '<img src="/design/smiles/grin.png" alt="smile" />',
':-D' => '<img src="/design/smiles/grin.png" alt="smile" />',
';)' => '<img src="/design/smiles/wink.png" alt="smile" />',
';-)' => '<img src="/design/smiles/wink.png" alt="smile" />',
':\' => '<img src="/design/smiles/think.png" alt="smile" />',
':-\' => '<img src="/design/smiles/think.png" alt="smile" />',
':'(' => '<img src="/design/smiles/cry.png" alt="smile" />',
':'-(' => '<img src="/design/smiles/cry.png" alt="smile" />',
':@' => '<img src="/design/smiles/angry.png" alt="smile" />',
':-@' => '<img src="/design/smiles/angry.png" alt="smile" />',
':O' => '<img src="/design/smiles/shock.png" alt="smile" />',
':-O' => '<img src="/design/smiles/shock.png" alt="smile" />',
':*' => '<img src="/design/smiles/kiss.png" alt="smile" />',
':-*' => '<img src="/design/smiles/kiss.png" alt="smile" />',
':x' => '<img src="/design/smiles/quiet.png" alt="smile" />',
':-x' => '<img src="/design/smiles/quiet.png" alt="smile" />',
'B)' => '<img src="/design/smiles/glasses.png" alt="smile" />',
'B-)' => '<img src="/design/smiles/glasses.png" alt="smile" />',
'8)' => '<img src="/design/smiles/glasses_nerdy.png" alt="smile" />',
'8-)' => '<img src="/design/smiles/glasses_nerdy.png" alt="smile" />',
'':|' => '<img src="/design/smiles/sweat.png" alt="smile" />',
'':-|' => '<img src="/design/smiles/sweat.png" alt="smile" />',
':P' => '<img src="/design/smiles/mad_tongue.png" alt="smile" />',
':-P' => '<img src="/design/smiles/mad_tongue.png" alt="smile" />',
'O:)' => '<img src="/design/smiles/angel.png" alt="smile" />',
'O:-)' => '<img src="/design/smiles/angel.png" alt="smile" />',
':S' => '<img src="/design/smiles/confused.png" alt="smile" />',
':-S' => '<img src="/design/smiles/confused.png" alt="smile" />',
':L' => '<img src="/design/smiles/loser.png" alt="smile" />',
':-L' => '<img src="/design/smiles/loser.png" alt="smile" />',
':T' => '<img src="/design/smiles/time_out.png" alt="smile" />',
':-T' => '<img src="/design/smiles/time_out.png" alt="smile" />',
':Z' => '<img src="/design/smiles/sleepy.png" alt="smile" />',
':-Z' => '<img src="/design/smiles/sleepy.png" alt="smile" />',
':?' => '<img src="/design/smiles/question.png" alt="smile" />',
':-?' => '<img src="/design/smiles/question.png" alt="smile" />',
':пока' => '<img src="/design/smiles/bye.png" alt="smile" />',
':гордый' => '<img src="/design/smiles/arrogant.png" alt="smile" />',
':хлоп' => '<img src="/design/smiles/clap.png" alt="smile" />',
':клоун' => '<img src="/design/smiles/clown.png" alt="smile" />',
':ковбой' => '<img src="/design/smiles/cowboy.png" alt="smile" />',
':мечта' => '<img src="/design/smiles/desire.png" alt="smile" />',
':бес' => '<img src="/design/smiles/devil.png" alt="smile" />',
':слюни' => '<img src="/design/smiles/drool.png" alt="smile" />',
':стеснит' => '<img src="/design/smiles/embarrassed.png" alt="smile" />',
':ботан' => '<img src="/design/smiles/glasses_nerdy.png" alt="smile" />',
':ухожу' => '<img src="/design/smiles/go_away.png" alt="smile" />',
':гипноз' => '<img src="/design/smiles/hypnotized.png" alt="smile" />',
':влюбви' => '<img src="/design/smiles/inlove.png" alt="smile" />',
':ресницы' => '<img src="/design/smiles/lashes.png" alt="smile" />',
':лол' => '<img src="/design/smiles/lol.png" alt="smile" />',
':лузер' => '<img src="/design/smiles/loser.png" alt="smile" />',
':безлюбви' => '<img src="/design/smiles/love_over.png" alt="smile" />',
':лгун' => '<img src="/design/smiles/lying.png" alt="smile" />',
':язык' => '<img src="/design/smiles/mad_tongue.png" alt="smile" />',
':мат' => '<img src="/design/smiles/mat.png" alt="smile" />',
':хитрый' => '<img src="/design/smiles/mean.png" alt="smile" />',
':ногти' => '<img src="/design/smiles/nailbiting.png" alt="smile" />',
':нейтрален' => '<img src="/design/smiles/neutral.png" alt="smile" />',
':насвязи' => '<img src="/design/smiles/on_the_phone.png" alt="smile" />',
':вечеринка' => '<img src="/design/smiles/party.png" alt="smile" />',
':вопрос' => '<img src="/design/smiles/question.png" alt="smile" />',
':ржу' => '<img src="/design/smiles/rofl.png" alt="smile" />',
':саркастик' => '<img src="/design/smiles/sarcastic.png" alt="smile" />',
':больной' => '<img src="/design/smiles/sick.png" alt="smile" />',
':глупый' => '<img src="/design/smiles/silly.png" alt="smile" />',
':сонный' => '<img src="/design/smiles/sleepy.png" alt="smile" />',
':капля' => '<img src="/design/smiles/sweat.png" alt="smile" />',
':дум' => '<img src="/design/smiles/think.png" alt="smile" />',
':таймаут' => '<img src="/design/smiles/time_out.png" alt="smile" />',
':жду' => '<img src="/design/smiles/waiting.png" alt="smile" />',
':слёзы' => '<img src="/design/smiles/weep.png" alt="smile" />',
':зеваю' => '<img src="/design/smiles/yawn.png" alt="smile" />',
':злой' => '<img src="/design/smiles/angry.png" alt="smile" />',
':улыбка' => '<img src="/design/smiles/smile.png" alt="smile" />',
':печаль' => '<img src="/design/smiles/sad.png" alt="smile" />',
':плачу' => '<img src="/design/smiles/cry.png" alt="smile" />',
':смех' => '<img src="/design/smiles/grin.png" alt="smile" />',
':подмиг' => '<img src="/design/smiles/wink.png" alt="smile" />',
':шок' => '<img src="/design/smiles/shock.png" alt="smile" />',
':поцелуй' => '<img src="/design/smiles/kiss.png" alt="smile" />',
':рот' => '<img src="/design/smiles/quiet.png" alt="smile" />',
':очки' => '<img src="/design/smiles/glasses.png" alt="smile" />',
':ангел' => '<img src="/design/smiles/angel.png" alt="smile" />',
':плохо' => '<img src="/design/smiles/confused.png" alt="smile" />',
':позвони' => '<img src="/design/smiles/call_me.png" alt="smile" />'));
return $msg;
}
// ББ-коды
function bbcode($msg) {
$bb = array('~[url=(.*?)?](.*?)[/url]~si' => '<a href="$1" target="_blank">$2</a>',
'/[b](.+)[/b]/isU' => '<b>$1</b>',
'/[u](.+)[/u]/isU' => '<span style="text-decoration:underline;">$1</span>',
'/[s](.+)[/s]/isU' => '<s>$1</s>',
'/[img](.+)[/img]/isU' => '<img src="$1" style="max-width:100px;" />',
'/[i](.+)[/i]/isU' => '<i>$1</i>',
'/[color=(.+)](.+)[/color]/isU' => '<span style="color:$1;">$2</span>',
'/[quote](.+)[/quote]/isU' => '<div class="quote">$1</div>');
$msg = preg_replace(array_keys($bb), array_values($bb), $msg);
return $msg;
}
// Фильтрация для правильного вывода из базы данных
function output($msg) {
return smiles(bbcode(nl2br($msg)));
}
// Функция вывода онлайна
function online($user = NULL) {
global $time;
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$user' LIMIT 1"));
if ($ank['position'] == 'admin') {
if ($ank['time_last'] > (time()-600)) {
if ($ank['pol'] == '1') {
echo "<img src='/design/imgs/users/admin_man_on.png' alt='on' class='icon' /> ";
} else {
echo "<img src='/design/imgs/users/admin_woman_on.png' alt='on' class='icon' /> ";
}
} else {
if ($ank['pol'] == '1') {
echo "<img src='/design/imgs/users/admin_man_off.png' alt='off' class='icon' /> ";
} else {
echo "<img src='/design/imgs/users/admin_woman_off.png' alt='off' class='icon' /> ";
}
}
}
if ($ank['position'] == 'mod_f' || $ank['position'] == 'mod_c') {
if ($ank['time_last'] > (time()-600)) {
if ($ank['pol'] == '1') {
echo "<img src='/design/imgs/users/mod_man_on.png' alt='on' class='icon' /> ";
} else {
echo "<img src='/design/imgs/users/mod_woman_on.png' alt='on' class='icon' /> ";
}
} else {
if ($ank['pol'] == '1') {
echo "<img src='/design/imgs/users/mod_man_off.png' alt='off' class='icon' /> ";
} else {
echo "<img src='/design/imgs/users/mod_woman_off.png' alt='off' class='icon' /> ";
}
}
}
if ($ank['position'] == 'user') {
if ($ank['time_last'] > (time()-600)) {
if ($ank['pol'] == '1') {
echo "<img src='/design/imgs/users/man_on.png' alt='on' class='icon' /> ";
} else {
echo "<img src='/design/imgs/users/woman_on.png' alt='on' class='icon' /> ";
}
} else {
if ($ank['pol'] == '1') {
echo "<img src='/design/imgs/users/man_off.png' alt='off' class='icon' /> ";
} else {
echo "<img src='/design/imgs/users/woman_off.png' alt='off' class='icon' /> ";
}
}
}
}
//Вывод аватара
function online_avatar($user = NULL) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$user' LIMIT 1"));
if ($ank['avatar'] != 0) {
echo '<img src="/design/imgs/avatars/'. $ank['avatar'] .'.png" />';
} elseif (is_file("../../design/imgs/user_avatars/". $ank['id'] .".jpg")) {
echo '<a href="/design/imgs/user_avatars/'. $ank['id'] .'_orig.jpg" title="Открыть оригинал"><img style="border-radius:10px" width="130px" height="130px" src="/design/imgs/user_avatars/'. $ank['id'] .'.jpg" /></a>';
} elseif (is_file("../../design/imgs/user_avatars/". $ank['id'] .".png")) {
echo '<a href="/design/imgs/user_avatars/'. $ank['id'] .'_orig.png" title="Открыть оригинал"><img style="border-radius:10px" width="130px" height="130px" src="/design/imgs/user_avatars/'. $ank['id'] .'.png" /></a>';
} elseif (is_file("../../design/imgs/user_avatars/". $ank['id'] .".gif")) {
echo '<a href="/design/imgs/user_avatars/'. $ank['id'] .'_orig.gif" title="Открыть оригинал"><img src="/design/imgs/user_avatars/'. $ank['id'] .'.gif" /></a>';
} else {
if ($ank['pol'] == '1') echo '<img style="border-radius:10px" width="130px" height="130px" src="/design/imgs/no_ava_man.jpg" />';
elseif ($ank['pol'] == '0') echo '<img style="border-radius:10px" width="130px" height="130px" src="/design/imgs/no_ava_woman.jpg" />';
}
}
function avatar($user = NULL) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$user' LIMIT 1"));
if ($ank['avatar'] != 0) {
echo '<img src="/design/imgs/avatars/'. $ank['avatar'] .'.png" />';
} elseif (is_file("../../design/imgs/user_avatars/". $ank['id'] .".jpg")) {
echo '<a href="/pages/users/user.php?name='.$ank['login'].'" title="'.$ank['name'].'"><img width="32px" height="32px" src="/design/imgs/user_avatars/'. $ank['id'] .'.jpg" /></a>';
} elseif (is_file("../../design/imgs/user_avatars/". $ank['id'] .".png")) {
echo '<a href="/pages/users/user.php?name='.$ank['login'].'" title="'.$ank['name'].'"><img width="32px" height="32px" src="/design/imgs/user_avatars/'. $ank['id'] .'.png" /></a>';
} elseif (is_file("../../design/imgs/user_avatars/". $ank['id'] .".gif")) {
echo '<a href="/pages/users/user.php?name='.$ank['login'].'" title="'.$ank['name'].'"><img src="/design/imgs/user_avatars/'. $ank['id'] .'.gif" /></a>';
} else {
if ($ank['pol'] == '1') echo '<a href="/pages/users/user.php?name='.$ank['login'].'" title="'.$ank['name'].'"><img src="/design/imgs/no_avatar_man.png" /></a>';
elseif ($ank['pol'] == '0') echo '<a href="/pages/users/user.php?name='.$ank['login'].'" title="'.$ank['name'].'"><img src="/design/imgs/no_avatar_woman.png" /></a>';
}
}
//Вывод должности
function position($user = NULL) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$user' LIMIT 1"));
if ($ank['position'] == 'admin') {
echo "<span style='color:green; font-size: small;'><small>Администратор сайта</small></span><br>";
} elseif ($ank['position'] == 'mod_f') {
echo "<span style='color:green; font-size: small;'><small>Модератор Форума</small></span><br>";
} elseif ($ank['position'] == 'mod_c') {
echo "<span style='color:green; font-size: small;'><small>Модератор Мини-Чата</small></span><br>";
}
}
// Определение браузера
function browser($user = NULL) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$user' LIMIT 1"));
$ua = strtolower($ank['agent']);
$path_pc = ' <img src="/design/imgs/PC.png" /> ';
$path_mob = ' <img src="/design/imgs/phone.png" /> ';
if ($ank['time_last'] > (time()-600)) {
// Компьютерные браузеры
if (preg_match('#(orca)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/orca.png" alt="" />';
elseif (preg_match('#(lunascape)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/lunascape.png" alt="" />';
elseif (preg_match('#(arora)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/arora.png" />';
elseif (preg_match('#(coolnovo)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/coolnovo.png" alt="" />';
elseif (preg_match('#(kylo)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/kylo.png" alt="" />';
elseif (preg_match('#(flock)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/flock.png" alt="" />';
elseif (preg_match('#(rockmelt)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/rockmelt.png" alt="" />';
elseif (preg_match('#(cometbird)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/cometbird.png" alt="" />';
elseif (preg_match('#(seamonkey)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/seamonkey.png" alt="" />';
elseif (preg_match('#(iron)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/iron.png" alt="" />';
elseif (preg_match('#(presto)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/opera.png" alt="" />';
elseif (preg_match('#(yabrowser)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/yabrowser.png" alt="" />';
elseif (preg_match('#(chrome)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/chrome.png" alt="" />';
elseif (preg_match('#(msie)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/msie.png" alt="" />';
elseif (preg_match('#(maxthon)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/maxthon.png" alt="" />';
elseif (preg_match('#(safari)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/safari.png" alt="" />';
elseif (preg_match('#(qtweb)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/qtweb.png" alt="" />';
elseif (preg_match('#(firefox)#ui', $ua)) $browser = $path_pc .'<img src="/design/imgs/browsers/firefox.png" alt="" />';
// Мобильные браузеры
if (preg_match('#(sonyericsson)#ui', $ua)) $browser = $path_mob .'<img src="/design/imgs/browsers/sony_ericsson.png" alt="" />';
elseif (preg_match('#(ipod)#ui', $ua)) $browser = $path_mob .'<img src="/design/imgs/browsers/apple.png" alt="" />';
elseif (preg_match('#(iphone)#ui', $ua)) $browser = $path_mob .'<img src="/design/imgs/browsers/apple.png" alt="" />';
elseif (preg_match('#(android)#ui', $ua)) $browser = $path_mob .'<img src="/design/imgs/browsers/android.png" alt="" />';
elseif (preg_match('#(symbian)#ui', $ua)) $browser = $path_mob .'<img src="/design/imgs/browsers/symbian.png" alt="" />';
elseif (preg_match('#(windowsphone)#ui', $ua)) $browser = $path_mob .'<img src="/design/imgs/browsers/windows.png" alt="" />';
elseif (preg_match('#(wp7)#ui', $ua)) $browser = $path_mob .'<img src="/design/imgs/browsers/windows.png" alt="" />';
elseif (preg_match('#(wp8)#ui', $ua)) $browser = $path_mob .'<img src="/design/imgs/browsers/windows.png" alt="" />';
elseif (preg_match('#(webos)#ui', $ua)) $browser = $path_mob .'<img src="/design/imgs/browsers/hp.png" alt="" />';
elseif (preg_match('#(blackberry)#ui', $ua)) $browser = $path_mob .'<img src="/design/imgs/browsers/blackberry.png" alt="" />';
elseif (preg_match('#(htc)#ui', $ua)) $browser = $path_mob .'<img src="/design/imgs/browsers/htc.png" alt="" />';
elseif (preg_match('#(opera m)#ui', $ua)) $browser = $path_mob .'<img src="/design/imgs/browsers/opera.png" alt="" />';
return $browser;
$arr = array('nokia',
'samsung',
'siemens',
'fly',
'motorola',
'sharp',
'sony',
'lg',
'acer',
'alcatel',
'asus',
'gigabyte',
'highscreen',
'huawei',
'philips',
'mts',
'midp-2.0',
'ucweb');
foreach ($arr as $value) {
if (strpos($ua, $value) !== false) {
$browser = $path_mob;
return $browser;
}
}
}
}
// Функция для удаления папки
function removeDirectory($dir) {
if ($objs = glob($dir."/*")) {
foreach($objs as $obj) {
is_dir($obj) ? removeDirectory($obj) : unlink($obj);
}
}
rmdir($dir);
}
function size($num) {
if ($num >= 1000000000000) {
$num = round($num / 1099511627776, 1);
$unit = "tb";
} elseif ($num >= 1000000000) {
$num = round($num / 1073741824, 1);
$unit ="gb";
} elseif ($num >= 1000000) {
$num = round($num / 1048576, 1);
$unit = "mb";
} elseif ($num >= 1000) {
$num = round($num / 1024, 1);
$unit = "kb";
} else {
$unit = "bytes";
return number_format($num).' '.$unit;
}
return number_format($num, 1).' '.$unit;
}
function userName($userid) {
$sqlUserNameFunc = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id`='$userid' LIMIT 1 "));
if (empty($sqlUserNameFunc['name']) || empty($sqlUserNameFunc['imname'])) {
$writename = $sqlUserNameFunc['login'];
} else {
$writename = $sqlUserNameFunc['name'].' '.$sqlUserNameFunc['imname'];
}
return $writename;
}
// Фильтрация данных
function filter($var) {
$return = trim(htmlspecialchars(mysql_real_escape_string($var)));
return $return;
}
?>