<?php
//*********************/
//Скрипт переписан админом
//http://waufon.ru  Кот      *  Проги для компа и мобил
//Помогал админ
//http://pfc.h2m.ru/ КОСМОС  * Посети непожалееш
//всю эту срань господнюю
//перехуяривали на дыры
//http://rus-waphost.ru/ Nitrix * Супер хост без висов
/*********************/
require( "inc/conf.inc.php" );
require( "inc/check.php" );
$datep = date("d.m");
$datep = str_replace("01","1",$datep);
$datep = str_replace("02","2",$datep);
$datep = str_replace("03","3",$datep);
$datep = str_replace("04","4",$datep);
$datep = str_replace("05","5",$datep);
$datep = str_replace("06","6",$datep);
$datep = str_replace("07","7",$datep);
$datep = str_replace("08","8",$datep);
$datep = str_replace("09","9",$datep);

$allreg_count = @mysql_query("SELECT count(*) FROM `forum_topic` WHERE id>0;");
$all = @mysql_fetch_array($allreg_count);
$allcount = $all['count(*)'];

$mas_count = @mysql_query("SELECT count(*) FROM `forum_message` WHERE id>0;");
$mas = @mysql_fetch_array($mas_count);
$mascount = $mas['count(*)'];


if(!empty($login))
$q = @mysql_query("select `id` from `".$px.$utable."` where `login`='".$login."';");
if(empty($id)) {
$data = @mysql_fetch_array($q);
$id = $data['id'];
}

$login = autorize();
$loginn = $login['login'] ;
$bday = $login['bday'] ;
$bmonth = $login['bmonth'] ;
$birth = "$bday.$bmonth";
$sex =  $login['sex'] ;
$sound =  $login['sound'] ;
$shtamp = $data['shtamp'];
$krutoj = $row['krutoj'];
$login = $row['login'];
$id = $row['id'];
$admin = $row['admin'];
$status = $row['status'];
$posts = $row['posts'];
$vposts = $row['vposts'];
$genij = $row['genij'];
$theme = $row['theme'];
#####################################

#####################################*/
if ( empty( $status ) )
{
mysql_query( "update users set status='Прохожий' where id='{$id}';" );
}
if ( 100 <= $posts && $posts < 500 && $status == "Прохожий" )
{
mysql_query( "update users set status='Новичок' where id='{$id}';" );
}
if ( 500 <= $posts && $posts < 1000 && $status == "Новичок" )
{
mysql_query( "update users set status='Пользователь' where id='{$id}';" );
}
if ( 1000 <= $posts && $posts < 3000 && $status == "Пользователь" )
{
mysql_query( "update users set status='Продвинутый' where id='{$id}';" );
}
if ( 3000 <= $posts && $posts < 5000 && $status == "Продвинутый" )
{
mysql_query( "update users set status='Чаттер' where id='{$id}';" );
}
if ( 5000 <= $posts && $posts < 7000 && $status == "Чаттер" )
{
mysql_query( "update users set status='Тусовщик' where id='{$id}';" );
}
if ( 7000 <= $posts && $status == "Тусовщик" )
{
mysql_query( "update users set status='Почетный' where id='{$id}';" );
}
$flag = false;
$opt = file( "data/optim.dat" );
$opt = intval( trim( $opt[0] ) );
if ( $opt < time( ) )
{
$opt = time( ) + 17280;
$fp = @fopen( "data/optim.dat", "wb" );
fputs( $fp, $opt );
fclose( $fp );
$flag = true;
}
if ( $flag )
{
$dt = time( ) - 86400;
mysql_query( "Delete from mess where wtime < '".$dt."'" );
mysql_query( "OPTIMIZE TABLE mess" );
mysql_query( "TRUNCATE TABLE intim" );
mysql_query( "Insert into mess set login='Дворецкий', msg='Приветствуем Вас в нашем позитивном чатике :)', id_from='0', id_to='0', wtime='".time( )."',room='all'" );

}
/////////////////////
$ltime = $row['ltime'];
$offline = $ltime + 1200;
if ( $offline < time( ) )
{
$time = time( );
$helo = "Привет :)";
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`='11' where id='{$id}';" );
////////Девушке///////////
if($sex=="2")
{
$ltime = $row['ltime'];
$offline = $ltime+1200;

if ($offline < time())
{
$time = time();
$helo = "Вау! <b><u>$login</u></b> Девачкам по чмасику. Привет! Проходи родная моя раздевайсо располагайсо!";
mysql_query ("Insert into mess set id=0, login='Дворецкий', msg='".$helo."', id_from='0', id_to='0', wtime='".$time."',room='all'");
}

mysql_query("update users set `ltime`='".time()."', `lroom`='11' where id='$id';");
}
///////Парню///////////
if($sex=="1")
{
$ltime = $row['ltime'];
$offline = $ltime+1200;

if ($offline < time())
{
$time = time();
$helo = "Йёпсь! <b><u>$login</u></b> Привет! Проходи, Бум девушек кадрить?!";
mysql_query ("Insert into mess set id=0, login='Дворецкий', msg='".$helo."', id_from='0', id_to='0', wtime='".$time."',room='all'");
}

mysql_query("update users set `ltime`='".time()."', `lroom`='11' where id='$id';");
}
/////////////////////////
///////Неизвестному///////////
if($sex=="0")
{
$ltime = $row['ltime'];
$offline = $ltime+1200;

if ($offline < time())
{
$time = time();
$helo = "Ипать! <b><u>$login</u></b> <img src=\"../sm/diablo.gif\" alt=\"\"/>. А што с тваей ориентацыей? анук вали гг в личный домик и анкету там и определись.<img src=\"../sm/haha.gif\" alt=\"\"/>";
mysql_query ("Insert into mess set id=0, login='Дворецкий', msg='".$helo."', id_from='0', id_to='0', wtime='".$time."',room='all'");
}

mysql_query("update users set `ltime`='".time()."', `lroom`='11' where id='$id';");
}
/////////////////////////
$q_c = @mysql_query( @"SELECT count(*) FROM users WHERE ltime>'".@intval( @time( ) - 300 )."'" );
$c_o = @mysql_fetch_array( @$q_c );
$onl = $c_o['count(*)'];
$data = file( "data/stats.dat" );
$ex = explode( "|", $data[0] );
$mline = $ex[0] + 0;
if ( $mline < $onl )
{
$fp = fopen( "data/stats.dat", "wb" );
$mdata = $onl."|".time( );
fputs( $fp, $mdata );
fclose( $fp );
}
echo "<title>{$cname}</title>";
echo "<link rel=\"shortcut icon\" href=\"images/favicon.jpeg\">";
if ( 20 < $theme)
{
echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"style/0".$s.".css\"></head><body>";
}
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>";
if ( 20 < $theme)
{
echo "<div class=\"title\">";
}
echo '<center>Добро пожаловать в позитивный чатик :)</center>';
if ( 20 < $theme)
{
echo "</div><div class=\"b\">";
}

require("calendar.php");

$for1 = mysql_query( "select count(*) as num from forum_sections" );
$for2 = mysql_fetch_array( $for1 );
$for3 = $for2['num'];
$n1 = mysql_query( "select count(*) as num from news" );
$n2 = mysql_fetch_array( $n1 );
$n3 = $n2['num'];
$t1 = mysql_query( "select count(*) as num from team" );
$t2 = mysql_fetch_array( $t1 );
$t3 = $t2['num'];
if ( 3 < $row['level'] )
{
echo "<a href=\"cpanel/?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">{$cpanel}Панель управления</a><br/>";
}
echo "<a href=\"help.php?id={$id}&amp;pass={$pass}&amp;mod=rules&amp;ref={$ref}\">Устав городка</a><br/>";
echo "<a href=\"search.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Поиск</a><br/>";
echo "<a href=\"online.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Сейчас в чате</a> ({$onl})</a><br/>";


echo "<a href=\"news.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Последние новости</a> ({$n3})</a><br/>";
echo "<a href=\"my/?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Личный кабинет</a> ($login)<br/>";
$q1 = mysql_query( "select id from letters where id_to='{$id}' and new=1 and del_in=0;" );
if ( mysql_num_rows( $q1 ) ){
echo "<a href=\"mail/?id={$id}&amp;pass={$pass}&amp;mod=in\">Вы получили <font color='red'>новые сообщения</font>!</a><br/>";
}
$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><br/>";
}
$q_klan = @mysql_query( @"SELECT count(*) FROM users WHERE ltime>'".@intval( @time( ) - 300 )."' and `lroom`='17' " );
$c_klan = @mysql_fetch_array( @$q_klan );
$klan = $c_klan['count(*)'];
$q_blog = @mysql_query( @"SELECT count(*) FROM users WHERE ltime>'".@intval( @time( ) - 300 )."' and `lroom`='20' " );
$c_blog = @mysql_fetch_array( @$q_blog );
$blog = $c_blog['count(*)'];

echo "<div><font color='#eee'>Развличения</font></div>";
include "includes/inc_online.php";
echo "<a href=\"clan/clans.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Кланы</a></b> ({$klan})<br/>\r\n";
echo "<a href=\"blogs.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Дневники</a> ({$blog})<br/>";


//echo "<div class=\"d1\">";
////////////////////////////////////////
echo "<div><font color='#eee'>Комнаты</font></div>";
$q = @mysql_query( "select `var`,`name` from setts order by var;" );
while ( $rooms = @mysql_fetch_array( @$q ) )
{
$rname = $rooms['name'];
$num = $rooms['var'];
$c = mysql_query( "SELECT count(id) FROM users WHERE `ltime`>'".intval( time( ) - 300 )."' AND `lroom`='".$num."';" );
$dcount = mysql_fetch_array( $c );
if ( $num == 9 )
{
echo "<b><a href=\"anlim.php?id={$id}&amp;pass={$pass}&amp;rm={$num}&amp;ref={$ref}\">{$rname}</a></b> (".$dcount['count(id)'].")<br/>";
}
else if ( $num == 10 )
{
echo "<b><a href=\"intim.php?id={$id}&amp;pass={$pass}&amp;rm={$num}&amp;ref={$ref}\">{$rname}</a></b> (".$dcount['count(id)'].")<br/>";
}
else if ( $num == 11 )
{
echo "<b><a href=\"psix.php?id={$id}&amp;pass={$pass}&amp;rm={$num}&amp;ref={$ref}\">{$rname}</a></b> (".$dcount['count(id)'].")<br/>";
}
else
{
echo "<a href=\"room.php?id={$id}&amp;pass={$pass}&amp;rm={$num}&amp;ref={$ref}\">{$rname}</a> (".$dcount['count(id)'].")<br/>";
}
}
//echo "</div>";
if ( empty( $do ) )
echo "<div><font color='#eee'>Сегодня тем чата</font> ({$t3})</a></div>";
$q = mysql_query( "select id,title from team order by id desc limit 10;" );
if ( mysql_affected_rows( ) == 0 )
{
echo "Сегодня тем нет...<br/>";
}
else
{
while ( $arr = mysql_fetch_array( $q ) )
{
++$i;
echo "{$i}. <a href=\"tema.php?id={$id}&amp;pass={$pass}&amp;mid=".$arr['id']."&amp;do=see&amp;ref={$ref}\">".$arr['title']."</a><br/>";
}
}
echo "<div><font color='#eee'>Прочее</font></div>";
$f1 = mysql_query( "select count(*) as num from users where photo <> '';" );
$f2 = mysql_fetch_array( $f1 );
$f3 = $f2['num'];
echo "<a href=\"help.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">FAQ/Помощь</a><br/>";
echo "<a href=\"stats.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Статистика</a><br/>";
$galery = mysql_query ("select count(id) as num from users where img!=''");
$foto = mysql_fetch_array($galery);
$kolfoto = $foto["num"];
echo "<a href=\"galery.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Фотогалерея</a> (".$kolfoto.")<br/>";
echo "<a href=\"gallery.php?id={$id}&amp;pass={$pass}\">Рейтинги</a> ({$f3})</a><br/>";
$svadbi=mysql_fetch_array(mysql_query ("select count(id) as num from svadbi"));
echo "<a href=\"svadbi.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Свадьбы</a> (".$svadbi[0].")</a><br/>";
echo "<a href=\"votes.php?id={$id}&amp;pass={$pass}\">Голосования</a><br/>";
echo "\r\n<a href=\"obmen/gipermarket.php?id={$id}&amp;pass={$pass}\">Магазин </a><br/>\r\n";
echo "\r\n<a href=\"obmen/obmennik.php?id={$id}&amp;pass={$pass}\">Обменник</a><br/>\r\n";
$viewsov = file("data/sovet.txt");
$sov = $viewsov[0];
//echo "</div>";
print"<br>Сейчас в прихожей: ";
$q_online = mysql_query( "SELECT `login` FROM users WHERE ltime>'".intval( time( ) - 300 )."' AND `lroom`='11' order by ltime desc;" );
while ( $donline = mysql_fetch_array( $q_online ) )
{
print $donline['login'].", ";
}
echo "<div><a href=\"exit.php?id={$id}&amp;pass={$pass}\">Выйти из чата</a></div>";
//require( "smiles/convert.php" );
$end = gettime();
echo "[".round( $end - $mystart, 5 )."]";
echo "</body></html>";
mysql_close( $link );
echo "\r\n";
?>