<?php
#Made By: AngelOfFaith
#URL: http://coder-lib.ru
#ICQ: 410755038
#Mail: angeloffaith@inbox.ru
#Скпри запрещено продавать, раздавать, менять, выкладывать, переписывать!
#Все права на скрипт принадлежат автору, тоесть мне!
#З.Ы. Уважайте авторские права

include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';

include_once '../sys/inc/thead.php';




$gconf=mysql_fetch_array(mysql_query("SELECT * FROM `gorod_conf`"));




if(isset($user)){

if ($user['level']==10){
echo '<b></a></b>';
};



if($gconf[0]['open']!=1){


if(time()>($user['gorod_eda_time']+(3600*12))){
if($user['gorod_life']>=25){
mysql_query("UPDATE `user` SET `gorod_life`=`gorod_life`-25,`gorod_eda_time`='".time()."' WHERE `id`='".$user['id']."'");
};
};

if (isset($user))mysql_query("DELETE FROM `chat_who` WHERE `id_user` = '$user[id]'");
mysql_query("DELETE FROM `chat_who` WHERE `time` < '".($time-120)."'");
if (isset($user) && isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `chat_rooms` WHERE `id` = '".intval($_GET['id'])."'"),0)==1
&& isset($_GET['msg']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '".intval($_GET['msg'])."'"),0)==1)
{
$room=mysql_fetch_array(mysql_query("SELECT * FROM `chat_rooms` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1"));
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '".intval($_GET['msg'])."' LIMIT 1"));
if (isset($user))mysql_query("INSERT INTO `chat_who` (`id_user`, `time`,  `room`) values('$user[id]', '$time', '$room[id]')");
if ($set['time_chat']!=0)header("Refresh: $set[time_chat]; url=/chat/room/$room[id]/".rand(1000,9999).'/'); // автообновление
$set['title']='Чат - '.$room['name'].' ('.mysql_result(mysql_query("SELECT COUNT(*) FROM `chat_who` WHERE `room` = '$room[id]'"),0).')'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
echo "<a href='/info.php?id=$ank[id]'>Посмотреть анкету</a><br />\n";
echo "<form method=\"post\" action=\"/chat/room/$room[id]/".rand(1000,9999)."/\">\n";
echo "Сообщение:<br />\n<textarea name=\"msg\">$ank[nick], </textarea><br />\n";
echo "<label><input type=\"checkbox\" name=\"privat\" value=\"$ank[id]\" /> Приватно</label><br />\n";
if ($user['set_translit']==1)echo "<label><input type=\"checkbox\" name=\"translit\" value=\"1\" /> Транслит</label><br />\n";
echo "<input value=\"Отправить\" type=\"submit\" />\n";
echo "</form>\n";
echo "<div class=\"foot\">\n";
echo "&laquo;<a href=\"/chat/$room[id]/".rand(1000,9999)."/\">В комнату</a><br />\n";
echo "&laquo;<a href=\"/chat/\">Прихожая</a><br />\n";
echo "</div>\n";
include_once '../sys/inc/tfoot.php';
}
if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `chat_rooms` WHERE `id` = '".intval($_GET['id'])."'"),0)==1)
{
$room=mysql_fetch_array(mysql_query("SELECT * FROM `chat_rooms` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1"));
if (isset($user))mysql_query("INSERT INTO `chat_who` (`id_user`, `time`,  `room`) values('$user[id]', '$time', '$room[id]')");
if ($set['time_chat']!=0)header("Refresh: $set[time_chat]; url=/chat/room/$room[id]/".rand(1000,9999).'/'); // автообновление
$set['title']='Чат - '.$room['name'].' ('.mysql_result(mysql_query("SELECT COUNT(*) FROM `chat_who` WHERE `room` = '$room[id]'"),0).')'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
include 'inc/room.php';
echo "<div class=\"foot\">\n";
echo "&laquo;<a href=\"/chat/\">Прихожая</a><br />\n";
echo "</div>\n";
include_once '../sys/inc/tfoot.php';
}
$set['title']='Чат - прихожая'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
if (isset($user) && $user['level']>0)include 'inc/admin_act.php';
aut();

 // форма авторизации
$q=mysql_query("SELECT * FROM `chat_rooms` ORDER BY `pos` ASC");
if (mysql_num_rows($q)==0) {

echo "Нет комнат<br/>\n";

}
while ($room = mysql_fetch_array($q))
{

if($num==1){
echo "<div class='rowdown'>";
$num=0;
}else{
echo "<div class='rowup'>";
$num=1;}

//echo "<img src='/style/themes/$set[set_them]/chat/14/room.png' alt='' />";

echo "<a href='/chat/room/$room[id]/".rand(1000,9999)."/'>$room[name] (".mysql_result(mysql_query("SELECT COUNT(*) FROM `chat_who` WHERE `room` = '$room[id]'"),0).")</a><br />\n";
if ($room['opis']!=NULL)echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($room['opis']))))))))."<br />\n";
if (isset($user) && $user['level']>2)echo "<a href='?set=$room[id]'>Параметры</a><br />\n";
echo "</div>";
}

if (isset($user) && $user['level']>0)include 'inc/admin_form.php';


}else{
echo '<div class="msg">Город закрыт администратором!</div>';
};

}else{


title();echo "<form method='post' action='/?$passgen'>\n";
echo "Логин:<br /><input type='text' name='nick' maxlength='32' /><br />\n";
echo "Пароль (<a href='/pass.php'>Забыли</a>):<br /><input type='password' name='pass' maxlength='32' /><br />\n";
echo "<label><input type='checkbox' name='aut_save' value='1' /> Запомнить меня<br /></label>\n";
echo "<input type='submit' value='Войти' />\n";
echo "</form><br />\n";
echo "<div class='foot'>\n";
echo "&raquo;<a href='/reg.php'><b>Регистрация</b></a><br />\n";
echo "</div>\n";
};

include_once '../sys/inc/tfoot.php';
?>
<?php
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';

$set['title']='Смайлы '.$_SERVER['HTTP_HOST'];
include_once '../sys/inc/thead.php';

title();
aut();

//echo '<div class="menu">';

if(!isset($user)){
echo '<div class="err">Доступ закрыт</div>';
}else{

if($user['level']<0){
$ty = ' WHERE `level` = $user[level]';
}

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `smiles_dir`$ty"),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];

if($k_post==0){
	echo '<div class="err">Нет директорий.</div>';
	}

$q=mysql_query("SELECT * FROM `smiles_dir`$ty ORDER BY `pos` ASC LIMIT $start, $set[p_str]");
while($post = mysql_fetch_array($q)){
if($num==1){
echo '<div class="frends">';
$num=0;
}else{
echo '<div class="frends2">';
$num=1;}
$smile = mysql_result(mysql_query("SELECT COUNT(*) FROM `smiles_spis` WHERE `id_dir` = '$post[id]'"),0);
echo '&#187;&nbsp;<a href="dir.php?id='.$post['id'].'">'.esc(stripcslashes(htmlspecialchars($post['name']))).'</a> ('.$smile.')<br/>';
echo "</div>";
}

if($k_page>1){
	str('index.php?',$k_page,$page);
	}
	}

echo '</div>';
include_once '../sys/inc/tfoot.php';
?>
