<?php 

function trun_to_rus( $str )
{
$str = strtolower( $str );
$str = str_replace( "ch", "ч", $str );
$str = str_replace( "sc", "щ", $str );
$str = str_replace( "&#8216;&#8216;", "ъ", $str );
$str = str_replace( "ye", "э", $str );
$str = str_replace( "yu", "ю", $str );
$str = str_replace( "ya", "я", $str );
$str = str_replace( "yi", "ы", $str );
$str = str_replace( "yo", "ё", $str );
$str = str_replace( "sh", "ш", $str );
$str = strtr( $str, array( "a" => "а", "b" => "б", "v" => "в", "g" => "г", "d" => "д", "e" => "е", "j" => "ж", "z" => "з", "i" => "и", "y" => "й", "k" => "к", "l" => "л", "m" => "м", "n" => "н", "o" => "о", "p" => "п", "r" => "р", "s" => "с", "t" => "т", "u" => "у", "f" => "ф", "h" => "х", "c" => "ц", "w" => "ш", "x" => "ы", "'" => "ь" ) );
return $str;
}
require( "inc/conf.inc.php" );
require( "inc/check.php" );
require( "license/license.php" );
$login = autorize();
if ( $lclose < time( ) )
{
echo "<title>ATTENTION!! ATTENTION EWERY ONE</title>";
echo "<style type=\"text/css\">";
echo "body { font-size: x-small; color: #00FF00; background-color: #000000; text-align: center }";
echo "a:link,a:visited { text-decoration: underline; color: #00FFFF }";
echo "div { color: #000000; background-color: #FFFF00 }";
echo "</style></head><body>";
echo "<div><b>Внимание!</b></div>";
echo "Срок данного продукта<br/>";
echo "истек <b>".date( "d-m-y", $lclose )."</b>!<br/>";
echo "По вопросам продления срока обращайтесь:<br/>";
echo "***<br/><b><u>olegarhi75@mail.ru<br/>";
echo "или<br/>";
echo "waufon@waufon.ru</u></b><br/>";
echo "<br/><a href=\"http://waufon.ru\">waufon.ru</a><br/><br/>";
echo "<div><b>&copy; КОТ</b></div>";echo "<p>{$ip}</p>";
echo "</body></html>";
exit( );
}
$rm = intval( $rm );
if ( $rm < 0 || 11 < $rm || !isset( $rm ) )
{
$rm = 9;
}
$prizrak = $row['prizrak'];
$room = "room".$rm;
$login = $row['login'];
$ncol = $row['ncol'];
$avator = $row['avator'];
$ltime = $row['ltime'];
$offline = $ltime + 1200;
$shrift = $row['shrift'];
////////Девушке///////////
if($sex=="2")
{
if ( $offline < time( ) )
{
$time = time( );
$helo = "Привет чатлане.<img src=\"http://waufon.gif/sm/privet.gif\" alt=\".\"/>  :)";
mysql_query( "Insert into mess set id=0, login='<b><u>{$login}</u></b>', msg='".$helo."', id_from='".$row['id']."', id_to='0', wtime='".$time."',room='all'" );
}
}
////////парню///////////
if($sex=="1")
{
if ( $offline < time( ) )
{
$time = time( );
$helo = "Привет <img src=\"http://waufon.gif/sm/bebe.gif\" alt=\".\"/>  :)";
mysql_query( "Insert into mess set id=0, login='<b><u>{$login}</u></b>', msg='".$helo."', id_from='".$row['id']."', id_to='0', wtime='".$time."',room='all'" );
}
}
////////неизвесному///////////
if($sex=="0")
{
if ( $offline < time( ) )
{
$time = time( );
$helo = "Привет <img src=\"http://waufon.gif/sm/figa.gif\" alt=\".\"/>  :)";
mysql_query( "Insert into mess set id=0, login='<b><u>{$login}</u></b>', msg='".$helo."', id_from='".$row['id']."', id_to='0', wtime='".$time."',room='all'" );
}
}
////////////КОНЕЦ БОТ НЕО/////////////
mysql_query( "update users set ltime='".time( )."', lroom='".$rm."' where id='{$id}';" );
$level = $row['level'];
$ncol = $row['ncol'];
$smile = $row['smile'];
$posts = $row['posts'];
$avr = $row['time_update'];
$max = $row['num_msgs'];
$pwd = $row['pwd'];
if ( empty( $max ) )
{
$max = 5;
}
if ( empty( $avr ) )
{
$avr = 300;
}
if ( time( ) < $row['kick'] && $rm != 9 )
{
$tleft = $row['kick'] - time( );
$whokik = $row['whokick'];
$whykik = $row['whykick'];
echo "<title>KICK!</title>";
echo "<style type=\"text/css\">";
echo "body { margin: auto; max-width: 500px; font: 12px Arial; color: #808080; background-color: #000000; }";
echo "a:link,a:visited { text-decoration: none; color: b0c4db; }";
echo "div { background-color: #202020; border-style:solid; border-width: 1px; }";
echo "img { vertical-align: middle; }";
echo "</style></head><body>";
echo "<div class=\"bc\">";
echo "<div class=\"cd\"><b>&nbsp; ОБЛОМ!!! Вход закрыт !</b></div>";
echo "<div align=\"center\"><img alt=\"...\" src=\"/img/red.gif\"><br/>";
echo "Вас выпнули за нарушение правил чата!";
echo "</div><br/>";
echo "<b>Кто:</b>\r{$whokik}<br/>";
echo "<b>За что:</b>\r{$whykik}<br/>";
echo "<b>Разбан через</b> {$tleft} <b>сек</b><br/><br/>";
echo "<div align=\"center\">";
echo "<a class=\"bc\" href=\"enter.php?id={$id}&amp;pass={$pass}\">&nbsp; Ok &nbsp;</a><br/><br/>";
echo "</div></div></body></html>";
$end = gettime( );
echo "<p align=\"center\">\r\n[".round( $end - $mystart, 5 )."]\r\n</p></body></html>";
mysql_close( $link );
exit( );
}
$qsetts = @mysql_query( @"select `name` from `setts` where var='".$rm."';" );
$setts = @mysql_fetch_array( @$qsetts );
$title = $setts['name'];
$q1 = mysql_query( "select id from letters where id_to='{$id}' and new=1 and del_in=0;" );
$mylet = mysql_num_rows( $q1 );
///МЕСС////КОНЕЦ////
require( "inc/tape.php" );
##### удалить пост пытаюсь зделать ######
if ( isset( $_GET['mid'] ) && 6 < $level )
{
$mid = intval( $_GET['mid'] );
@mysql_query( @"delete from mess where id='".$mid."' limit 1;" );
}
###### конец формы удалить пост #####*/
############# РАБОТАЮЩИЙ КОД ######################
if ( $row['priv'] == 1 ) 
{
{ $q_msg = "select * from mess where room='{$room}' OR room = 'all' order by id desc limit {$max}"; } 
}
else
{
$q_msg = "select * from mess where (room='{$room}' OR room = 'all') AND (id_to='0' OR id_to='{$id}' OR id_from='{$id}') order by id desc limit {$max}";
}
//}
##################################*/
if ( $rm == 10 )
{
///\\\\
$res = mysql_query( "select * from intim where pwd='{$pwd}' AND (id_to='0' OR id_to='{$id}' OR id_from='{$id}')  order by id desc limit {$max}" );
$q_msg = "select * from intim where pwd='{$pwd}' AND (id_to='0' OR id_to='{$id}' OR id_from='{$id}') order by id desc limit {$max}";
}
else
///\\\\
{
///\\\\
$res = mysql_query( "select * from mess where  (room='{$room}' OR room = 'all') AND (id_to='0' OR id_to='{$id}' OR id_from='{$id}')  order by id desc limit {$max}" );
$res = mysql_query( $q_msg );
///\\\\
}
$time = date( "H:i" );
echo "<title>-={$time}=-</title>";
echo "<link rel=\"shortcut icon\" href=\"favicon.ico\">";
echo "<meta http-equiv=\"refresh\" content=\"{$avr}\">";
echo "<style type=\"text/css\">";
echo "body { margin: auto; max-width: 500px; font: 12px Arial; color: #808080; background-color: #000000; }";
echo "a:link,a:visited { text-decoration: none; color: b0c4db; }";
echo "div { background-color: #202020; border-style:solid; border-width: 1px; }";
echo "img { vertical-align: middle; }";
echo "</style>";
echo "</head>";
echo "<body>\n";

if ( $rm == 11 )
{
$q_count = @mysql_query( @"SELECT count(*) FROM `users` WHERE `pwd`='".$pwd."' AND `ltime`>'".@intval( @time( ) - 300 ).@"' AND `lroom`='{$rm}';" );
}
else
{
$q_count = @mysql_query( @"SELECT count(*) FROM `users` WHERE `ltime`>'".@intval( @time( ) - 300 ).@"' AND `lroom`='{$rm}';" );
}
$dcount = @mysql_fetch_array( @$q_count );
echo "<p align=\"center\"><b><u>{$title}</u></b>\r";
echo "(<a href=\"here.php?id={$id}&amp;pass={$pass}&amp;rm={$rm}&amp;ref={$ref}\">".$dcount['count(*)']."</a>)";
if ( 0 < $mylet )
{
print "<br/><a href=\"mail/?id={$id}&amp;pass={$pass}&amp;mod=in\"><img src=\"let.gif\" alt=\"Letter\"/></a>";
}
/////
$q2 = mysql_query( "select id from zags where id_to='{$id}' and new=1 and del_in=0;" );
if ( mysql_num_rows( $q2 ) )
{
echo "<br/><a href=\"zags/?id={$id}&amp;pass={$pass}&amp;mod=in\"><img src=\"zags.gif\" alt=\"Letter\"/></a>";
}
///----=====----////

echo "</p><div>";
echo "<a href=\"room.php?id={$id}&amp;pass={$pass}&amp;rm={$rm}&amp;ref={$ref}\">Обновить</a><br/>";
echo "<a href=\"say.php?id={$id}&amp;pass={$pass}&amp;rm={$rm}&amp;ref={$ref}\">Сказать</a></div>";
////////////////////////////////////////////////////
if ( $rm == 0 ){echo "<div><a href=\"obmen/kupotvet.php?id={$id}&amp;pass={$pass}&amp;rm={$rm}&amp;ref={$ref}\">Купить ответ</a><br/></div>";}
if ( $rm == 0 )
{
require( "vict.php" );
}
{
require( "flud.php" );
}
if ( $rm == 9 )
{
require( "cellar.php" );
}
if ( $rm == 1 )
{
require( "virt.php" );
}
if ( $rm == 5 )
{
require( "vict1.php" );
}
if ( $rm == 11 )
{
require( "psixolog.php" );
}
echo "<form method=\"post\" action=\"room.php?id={$id}&amp;pass={$pass}&amp;rm={$rm}&amp;ref={$ref}\">\r\n<input name=\"msg\" maxlength=\"150\"/><br/>";
if ( $row['trans'] == 1 )
{
echo "<input name=\"translit\" type=\"checkbox\" value=\"1\">Транслит<br/>";
}
echo "<input value=\"Написать\" type=\"submit\" class=\"cp\">\r\n</form>";
////////////////
if ( $rm == 3 ){require( "zags.php" );}
if ( $rm == 9 ){require( "cellar2.php" );}
if ( $rm == 2 ){ require( "smeh.php" );}
echo "<div>";
///////////
while ( $lines = mysql_fetch_array( $res ) )
{
$priv = intval( $priv );
$mid = $lines['id'];
$dblogin = $lines['login'];
$dbavatar = $lines['avatar'];
$dbid = $lines['id_from'];
$dbmsg = $lines['msg'];
$dbtime = date( "H:i", 
$lines['wtime'] );
$id_to = $lines['id_to'];
##############удаление поста#########
require( "pap/delpost.php" );
require( "pap/ignor.php" );
###################################
}
echo "</div><br>";

echo "<form method=\"post\" action=\"go.php?id={$id}&amp;pass={$pass}&amp;rm={$rm}\">";
echo "<select name=\"url\" title=\"Options\" >";
echo "<option value=\"go2\">Кто сейчас в чате?</option>";
echo "<option value=\"go6\">Смайлы</option>";
echo "<option value=\"go1\">Поиск</option>";
echo "<option value=\"go7\">Черный список</option>";
echo "<option value=\"go8\">Друзья</option>";
echo "<option value=\"go9\">Враги</option>";
//echo "<option value=\"map1\">Приваты</option>";
echo "<option value=\"go3\">Почта ({$mylet})</option>";
echo "<option value=\"go4\">Анкета</option>";
echo "<option value=\"go5\">Настройки</option>";
if ( 3 < $level )
{
echo "<option value=\"map\">Панель управления</option>";
//}
//if ( 7 < $level )
//{
}
echo "</select>\r";
echo "<br/><input value=\"Перейти\" type=\"submit\" class=\"cp\"/>";
echo "</form>";

echo "<div><a href=\"history.php?id={$id}&amp;pass={$pass}&amp;rm={$rm}&amp;s={$max}&amp;ref={$ref}\">История сообщений</a>\n";
echo "<br/><a href=\"enter.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Прихожая</a></div>\n";
$pagesize = round( ( ob_get_length( ) + 500 ) / 1024, 1 );
echo "<center>(~ {$pagesize} Кб) | ";
$end = gettime( );
print "(".round( $end - $mystart, 5 ).")";


//$Contents = ob_get_contents(); 
//$gzib_file = strlen($Contents); 
//$gzib_file_out = strlen(gzcompress($Contents,4)); 
//$gzib_pro=round( 100-(100 /($gzib_file/$gzib_file_out)),1); 
//echo '[ Сжатие: '.$gzib_pro.'% ]';



print "</p></body></html>";
ob_end_flush( );
//require("inc/footer.php");
mysql_close( $link );
?>