Файл: mydcms.tk/system/function.php
Строк: 1223
<?php
function antimat($str)
{
global $user,$time,$set;
if ($set['antimat'])
{
$antimat=&$_SESSION['antimat'];
include_once H.'sys/inc/censure.php';
$censure=censure($str);
if ($censure)
{
$antimat[$censure]=$time;
if (count($antimat)>3 && isset($user) && $user['level']) // если сделано больше 3-х предупреждений
{
$prich="Обнаружен мат: $censure";
$timeban=$time+60*60; // бан на час
mysql_query("INSERT INTO `ban` (`id_user`, `id_ban`, `prich`, `time`) VALUES ('$user[id]', '0', '$prich', '$timeban')");
admin_log('Пользователи','Бан',"Бан пользователя '[url=/amd_panel/ban.php?id=$user[id]]$user[nick][/url]' (id#$user[id]) до ".vremja($timeban)." по причине '$prich'");
header('Location: /ban.php?'.SID);exit;
}
return $censure;
}
else return false;
}
else return false;
}
function output_text($str,$br=1,$html=1,$smiles=1,$links=1,$bbcode=1)
{
global $theme_ini;
//if ($br && isset($theme_ini['text_width']))$str=wordwrap($str, $theme_ini['text_width'], ' ',1);
if ($html)$str=htmlentities($str, ENT_QUOTES, 'UTF-8'); // преобразуем все к нормальному перевариванию браузером
if ($links)$str=links($str); // обработка ссылок
if ($smiles)
$str=smiles($str); // вставка смайлов
if ($bbcode)
{
$tmp_str=$str;
$str=bbcode($str); // обработка bbcode
}
if ($br)
{
$str=br($str); // переносы строк
}
return stripslashes($str); // возвращаем обработанную строку
}
// для форм
function input_value_text($str){return output_text($str,0,1,0,0,0);}
function strlen2($str)
{
$rus=array('й','ц','у','к','е','н','г','ш','щ','з','х','ъ','ф','ы','в','а','п','р','о','л','д','ж','э','я','ч','с','м','и','т','ь','б','ю','Й','Ц','У','К','Е','Н','Г','Ш','Щ','З','Х','Ъ','Ф','Ы','В','А','П','Р','О','Л','Д','Ж','Э','Я','Ч','С','М','И','Т','Ь','Б','Ю');
return strlen(str_replace($rus, '0', $str));
}
function my_esc($str)
{
return mysql_real_escape_string($str);
}
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 "<div class="str">n";
if ($page!=1)echo "<a href="".$link."page=1" title='Первая страница'><<</a> ";
if ($page>1)echo "<a href="".$link."page=".($page-1)."" title='Предыдущая страница (№".($page-1).")'><назад</a> ";
echo " ";
if ($page<$k_page)echo " <a href="".$link."page=".($page+1)."" title='Следующая страница (№".($page+1).")'>далее></a>";
if ($page!=$k_page)echo " <a href="".$link."page=end" title='Последняя страница'>>></a>";
echo "<br />n";
if ($page!=1)echo "<a href="".$link."page=1" title='Страница №1'>1</a>";else echo "<b>1</b>";
for ($ot=-3; $ot<=3; $ot++){
if ($page+$ot>1 && $page+$ot<$k_page){
if ($ot==-3 && $page+$ot>2)echo " ..";
if ($ot!=0)echo " <a href="".$link."page=".($page+$ot)."" title='Страница №".($page+$ot)."'>".($page+$ot)."</a>";else echo " <b>".($page+$ot)."</b>";
if ($ot==3 && $page+$ot<$k_page-1)echo " ..";}}
if ($page!=$k_page)echo " <a href="".$link."page=end" title='Страница №$k_page'>$k_page</a>";elseif ($k_page>1)echo " <b>$k_page</b>";
echo "</div>n";
}
//-------------функция микросекунд-------------//
function getmicrotime()
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
//-------------функция определения правильного размера-------------//
function get_size($size)
{
if ($size < 1024) $size = $size . 'Bt';
if ($size > 1024 and $size < 1048576) $size = round($size / 1024, 1) . 'Kb';
if ($size >= 1048576) $size = round(($size / 1024) / 1024, 1) . 'Mb';
return $size;
}
//-------------функция последней деректории-------------//
function getWithOutPath($filename)
{
return end(explode('/', $filename));
}
// ------------- Функция вывода пользовательских тегов --------------//
function quickcode()
{
?>
<script charset="utf-8" src="/js/bbcode.js" type="text/javascript"></script>
<a href="javascript:bb_b('Site');" title="Жирный"><img src="/views/icon/bbcode/b.gif" alt="" /></a>
<a href="javascript:bb_i('Site');" title="Курсив"><img src="/views/icon/bbcode/i.gif" alt="" /></a>
<a href="javascript:bb_u('Site');" title="Подчеркивание"><img src="/views/icon/bbcode/u.gif" alt="" /></a>
<a href="javascript:bb_url('Site');" title="Ссылка"><img src="/views/icon/bbcode/url.gif" alt="" /></a>
<a href="javascript:bb_q('Site');" title="Цитата"><img src="/views/icon/bbcode/q.gif" alt="" /></a>
<a href="javascript:bb_img('Site');" title="Картинкa"><img src="/views/icon/bbcode/img.gif" alt="" /></a>
<a href="javascript:bb_red('Site');" title="Красный"><img src="/views/icon/bbcode/red.gif" alt="" /></a>
<a href="javascript:bb_green('Site');" title="Зеленый"><img src="/views/icon/bbcode/green.gif" alt="" /></a>
<a href="javascript:bb_blue('Site');" title="Синий"><img src="/views/icon/bbcode/blue.gif" alt="" /></a><br />
<?
}
// -------------- Вспомогательная функция быстрой вставки -------------//
function quickpaste($form)
{
echo '<script language="JavaScript" type="text/javascript">
function tag(text1, text2) {
if ((document.selection)) {
document.form.' . $form . '.focus();
document.form.document.selection.createRange().text = text1+document.form.document.selection.createRange().text+text2;
} else if(document.forms['form'].elements['' . $form . ''].selectionStart!=undefined) {
var element = document.forms['form'].elements['' . $form . ''];
var str = element.value;
var start = element.selectionStart;
var length = element.selectionEnd - element.selectionStart;
element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
} else document.form.' . $form . '.value += text1+text2;
}
</script>';
}
//-------------функция удаления деректории со вложенными файлами-------------//
function removeDir($dir)
{
if ($objs = glob($dir . '/*'))
{
foreach($objs as $obj)
{
unlink($obj);
}
}
rmdir($dir);
}
//-------------функция перевода секунд в дни-------------//
function makestime($string)
{
$day = floor($string / 86400);
$hours = floor(($string / 3600) - $day * 24);
$min = floor(($string - $hours * 3600 - $day * 86400) / 60);
$sec = $string - ($min * 60 + $hours * 3600 + $day * 86400);
return sprintf("%01d дн %02d час %02d мин %02d сек", $day, $hours, $min, $sec);
}
//-------------функция перевода секунд во время-------------//
function maketime($string)
{
if ($string < 3600) {
$string = sprintf("%02d:%02d", (int)($string / 60) % 60, $string % 60);
} else {
$string = sprintf("%02d:%02d:%02d", (int)($string / 3600) % 24, (int)($string / 60) % 60, $string % 60);
}
return $string;
}
// --------------- Функция правильного вывода времени -------------------//
function formattime($file_time)
{
if ($file_time >= 86400) {
$file_time = 'суток: ' . round((($file_time / 60) / 60) / 24, 1);
} elseif ($file_time >= 3600) {
$file_time = 'часов: ' . round(($file_time / 60) / 60, 1);
} elseif ($file_time >= 60) {
$file_time = 'минут: ' . round($file_time / 60);
} else {
$file_time = 'секунд: ' . round($file_time);
}
return $file_time;
}
//-------------Функция правильного вычитания-------------//
function minus($all, $minus) {
$all -= $minus;
if (0 > $all) $all = 0;
return $all;
}
//-------------Функция склонения чисел-------------//
function plural($n, $form1, $form2, $form5)
{
$n = abs($n) % 100;
$n1 = $n % 10;
if ($n > 10 && $n < 20) return $form5;
if ($n1 > 1 && $n1 < 5) return $form2;
if ($n1 == 1) return $form1;
return $form5;
}
//-------------Функция текстовой каптчи-------------//
function captcha($var)
{
$var = strtr($var, array(0 => 'ноль ',
1 => 'один ',
2 => 'два ',
3 => 'три ',
4 => 'четыре ',
5 => 'пять ',
6 => 'шесть ',
7 => 'семь ',
8 => 'восемь ',
9 => 'девять '));
return $var;
}
//------------------ Функция определения реального IP --------------------//
require_once 'class_ipinit.php';
$ipinit = new ipinit();
$ipl = $ipinit->ip;
$ipp = long2ip($ipl);
unset($ipinit);
//------------------ Функция определения реального браузера --------------------//
if (empty($_SESSION['user_brow'])) {
if (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])) {
$agent = $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
} elseif (isset($_SERVER['HTTP_USER_AGENT'])) {
$agent = $_SERVER['HTTP_USER_AGENT'];
} else {
$agent = 'Not_detected';
}
$agent = preg_replace('|http://|i','', $agent);
$agent = strtok($agent,'( ');
$_SESSION['user_brow'] = substr($agent, 0, 22);
}
$agent = check($_SESSION['user_brow']);
//-------------Функция времени-------------//
function vrem($time = NULL)
{
global $id, $time;
if ($time == NULL) $time = time();
if (isset($id)) $time = $time + 120 * 60 * 60;
$timep = date("j M Y в H:i", $time);
$time_p[0] = date("j n Y", $time);
$time_p[1] = date("H:i", $time);
if ($time_p[0] == date("j n Y")) $timep = date("H:i:s", $time);
if (isset($id)) {
if ($time_p[0] == date("j n Y", time() + 120 * 60 * 60)) $timep = date("H:i:s", $time);
if ($time_p[0] == date("j n Y", time() - 60 * 60 * (24 - 120))) $timep = "Вчера в $time_p[1]";
}
else
{
if ($time_p[0] == date("j n Y")) $timep = date("H:i:s", $time);
if ($time_p[0] == date("j n Y", time() - 60 * 60 * 24)) $timep = "Вчера в $time_p[1]";}
$timep = str_replace("Jan","Янв", $timep);
$timep = str_replace("Feb","Фев", $timep);
$timep = str_replace("Mar","Марта", $timep);
$timep = str_replace("May","Мая", $timep);
$timep = str_replace("Apr","Апр", $timep);
$timep = str_replace("Jun","Июня", $timep);
$timep = str_replace("Jul","Июля", $timep);
$timep = str_replace("Aug","Авг", $timep);
$timep = str_replace("Sep","Сент", $timep);
$timep = str_replace("Oct","Окт", $timep);
$timep = str_replace("Nov","Ноября", $timep);
$timep = str_replace("Dec","Дек", $timep);
return $timep;
}
//-------------Принудительно вырубаем глобальные переменные-------------//
if (ini_get('register_globals')) {
$allowed = array('_ENV' => 1, '_GET' => 1, '_POST' => 1, '_COOKIE' => 1, '_FILES' => 1, '_SERVER' => 1, '_REQUEST' => 1, 'GLOBALS' => 1);
foreach ($GLOBALS as $key => $value) {
if (!isset($allowed[$key])) {
unset($GLOBALS[$key]);
}
}
}
//-------------функция антимата-------------//
function mat($str)
{
include_once 'censure.php';
$censure = censure($str);
if ($censure)
{
$str = preg_replace('/[(.*)]/siu', '<span style="color: #FF0000;"><b>[censored]</b></span>', $censure);
return $str;
}
else return $str;
}
//-------------воспомагательная функция линков-------------//
function url_replace($m)
{
if (isset($_SESSION['us']))
{
if (!isset($m[3])) {
return '<a href="/link.php?link=' . base64_encode($m[1]) . '">' . $m[2] . '</a>';
} else {
return '<a href="/link.php?link=' . base64_encode($m[3]) . '">' . $m[3] . '</a>';
}
} else {
return 'Ссылки доступны только авторизированным!';
}
}
//-------------функция подсветки PHP-кода-------------//
function highlight($code)
{
$code = strtr($code, array('<br />' => "rn", '<br/>' => "rn", '<' => '<', '>' => '>', '&' => '&', '$' => '$', '"' => '"', ''' => "'", '\' => '\', '`' => '`', '%' => '%', '^' => '^'));
if (!strpos($code, '<?') && mb_substr($code, 0, 2, 'UTF-8') != '<?')
{
$code = "<?phprn" . trim($code) . "rn?>";
}
$code = highlight_string($code, true);
$code = strtr($code, array('<br />' => "rn", '<br/>' => "rn"));
$code = preg_replace('|( {2,})|', "rn1", $code);
$codeline = explode("rn", $code);
foreach($codeline as $line => $string)
{
if ($string != '') {
$ret .= '<li> ' . trim($string) . '</li>';
}
}#<span style="color:#666">' . ($line + 1) . '</span><br/>
$code = strtr($ret, array('$' => '$', "'" => ''', '\' => '\', '`' => '`', '%' => '%', '^' => '^'));
return '<div class="code"><ol>' . $code . '</ol></div>';
}
//-------------функция ББ-кодов-------------//
function bb_code($msg)
{
$msg = preg_replace('|<img src="/smiles/(.*?)" alt="(.*?)"/>|', '2', $msg);
$msg = preg_replace('#[code](.*?)[/code]#ie', "highlight('$1')", $msg);
$msg = preg_replace('#[img](.*?)[/img]#si', '<img src=1>', $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('#[red](.*?)[/red]#si', '<span style="color:#ff0000">1</span>', $msg);
$msg = preg_replace('#[green](.*?)[/green]#si', '<span style="color:#00bb00">1</span>', $msg);
$msg = preg_replace('#[blue](.*?)[/blue]#si', '<span style="color:#0000bb">1</span>', $msg);
$msg = preg_replace('#[q](.*?)[/q]#si', '<div class="q">1</div>', $msg);
$msg = preg_replace_callback('~\[url=(http://.+?)\](.+?)\[/url\]~', 'url_replace', $msg);
return $msg;
}
//-------------функция обратной замены ББ-кодов-------------//
function back_bb($msg)
{
$msg = preg_replace('/<br/>/si', "n", $msg);
$msg = preg_replace('/<br />/si', "n", $msg);
$msg = preg_replace('/<img src=(.*)>/si', '[img]1[/img]', $msg);
$msg = preg_replace('/<b>(.*)</b>/si', '[b]1[/b]', $msg);
$msg = preg_replace('/<u>(.*)</u>/si', '[u]1[/u]', $msg);
$msg = preg_replace('/<i>(.*)</i>/si', '[i]1[/i]', $msg);
$msg = preg_replace('/<div class="q">(.*)</div>/si', '[q]1[/q]', $msg);
$msg = preg_replace('/<span style="color:#ff0000">(.*)</span>/si', '[red]1[/red]', $msg);
$msg = preg_replace('/<span style="color:#00bb00">(.*)</span>/si', '[green]1[/green]', $msg);
$msg = preg_replace('/<span style="color:#0000bb">(.*)</span>/si', '[blue]1[/blue]', $msg);
$msg = preg_replace('/<img src="/smiles/(.*)" alt="(.*)"/>/si', '2', $msg);
$msg = preg_replace('/<a href="/link.php?&l=http://(.*?)">(.*)</a>/isU', '[url=http://1]2[/url]', $msg);
return $msg;
}
//------------- Функция вырезания ББ-кодов -------------//
function notags($var = '')
{
$var = strtr($var, array(
'[b]' => '',
'[/b]' => '',
'[red]' => '',
'[/red]' => '',
'[green]' => '',
'[/green]' => '',
'[blue]' => '',
'[/blue]' => '',
'[img]' => '',
'[/img]' => '',
'[u]' => '',
'[/u]' => '',
'[i]' => '',
'[/i]' => '',
'[q]' => '',
'[/q]' => '',
'[code]' => '',
'[/code]' => ''
));
return $var;
}
//-------------функция просмотра градиента-------------//
function PreviewGrad($var)
{
$var = user_inf($var, 'color');
if ($var == 1) $name = '<span style="background-color: #000000;"> </span><span style="background-color: #FF0000;"> </span>';
elseif ($var == 2) $name = '<span style="background-color: #000000;"> </span><span style="background-color: #00FF00;"> </span>';
elseif ($var == 3) $name = '<span style="background-color: #000000;"> </span><span style="background-color: #DDE4DA;"> </span>';
elseif ($var == 4) $name = '<span style="background-color: #000000;"> </span><span style="background-color: #0000FF;"> </span>';
elseif ($var == 5) $name = '<span style="background-color: #FF0000;"> </span><span style="background-color: #A80AEA;"> </span>';
elseif ($var == 6) $name = '<span style="background-color: #0000FF;"> </span><span style="background-color: #0ADFEC;"> </span>';
elseif ($var == 7) $name = '<span style="background-color: #FCD05B;"> </span><span style="background-color: #E665F9;"> </span>';
elseif ($var == 8) $name = '<span style="background-color: #C3C3C3;"> </span><span style="background-color: #2020EF;"> </span>';
elseif ($var == 9) $name = '<span style="background-color: #4ECF0F;"> </span><span style="background-color: #FAB600;"> </span>';
elseif ($var == 10) $name = '<span style="background-color: #F3F016;"> </span><span style="background-color: #3A2FC8;"> </span>';
elseif ($var == 11) $name = '<span style="background-color: #E80A24;"> </span><span style="background-color: #F9BB14;"> </span>';
elseif ($var == 12) $name = '<span style="background-color: #46A6F7;"> </span><span style="background-color: #0AD90A;"> </span>';
elseif ($var == 13) $name = '<span style="background-color: #EA18F7;"> </span><span style="background-color: #000000;"> </span>';
else $name = '<span style="background-color: #003A77;"> </span>';
return $name;
}
//-------------функция наложения копирайта-------------//
function img_copyright($img)
{
$copy_path = $_SERVER
['DOCUMENT_ROOT'] . '/ico/copy.png';
if (isset($copy_path) && $copy_path != null && $copy = @imagecreatefromstring(file_get_contents($copy_path)))
{
$img_x = imagesx($img);
$img_y = imagesy($img);
$copy_x = imagesx($copy);
$copy_y = imagesy($copy);
$w = intval(min($img_x / 2.5, $copy_x, 128));
$h = intval(min($img_y / 2.5, $copy_y, 64));
$x_ratio = $w / $copy_x;
$y_ratio = $h / $copy_y;
if (($copy_x <= $w) && ($img_y <= $h))
{
$dstW = $copy_x;
$dstH = $copy_y;
}
elseif (($x_ratio * $copy_y) < $h)
{
$dstH = ceil($x_ratio * $copy_y);
$dstW = $w;
}
else
{
$dstW = ceil($y_ratio * $copy_x);
$dstH = $h;
}
imagecopyresampled($img, $copy, $img_x - $dstW, $img_y - $dstH, 0, 0, $dstW, $dstH, $copy_x, $copy_y);
}
return $img2166;
}
//-------------функция названия должности-------------//
function elite($var)
{
if (user_inf($var, 'level') == 0) $return = 'Пользователь';
elseif (user_inf($var, 'level') == 1) $return = 'Пользователь';
elseif (user_inf($var, 'level') == 2) $return = 'Модератор';
elseif (user_inf($var, 'level') == 3) $return = 'Ст.Модератор';
elseif (user_inf($var, 'level') == 4) $return = 'Администратор';
elseif (user_inf($var, 'level') == 5) $return = 'Ст.Админ';
return $return;
}
//-------------функция градиента-------------//
function GradientLetter($text, $from = '', $to = '', $mode = 'hex')
{
$text = iconv('UTF-8', 'windows-1251', $text);
if ($mode == 'hex') {
$to = hexdec($to[0] . $to[1]) . ',' . hexdec($to[2] . $to[3]) . ',' . hexdec($to[4] . $to[5]);
$from = hexdec($from[0] . $from[1]) . ',' . hexdec($from[2] . $from[3]) . ',' . hexdec($from[4] . $from[5]);
}
if (empty($text)) return null;
else $levels = strlen($text);
if (empty($from)) $from = array(0, 0, 255);
else $from = explode(',', $from);
if (empty($to)) $to = array(255, 0, 0);
else $to = explode(',', $to); $output = null;
for ($i = 1; $i <= $levels; $i++) {
for ($ii = 0; $ii < 3; $ii++) {
$tmp[$ii] = $from[$ii] - $to[$ii];
$tmp[$ii] = floor($tmp[$ii] / $levels);
$rgb[$ii] = $from[$ii] - ($tmp[$ii] * $i);
if ($rgb[$ii] > 255) $rgb[$ii] = 255;
$rgb[$ii] = dechex($rgb[$ii]);
$rgb[$ii] = strtoupper($rgb[$ii]);
if (strlen($rgb[$ii]) < 2) $rgb[$ii] = 0 . $rgb[$ii];
}
$output .= '<span style="color: #'.$rgb['0'].$rgb['1'].$rgb['2'].'">'.$text[$i-1].'</span>';
}
return iconv('windows-1251', 'UTF-8', $output);
}
//-------------функции постов форума-------------//
function forumPost($var)
{
return mysql_num_rows(mysql_query("SELECT id FROM f_message WHERE user = '$var'"));
}
//-------------функции лучших постов форума-------------//
function forumBest($var)
{
return mysql_num_rows(mysql_query("SELECT id FROM f_message WHERE user = '$var' AND best = '1'"));
}
//-------------функции худших постов форума-------------//
function forumWorse($var)
{
return mysql_num_rows(mysql_query("SELECT id FROM f_message WHERE user = '$var' AND worse = '1'"));
}
//-------------функции ника (с онлайном)-------------//
function us($ius)
{
global $user;
if (isset($ius)) $ius = intval($ius);
$result = mysql_query("SELECT `id`,`color`,`user`,`img`,`sex`,`date`,`birth`,`on_time` FROM `users` WHERE `id` = '$ius' LIMIT 1");
$nik = mysql_fetch_assoc($result);
if (!empty($nik['id'])) {
if ($nik['sex'] == 2) $_sex = 'М';
elseif ($nik['sex'] == 1) $_sex = 'Ж';
else $_sex = 'Не установлен';
$name = $nik['user'];
if ($nik['color'] == 1) $name = GradientLetter($name, '000000', 'FF0000');
elseif ($nik['color'] == 2) $name = GradientLetter($name, '000000', '00FF00');
elseif ($nik['color'] == 3) $name = GradientLetter($name, '000000', 'DDE4DA');
elseif ($nik['color'] == 4) $name = GradientLetter($name, '000000', '0000FF');
elseif ($nik['color'] == 5) $name = GradientLetter($name, 'FF0000', 'A80AEA');
elseif ($nik['color'] == 6) $name = GradientLetter($name, '0000FF', '0ADFEC');
elseif ($nik['color'] == 7) $name = GradientLetter($name, 'FCD05B', 'E665F9');
elseif ($nik['color'] == 8) $name = GradientLetter($name, 'C3C3C3', '2020EF');
elseif ($nik['color'] == 9) $name = GradientLetter($name, '4ECF0F', 'FAB600');
elseif ($nik['color'] == 10) $name = GradientLetter($name, 'F3F016', '3A2FC8');
elseif ($nik['color'] == 11) $name = GradientLetter($name, 'E80A24', 'F9BB14');
elseif ($nik['color'] == 12) $name = GradientLetter($name, '46A6F7', '0AD90A');
elseif ($nik['color'] == 13) $name = GradientLetter($name, 'EA18F7', '000000');
$rot=mysql_fetch_array(mysql_query("SELECT `rotate`, `block` FROM `albums` WHERE `user`='$nik[id]' AND `type`='f' AND `path`='$nik[img]'"));
if ($rot[1]==1)
$Foto = '<img src="/views/default/img/no_avatar.gif" widht="35" height="35" alt="ava"/>';
else $Foto = '<img src="/resize.php?img='.$nik['img'].'&width=35&height=0&i='.$rot[0].'" alt="ava"/>';
$foto = (!empty($nik['img']))?$Foto:'<img src="/views/default/img/no_avatar.png" widht="35" height="35" alt="no ava"/>';
$Hours = floor(($nik['on_time'] / 3600));
if ($Hours >= 30) $med = ' <img src="/medals/b.gif" alt=""/>';
if ($Hours >= 90) $med = ' <img src="/medals/s.gif" alt=""/>';
if ($Hours >= 150) $med = ' <img src="/medals/g.gif" alt=""/>';
if ($Hours >= 300) $med = ' <img src="/medals/br.gif" alt=""/>';
$BirthEx = explode('.', $nik['birth']);
$Birth = ($BirthEx[0] . '.' . $BirthEx[1] == date('j.n')) ? ' <img src="/ico/sh.gif" alt=""/>' : '';
return '<a href="/'.$nik['id'].'">'.$name.'</a>';
}
else
{
return 'Удален';
}
}
function uus($ius)
{
global $user;
if (isset($ius)) $ius = intval($ius);
$result = mysql_query("SELECT `id`,`color`,`user`,`img`,`sex`,`date`,`birth`,`on_time` FROM `users` WHERE `id` = '$ius' LIMIT 1");
$nik = mysql_fetch_assoc($result);
if (!empty($nik['id']))
{
if ($nik['sex'] == 2) $_sex = 'М';
elseif ($nik['sex'] == 1) $_sex = 'Ж';
else $_sex = 'Не установлен';
$name = $nik['user'];
if ($nik['color'] == 1) $name = GradientLetter($name, '000000', 'FF0000');
elseif ($nik['color'] == 2) $name = GradientLetter($name, '000000', '00FF00');
elseif ($nik['color'] == 3) $name = GradientLetter($name, '000000', 'DDE4DA');
elseif ($nik['color'] == 4) $name = GradientLetter($name, '000000', '0000FF');
elseif ($nik['color'] == 5) $name = GradientLetter($name, 'FF0000', 'A80AEA');
elseif ($nik['color'] == 6) $name = GradientLetter($name, '0000FF', '0ADFEC');
elseif ($nik['color'] == 7) $name = GradientLetter($name, 'FCD05B', 'E665F9');
elseif ($nik['color'] == 8) $name = GradientLetter($name, 'C3C3C3', '2020EF');
elseif ($nik['color'] == 9) $name = GradientLetter($name, '4ECF0F', 'FAB600');
elseif ($nik['color'] == 10) $name = GradientLetter($name, 'F3F016', '3A2FC8');
elseif ($nik['color'] == 11) $name = GradientLetter($name, 'E80A24', 'F9BB14');
elseif ($nik['color'] == 12) $name = GradientLetter($name, '46A6F7', '0AD90A');
elseif ($nik['color'] == 13) $name = GradientLetter($name, 'EA18F7', '000000');
$rot=mysql_fetch_array(mysql_query("SELECT `rotate`, `block` FROM `albums` WHERE `user`='$nik[id]' AND `type`='f' AND `path`='$nik[img]'"));
if ($rot[1] == 1)
{
$Foto = '<img src="/views/default/img/no_avatar.gif" alt=""/>';
}
else
{
$Foto = '<img src="/resize.php?img='.$nik['img'].'&width=128&height=0&i='.$rot[0].'" width="35" height="35" alt="*"/>';
}
$foto = (!empty($nik['img']))?''.$Foto.'':'<img src="/views/default/img/no_avatar.png" widht="35" height="35" alt="no ava"/>';
return '<table><tr><td>'.$foto.'</td><td>';
}
else
{
return 'Удален';
}
}
function uuss($ius)
{
global $user;
if (isset($ius)) $ius = intval($ius);
$result = mysql_query("SELECT `id`,`color`,`user`,`img`,`sex`,`date`,`birth`,`on_time` FROM `users` WHERE `id` = '$ius' LIMIT 1");
$nik = mysql_fetch_assoc($result);
if (!empty($nik['id']))
{
if ($nik['sex'] == 2) $_sex = 'М';
elseif ($nik['sex'] == 1) $_sex = 'Ж';
else $_sex = 'Не установлен';
$name = $nik['user'];
if ($nik['color'] == 1) $name = GradientLetter($name, '000000', 'FF0000');
elseif ($nik['color'] == 2) $name = GradientLetter($name, '000000', '00FF00');
elseif ($nik['color'] == 3) $name = GradientLetter($name, '000000', 'DDE4DA');
elseif ($nik['color'] == 4) $name = GradientLetter($name, '000000', '0000FF');
elseif ($nik['color'] == 5) $name = GradientLetter($name, 'FF0000', 'A80AEA');
elseif ($nik['color'] == 6) $name = GradientLetter($name, '0000FF', '0ADFEC');
elseif ($nik['color'] == 7) $name = GradientLetter($name, 'FCD05B', 'E665F9');
elseif ($nik['color'] == 8) $name = GradientLetter($name, 'C3C3C3', '2020EF');
elseif ($nik['color'] == 9) $name = GradientLetter($name, '4ECF0F', 'FAB600');
elseif ($nik['color'] == 10) $name = GradientLetter($name, 'F3F016', '3A2FC8');
elseif ($nik['color'] == 11) $name = GradientLetter($name, 'E80A24', 'F9BB14');
elseif ($nik['color'] == 12) $name = GradientLetter($name, '46A6F7', '0AD90A');
elseif ($nik['color'] == 13) $name = GradientLetter($name, 'EA18F7', '000000');
$rot=mysql_fetch_array(mysql_query("SELECT `rotate`, `block` FROM `albums` WHERE `user`='$nik[id]' AND `type`='f' AND `path`='$nik[img]'"));
if ($rot[1] == 1)
{
$Foto = '<img src="/views/default/img/no_avatar.gif" alt=""/>';
}
else
{
$Foto = '<img src="/resize.php?img='.$nik['img'].'&width=128&height=0&i='.$rot[0].'" alt="*"/>';
}
$foto = (!empty($nik['img']))?''.$Foto.'':'<img src="/views/default/img/no_avatar.png" alt="no ava"/>';
return '<table><tr><td>'.$foto.'</td><td>';
}
else
{
return 'Удален';
}
}
function usss($ius)
{
global $user;
if (isset($ius)) $ius = intval($ius);
$result = mysql_query("SELECT `id`,`color`,`user`,`img`,`sex`,`date`,`birth`,`on_time` FROM `users` WHERE `id` = '$ius' LIMIT 1");
$nik = mysql_fetch_assoc($result);
if (!empty($nik['id']))
{
if ($nik['sex'] == 2) $_sex = 'М';
elseif ($nik['sex'] == 1) $_sex = 'Ж';
else $_sex = 'Не установлен';
$name = $nik['user'];
if ($nik['color'] == 1) $name = GradientLetter($name, '000000', 'FF0000');
elseif ($nik['color'] == 2) $name = GradientLetter($name, '000000', '00FF00');
elseif ($nik['color'] == 3) $name = GradientLetter($name, '000000', 'DDE4DA');
elseif ($nik['color'] == 4) $name = GradientLetter($name, '000000', '0000FF');
elseif ($nik['color'] == 5) $name = GradientLetter($name, 'FF0000', 'A80AEA');
elseif ($nik['color'] == 6) $name = GradientLetter($name, '0000FF', '0ADFEC');
elseif ($nik['color'] == 7) $name = GradientLetter($name, 'FCD05B', 'E665F9');
elseif ($nik['color'] == 8) $name = GradientLetter($name, 'C3C3C3', '2020EF');
elseif ($nik['color'] == 9) $name = GradientLetter($name, '4ECF0F', 'FAB600');
elseif ($nik['color'] == 10) $name = GradientLetter($name, 'F3F016', '3A2FC8');
elseif ($nik['color'] == 11) $name = GradientLetter($name, 'E80A24', 'F9BB14');
elseif ($nik['color'] == 12) $name = GradientLetter($name, '46A6F7', '0AD90A');
elseif ($nik['color'] == 13) $name = GradientLetter($name, 'EA18F7', '000000');
return ''.$name.'';
}
else
{
return 'Удален';
}
}
//-------------функции цветного ника-------------//
function cvetnik($ius)
{
global $user;
if (isset($ius)) $ius = intval($ius);
$result = mysql_query("SELECT `id`, `user`, `color` FROM `users` WHERE `id` = '$ius' LIMIT 1");
$nik = mysql_fetch_assoc($result);
if (!empty($nik['id'])) {
$name = $nik['user'];
if ($nik['color'] == 1) $name = GradientLetter($name, '000000', 'FF0000');
elseif ($nik['color'] == 2) $name = GradientLetter($name, '000000', '00FF00');
elseif ($nik['color'] == 3) $name = GradientLetter($name, '000000', 'DDE4DA');
elseif ($nik['color'] == 4) $name = GradientLetter($name, '000000', '0000FF');
elseif ($nik['color'] == 5) $name = GradientLetter($name, 'FF0000', 'A80AEA');
elseif ($nik['color'] == 6) $name = GradientLetter($name, '0000FF', '0ADFEC');
elseif ($nik['color'] == 7) $name = GradientLetter($name, 'FCD05B', 'E665F9');
elseif ($nik['color'] == 8) $name = GradientLetter($name, 'C3C3C3', '2020EF');
elseif ($nik['color'] == 9) $name = GradientLetter($name, '4ECF0F', 'FAB600');
elseif ($nik['color'] == 10) $name = GradientLetter($name, 'F3F016', '3A2FC8');
elseif ($nik['color'] == 11) $name = GradientLetter($name, 'E80A24', 'F9BB14');
elseif ($nik['color'] == 12) $name = GradientLetter($name, '46A6F7', '0AD90A');
elseif ($nik['color'] == 13) $name = GradientLetter($name, 'EA18F7', '000000');
return $name;
} else {
return 'Удален';
}
}
//-------------функции зодиака-------------//
function zodiak($birth)
{
$birth = explode('.', $birth);
$d = $birth[0];
$m = $birth[1];
$g = $birth[2];
if ($d != NULL and $m != NULL and $g != NULL) {
if ($m == 1);
elseif ($m == 2);
elseif ($m == 3);
elseif ($m == 4);
elseif ($m == 5);
elseif ($m == 6);
elseif ($m == 7);
elseif ($m == 8);
elseif ($m == 9);
elseif ($m == 10);
elseif ($m == 11);
elseif ($m == 12);
$birth = date('Y') - $g;
if (date('n') < $m) $birth = $birth-1;
elseif (date('n') == $m and date('j') < $d) $birth = $birth-1;
if (($d >= 20) and ($m == 3)) {
$znak = 'Овен';
}
elseif (($d <= 20) and ($m == 4)) {
$znak = 'Овен';
}
if (($d >= 20) and ($m == 4)) {
$znak = 'Телец';
}
elseif (($d <= 21) and ($m == 5)) {
$znak = 'Телец';
}
if (($d >= 21) and ($m == 5)) {
$znak = 'Близнецы';
}
elseif (($d <= 21) and ($m == 6)) {
$znak = 'Близнецы';
}
if (($d >= 21) and ($m == 6)) {
$znak = 'Рак';
}
elseif (($d <= 22) and ($m == 7)) {
$znak = 'Рак';
}
if (($d >= 22) and ($m == 7)) {
$znak = 'Лев';
}
elseif (($d <= 22) and ($m == 8)) {
$znak = 'Лев';
}
if (($d >= 23) and ($m == 8)) {
$znak = 'Дева';
}
elseif (($d <= 20) and ($m == 9)) {
$znak = 'Дева';
}
if (($d >= 23) and ($m == 9)) {
$znak = 'Весы';
}
elseif (($d <= 23) and ($m == 10)) {
$znak = 'Весы';
}
if (($d >= 24) and ($m == 10)) {
$znak = 'Скорпион';
}
elseif (($d <= 22) and ($m == 11)) {
$znak = 'Скорпион';
}
if (($d >= 23) and ($m == 11)) {
$znak = 'Стрелец';
}
elseif (($d <= 21) and ($m == 12)) {
$znak = 'Стрелец';
}
if (($d >= 22) and ($m == 12)) {
$znak = 'Козерог';
}
elseif (($d <= 20) and ($m == 1)) {
$znak = 'Козерог';
}
if (($d >= 21) and ($m == 1)) {
$znak = 'Водолей';
}
elseif (($d <= 18) and ($m == 2)) {
$znak = 'Водолей';
}
if (($d >= 19) and ($m == 2)) {
$znak = 'Рыбы';
}
elseif (($d <= 20) and ($m == 3)) {
$znak = 'Рыбы';
}
return $znak;
}
}
//-------------функции онлайна юзера-------------//
function online_user($ius)
{
if (isset($ius)) $ius = intval($ius);
$result = mysql_query("SELECT `id`, `onl` FROM `users` WHERE `id` = '$ius' LIMIT 1");
$nik = mysql_fetch_assoc($result);
if (!empty($nik['id']) && $nik['onl'] + 300 > time()) {
return $ius;
}
}
//-------------функция фильтра букв-------------//
function my_check($var)
{
$var = trim($var);
$var = htmlspecialchars($var, ENT_QUOTES, 'UTF-8');
$var = nl2br($var);
$var = strtr($var, array(
chr(0)=> '',
chr(1)=> '',
chr(2)=> '',
chr(3)=> '',
chr(4)=> '',
chr(5)=> '',
chr(6)=> '',
chr(7)=> '',
chr(8)=> '',
chr(9)=> '',
chr(10)=> '',
chr(11)=> '',
chr(12)=> '',
chr(13)=> '',
chr(14)=> '',
chr(15)=> '',
chr(16)=> '',
chr(17)=> '',
chr(18)=> '',
chr(19)=> '',
chr(20)=> '',
chr(21)=> '',
chr(22)=> '',
chr(23)=> '',
chr(24)=> '',
chr(25)=> '',
chr(26)=> '',
chr(27)=> '',
chr(28)=> '',
chr(29)=> '',
chr(30)=> '',
chr(31)=> ''
));
$var = str_replace(" 0", "", $var);
$var = str_replace('\', '\', $var);
$var = str_replace(''', ''', $var);
$var = str_replace('$', '$$', $var);
$var = addcslashes($var, '_%');
$var = iconv('utf-8', 'windows-1251', $var);
$var = iconv('windows-1251', 'utf-8', $var);
return $var;
}
//------------функция фильтра цифр-------------//
function my_int($var)
{
return abs($var);
}
//-------------функция смайлов-------------//
function smiles($str)
{
$querysmiles = mysql_query("SELECT `name`, `path` FROM `smiles`");
while($arrsmiles = mysql_fetch_assoc($querysmiles))
{
$str = str_replace($arrsmiles['name'], '<img src="/' . $arrsmiles['path'] . '" alt="'.$arrsmiles['name'].'"/>', $str);
}
return $str;
}
//-------------функция возраста-------------//
function calc_age($data)
{
$ex_age = explode('.', $data);
$age = date('Y') - $ex_age[2];
if (date('m') < $ex_age[1] || (date('m') == $ex_age[1] && date('d') < $ex_age[0])) {
$age--;
}
$q1 = abs($age) % 100;
$q2 = $age % 10;
if ($q1 > 10 && $q1 < 20) {
$result = 'лет';
} elseif ($q2 > 1 && $q2 < 5) {
$result = 'года';
} elseif ($q2 == 1) {
$result = 'год';
} else {
$result = 'лет';
}
$age = (int)$age;
if ($age == date('Y')) $age = 0;
return $age . ' ' . $result;
}
//-------------функция игнора-------------//
function ignor($f1 = NULL, $f2 = NULL, $w = NULL)
{
if (isset($f1)) $f1 = my_check($f1);
if (isset($f2)) $f2 = my_check($f2);
if (isset($w)) $w = my_check($w);
$f = mysql_fetch_assoc(mysql_query("SELECT id FROM `ignor` WHERE `user_id` = '$f1' AND `ig_id` = '$f2'"));
if ($w == NULL) {
if ($f1 != $f2) {
if (isset($f['id'])) return 1;
else return 0;
} else {
return 0;
}
} else {
if (isset($f['id'])) return $f[$w];
}
}
//-------------функция инфы о юзере-------------//
function user_inf($ref = NULL, $w = NULL)
{
if (isset($ref)) $ref = my_check($ref);
if (!ctype_digit($ref))
{
$lowuser = mb_strtolower($ref, 'UTF8');
$result = mysql_query("SELECT * FROM `users` WHERE `latuser` = '$lowuser' LIMIT 1");
} elseif (ctype_digit($ref)) {
$ref = my_int($ref);
$result = mysql_query("SELECT * FROM `users` WHERE `id` = '$ref' LIMIT 1");
}
$nik = mysql_fetch_array($result);
if ($w == NULL) return $nik['id'];
else return $nik[$w];
}
//-------------функция записи онлайна-------------//
function whorm($rm = 0, $room = NULL)
{
global $user, $ipl, $agent, $ontime, $onsite;
if (!empty($_SESSION['us'])) {
$agent = my_check($agent);
mysql_query("UPDATE `users` SET
`onl` = '" . time() . "',
`visit` = '" . date('d/m/y H:i') . "',
`user_ip` = '$ipl',
`user_soft` = '$agent',
`room` = '$room'
WHERE `id` = '$user[id]' LIMIT 1");
// запись времени онлайна
$ontime = $user['on_time'];
if ($user['onl'] > (time() - 300)) {
$onsite = $ontime + time() - $user['onl'];
mysql_query("UPDATE `users` SET `on_time` = '$onsite' WHERE `id` = '$user[id]' LIMIT 1");
}
}
}
//-------------функция временного бана-------------//
function kikt($t)
{
$t2 = $t - time();
if ($t2 > (60 * 60 * 24 * 30)) $t3 = round($t2 / (60 * 60 * 24 * 30)) . ' месяцев';
elseif ($t2 > (60 * 60 * 24)) $t3 = round($t2 / (60 * 60 * 24)) . ' дней';
elseif ($t2 > (60 * 60)) $t3 = round($t2 / (60 * 60)) . ' часов';
elseif ($t2 > 60) $t3 = round($t2 / 60) . ' минут';
else $t3 = $t2 . ' секунд';
return $t3;
}
//-------------функция вывода сообщений-------------//
function msg($msg)
{
echo '<div class="msg_notice">' . $msg . '</div>';
}
function err($msg)
{
echo '<div class="msg_error">' . $msg . '</div>';
}
//-------------функция транслита-------------//
function rus_to_k($str)
{
$str = str_replace("а","a",$str);
$str = str_replace("б","b",$str);
$str = str_replace("в","v",$str);
$str = str_replace("г","g",$str);
$str = str_replace("д","d",$str);
$str = str_replace("е","e",$str);
$str = str_replace("ё","e",$str);
$str = str_replace("ж","j",$str);
$str = str_replace("з","z",$str);
$str = str_replace("и","i",$str);
$str = str_replace("й","y",$str);
$str = str_replace("к","k",$str);
$str = str_replace("л","l",$str);
$str = str_replace("м","m",$str);
$str = str_replace("н","n",$str);
$str = str_replace("о","o",$str);
$str = str_replace("п","p",$str);
$str = str_replace("р","r",$str);
$str = str_replace("с","s",$str);
$str = str_replace("т","t",$str);
$str = str_replace("у","u",$str);
$str = str_replace("ф","f",$str);
$str = str_replace("х","h",$str);
$str = str_replace("ч","c",$str);
$str = str_replace("ц","q",$str);
$str = str_replace("ш","w",$str);
$str = str_replace("щ",">",$str);
$str = str_replace("ь","<",$str);
$str = str_replace("ы","x",$str);
$str = str_replace("ъ",".",$str);
$str = str_replace("э",":",$str);
$str = str_replace("ю",";",$str);
$str = str_replace("я","}",$str);
$str = str_replace("А","a",$str);
$str = str_replace("Б","b",$str);
$str = str_replace("В","v",$str);
$str = str_replace("Г","g",$str);
$str = str_replace("Д","d",$str);
$str = str_replace("Е","e",$str);
$str = str_replace("Ё","e",$str);
$str = str_replace("Ж","j",$str);
$str = str_replace("З","z",$str);
$str = str_replace("И","i",$str);
$str = str_replace("Й","y",$str);
$str = str_replace("К","k",$str);
$str = str_replace("Л","l",$str);
$str = str_replace("М","m",$str);
$str = str_replace("Н","n",$str);
$str = str_replace("О","o",$str);
$str = str_replace("П","p",$str);
$str = str_replace("Р","r",$str);
$str = str_replace("С","s",$str);
$str = str_replace("Т","t",$str);
$str = str_replace("У","u",$str);
$str = str_replace("Ф","f",$str);
$str = str_replace("Х","h",$str);
$str = str_replace("Ч","c",$str);
$str = str_replace("Ц","q",$str);
$str = str_replace("Ш","w",$str);
$str = str_replace("Щ",">",$str);
$str = str_replace("Ь","<",$str);
$str = str_replace("Ы","x",$str);
$str = str_replace("Ъ",".",$str);
$str = str_replace("Э",":",$str);
$str = str_replace("Ю",";",$str);
$str = str_replace("Я","}",$str);
return $str;
}
// ----------------------- Функция определения кодировки ------------------------//
function is_utf($str)
{
$c = 0;
$b = 0;
$bits = 0;
$len = strlen($str);
for($i = 0; $i < $len; $i++)
{
$c = ord($str[$i]);
if ($c > 128) {
if (($c >= 254)) return false;
elseif ($c >= 252) $bits = 6;
elseif ($c >= 248) $bits = 5;
elseif ($c >= 240) $bits = 4;
elseif ($c >= 224) $bits = 3;
elseif ($c >= 192) $bits = 2;
else return false;
if (($i + $bits) > $len) return false;
while ($bits > 1) {
$i++;
$b = ord($str[$i]);
if ($b < 128 || $b > 191) return false;
$bits--;
}
}
}
return true;
}
// ----------------------- Функция отправки письма по e-mail ------------------------//
function addmail($usermail, $subject, $msg, $mail = '', $name = '')
{
global $config;
if ($mail == '') {
$mail = $config['emails'];
$name = $config['nickname'];
}
$subject = utf_to_win($subject);
$msg = utf_to_win($msg);
$name = utf_to_win($name);
$subject = convert_cyr_string($subject, 'w', 'k');
$msg = convert_cyr_string($msg, 'w', 'k');
$name = convert_cyr_string($name, 'w', 'k');
$subject = '=?KOI8-R?B?' . base64_encode($subject) . '?=';
$adds = "From: " . $name . " <" . $mail . ">n";
$adds .= "X-sender: " . $name . " <" . $mail . ">n";
$adds .= "Content-Type: text/plain; charset=koi8-rn";
$adds .= "MIME-Version: 1.0n";
$adds .= "Content-Transfer-Encoding: 8bitn";
$adds .= "X-Mailer: PHP v." . phpversion();
return mail($usermail, $subject, $msg, $adds);
}
//-------------функция перекодировки из вин в утф-------------//
function win_to_utf($str)
{
if (function_exists('mb_convert_encoding')) return mb_convert_encoding($str, 'utf-8', 'windows-1251');
if (function_exists('iconv')) return iconv('windows-1251', 'utf-8', $str);
$win1251utf8 = array(
"xC0"=>"А","xC1"=>"Б","xC2"=>"В","xC3"=>"Г","xC4"=>"Д","xC5"=>"Е","xA8"=>"Ё","xC6"=>"Ж","xC7"=>"З","xC8"=>"И","xC9"=>"Й","xCA"=>"К","xCB"=>"Л","xCC"=>"М",
"xCD"=>"Н","xCE"=>"О","xCF"=>"П","xD0"=>"Р","xD1"=>"С","xD2"=>"Т","xD3"=>"У","xD4"=>"Ф","xD5"=>"Х","xD6"=>"Ц","xD7"=>"Ч","xD8"=>"Ш","xD9"=>"Щ","xDA"=>"Ъ",
"xDB"=>"Ы","xDC"=>"Ь","xDD"=>"Э","xDE"=>"Ю","xDF"=>"Я","xE0"=>"а","xE1"=>"б","xE2"=>"в","xE3"=>"г","xE4"=>"д","xE5"=>"е","xB8"=>"ё","xE6"=>"ж","xE7"=>"з",
"xE8"=>"и","xE9"=>"й","xEA"=>"к","xEB"=>"л","xEC"=>"м","xED"=>"н","xEE"=>"о","xEF"=>"п","xF0"=>"р","xF1"=>"с","xF2"=>"т","xF3"=>"у","xF4"=>"ф","xF5"=>"х",
"xF6"=>"ц","xF7"=>"ч","xF8"=>"ш","xF9"=>"щ","xFA"=>"ъ","xFB"=>"ы","xFC"=>"ь","xFD"=>"э","xFE"=>"ю","xFF"=>"я");
return strtr($str, $win1251utf8);
}
//-------------функция перекодировки из утф в вин-------------//
function utf_to_win($str)
{
if (function_exists('mb_convert_encoding')) return mb_convert_encoding($str, 'windows-1251', 'utf-8');
if (function_exists('iconv')) return iconv('utf-8', 'windows-1251', $str);
$utf8win1251 = array(
"А"=>"xC0","Б"=>"xC1","В"=>"xC2","Г"=>"xC3","Д"=>"xC4","Е"=>"xC5","Ё"=>"xA8","Ж"=>"xC6","З"=>"xC7","И"=>"xC8","Й"=>"xC9","К"=>"xCA","Л"=>"xCB","М"=>"xCC",
"Н"=>"xCD","О"=>"xCE","П"=>"xCF","Р"=>"xD0","С"=>"xD1","Т"=>"xD2","У"=>"xD3","Ф"=>"xD4","Х"=>"xD5","Ц"=>"xD6","Ч"=>"xD7","Ш"=>"xD8","Щ"=>"xD9","Ъ"=>"xDA",
"Ы"=>"xDB","Ь"=>"xDC","Э"=>"xDD","Ю"=>"xDE","Я"=>"xDF","а"=>"xE0","б"=>"xE1","в"=>"xE2","г"=>"xE3","д"=>"xE4","е"=>"xE5","ё"=>"xB8","ж"=>"xE6","з"=>"xE7",
"и"=>"xE8","й"=>"xE9","к"=>"xEA","л"=>"xEB","м"=>"xEC","н"=>"xED","о"=>"xEE","п"=>"xEF","р"=>"xF0","с"=>"xF1","т"=>"xF2","у"=>"xF3","ф"=>"xF4","х"=>"xF5",
"ц"=>"xF6","ч"=>"xF7","ш"=>"xF8","щ"=>"xF9","ъ"=>"xFA","ы"=>"xFB","ь"=>"xFC","э"=>"xFD","ю"=>"xFE","я"=>"xFF");
return strtr($str, $utf8win1251);
}
//-------------функция запрета копирования текста-------------//
function nonCopy($var)
{
return $var = '<script language="JavaScript">
document.onselectstart=function()
{
return false
}
document.oncontextmenu=function()
{
return false
}
document.onmousedown=function()
{
return false
}
</script>' . win_to_utf($var);
}
//-------------функция транслита-------------//
function trun_to_rus($str)
{
$translate = array
(
'YO' => 'Ё', 'Yo' => 'Ё', 'yo' => 'ё', 'ZH' => 'Ж',
'Zh' => 'Ж', 'zh' => 'ж', 'CH' => 'Ч', 'Ch' => 'Ч',
'ch' => 'ч', 'SH' => 'Ш', 'Sh' => 'Ш', 'sh' => 'ш',
'SHC' => 'Щ', 'Shc' => 'Щ', 'shc' => 'щ', 'QQ' => 'Ъ',
'qq' => 'ъ', 'YE' => 'Э', 'Ye' => 'Э', 'ye' => 'э',
'YU' => 'Ю', 'Yu' => 'Ю', 'yu' => 'ю', 'YA' => 'Я',
'Ya' => 'Я', 'ya' => 'я', 'YI' => 'Ы', 'Yi' => 'Ы',
'yi' => 'ы', 'A' => 'А', 'a' => 'а', 'B' => 'Б',
'b' => 'б', 'C' => 'Ц', 'c' => 'ц', 'D' => 'Д',
'd' => 'д', 'E' => 'Е', 'e' => 'е', 'F' => 'Ф',
'f' => 'ф', 'G' => 'Г', 'g' => 'г', 'H' => 'Х',
'h' => 'х', 'X' => 'Х', 'x' => 'х', 'I' => 'И',
'i' => 'и', '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' => 'ш', 'J' => 'Й',
'j' => 'й', 'Z' => 'З', 'z' => 'з'
);
preg_match_all('/#([^[]+)#/U', $str, $a);
$str = strtr($str, $translate);
preg_match_all('/#([^[]+)#/U', $str, $b);
$str = str_replace(array_values($b[0]), array_values($a[1]), $str);
return $str;
}
//-------------функция ретранлсита-------------//
function retranslit($in)
{
$trans1 = array("'",'`',',',' ',"Ё","Ж","Ч","Ш","Щ","Э","Ю","Я","ё","ж","ч","ш","щ","э","ю","я","А","Б","В","Г","Д","Е","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ц","Ь","Ы","а","б","в","г","д","е","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ь","ы");
$trans2 = array('_','_','_','_',"JO","ZH","CH","SH","SCH","Je","Jy","Ja","jo","zh","ch","sh","sch","je","jy","ja","A","B","V","G","D","E","Z","I","J","K","L","M","N","O","P","R","S","T","U","F","H","C","","Y","a","b","v","g","d","e","z","i","j","k","l","m","n","o","p","r","s","t","u","f","h","c","","y");
return str_replace($trans1, $trans2, $in);
}
//-------------функция экранирования и замены спецсимволов-------------//
function check($message)
{
$message = nl2br(htmlspecialchars($message, ENT_QUOTES, 'UTF-8'));
$message = strtr($message, array(
chr(0)=> '',
chr(1)=> '',
chr(2)=> '',
chr(3)=> '',
chr(4)=> '',
chr(5)=> '',
chr(6)=> '',
chr(7)=> '',
chr(8)=> '',
chr(9)=> '',
chr(10)=> '',
chr(11)=> '',
chr(12)=> '',
chr(13)=> '',
chr(14)=> '',
chr(15)=> '',
chr(16)=> '',
chr(17)=> '',
chr(18)=> '',
chr(19)=> '',
chr(20)=> '',
chr(21)=> '',
chr(22)=> '',
chr(23)=> '',
chr(24)=> '',
chr(25)=> '',
chr(26)=> '',
chr(27)=> '',
chr(28)=> '',
chr(29)=> '',
chr(30)=> '',
chr(31)=> ''
));
$message = str_replace("'", "'", $message);
$message = str_replace('\', "\", $message);
$message = str_replace("|", "I", $message);
$message = str_replace("||", "I", $message);
$message = str_replace("/\$/", "$", $message);
$message = stripslashes($message);
$message = iconv('utf-8', 'windows-1251', $message);
$message = iconv('windows-1251', 'utf-8', $message);
return $message;
}
//-------------функция замены рус букв-------------//
function replace_rus($str)
{
$str = str_replace("а","|",$str);
$str = str_replace("б","|",$str);
$str = str_replace("в","|",$str);
$str = str_replace("г","|",$str);
$str = str_replace("д","|",$str);
$str = str_replace("е","|",$str);
$str = str_replace("ё","|",$str);
$str = str_replace("ж","|",$str);
$str = str_replace("з","|",$str);
$str = str_replace("и","|",$str);
$str = str_replace("й","|",$str);
$str = str_replace("к","|",$str);
$str = str_replace("л","|",$str);
$str = str_replace("м","|",$str);
$str = str_replace("н","|",$str);
$str = str_replace("о","|",$str);
$str = str_replace("п","|",$str);
$str = str_replace("р","|",$str);
$str = str_replace("с","|",$str);
$str = str_replace("т","|",$str);
$str = str_replace("у","|",$str);
$str = str_replace("ф","|",$str);
$str = str_replace("х","|",$str);
$str = str_replace("ч","|",$str);
$str = str_replace("ц","|",$str);
$str = str_replace("ш","|",$str);
$str = str_replace("щ","|",$str);
$str = str_replace("ь","|",$str);
$str = str_replace("ы","|",$str);
$str = str_replace("ъ","|",$str);
$str = str_replace("э","|",$str);
$str = str_replace("ю","|",$str);
$str = str_replace("я","|",$str);
$str = str_replace("А","|",$str);
$str = str_replace("Б","|",$str);
$str = str_replace("В","|",$str);
$str = str_replace("Г","|",$str);
$str = str_replace("Д","|",$str);
$str = str_replace("Е","|",$str);
$str = str_replace("Ё","|",$str);
$str = str_replace("Ж","|",$str);
$str = str_replace("З","|",$str);
$str = str_replace("?","|",$str);
$str = str_replace("Й","|",$str);
$str = str_replace("К","|",$str);
$str = str_replace("Л","|",$str);
$str = str_replace("М","|",$str);
$str = str_replace("Н","|",$str);
$str = str_replace("О","|",$str);
$str = str_replace("П","|",$str);
$str = str_replace("Р","|",$str);
$str = str_replace("С","|",$str);
$str = str_replace("Т","|",$str);
$str = str_replace("У","|",$str);
$str = str_replace("Ф","|",$str);
$str = str_replace("Х","|",$str);
$str = str_replace("Ч","|",$str);
$str = str_replace("Ц","|",$str);
$str = str_replace("Ш","|",$str);
$str = str_replace("Щ","|",$str);
$str = str_replace("Ь","|",$str);
$str = str_replace("Ы","|",$str);
$str = str_replace("Ъ","|",$str);
$str = str_replace("Э","|",$str);
$str = str_replace("Ю","|",$str);
$str = str_replace("Я","|",$str);
return $str;
}
//-------------Сжатие начало-------------//
if (extension_loaded('zlib') and ini_get('zlib.output_compression') != 1 and ini_get('output_handler') != 'ob_gzhandler')
{
$PREFER_DEFLATE = false;
$FORCE_COMPRESSION = false;
function compress_output_gzip($output)
{
return gzencode($output);
}
function compress_output_deflate($output)
{
return gzdeflate($output, 9);
}
function compress_output_x_gzip($output)
{
return gzcompress($output, 9);
}
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
$AE = $_SERVER['HTTP_ACCEPT_ENCODING'];
else
$AE = $_SERVER['HTTP_TE'];
$support_gzip = (strpos($AE, 'gzip') !== FALSE) || $FORCE_COMPRESSION;
$support_deflate = (strpos($AE, 'deflate') !== FALSE) || $FORCE_COMPRESSION;
$support_x_gzip = (strpos($AE, 'x-gzip') !== FALSE) || $FORCE_COMPRESSION;
if ($support_gzip && $support_deflate)
{
$support_deflate = $PREFER_DEFLATE;
}
if ($support_deflate)
{
header("Content-Encoding: deflate");
ob_start("compress_output_deflate");
}
else
{
if ($support_gzip)
{
header("Content-Encoding: gzip");
ob_start("compress_output_gzip");
}
else
{
if ($support_x_gzip)
{
header("Content-Encoding: x_gzip");
ob_start("compress_output_x_gzip");
}
else
{
ob_start();
$config_gzip = 0;
}
}
}
}
else
{
$config_gzip = 0;
}
// Сжатие конец
function url($url)
{
$url2=preg_split('#&(amp;)?#', $url);
$url3=NULL;
for ($i=0;$i<count($url2);$i++)
{
$url4=explode('=', $url2[$i]);
if (isset($url4[1]))
$url3.=$url4[0].'='.urlencode($url4[1]);
else $url3.=$url4[0];
if ($i<count($url2)-1)$url3.='&';
}
return $url3;
}
function url2($url)
{
$url2=explode('/', $url);
for ($i=0;$i<sizeof($url2);$i++)
{
$url2[$i]=urlencode($url2[$i]);
}
return implode('/',$url2);
}
$div_title = '<div class="title">';
$div_menu = '<div class="menu">';
$div_end = '</div>';
?>