<?
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']='Знакомства';
include_once '../sys/inc/thead.php';
title();
err();
echo "<img src='/love/search.gif' alt=''/> <a href='/users.php'>Общий поиск!!!</a><br/>\n";

"<div class='WhiteLine'></div>";
echo "<div style='font-size:small;background-color:#696969;'>";echo "<center>Найди собеседника</center>";echo "</div>\n";

echo "<a href='/users.php'>Всего анкет:</a> [".mysql_result(mysql_query("SELECT COUNT(*) FROM `user`"), 0)."</a>]<br/>\n";
echo "Из них:<br />\n";

echo "<img src='/love/woman.gif' alt=''/> <a href='woman.php'>Девушки</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `pol` = '0'"),0).")<br/>\n";

echo '<div class="cont">';
echo "<img src='/love/man.gif' alt=''/> <a href='man.php'>Парни</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `pol` = '1'"),0).")<br/>\n";
echo "</div>";
"<div class='WhiteLine'></div>";
echo "<div style='font-size:small;background-color:#6969;'>";echo "<center>Лидеры сайта</center>";echo "</div>\n";
// Лучшие девушки
$q_women=mysql_query("SELECT * FROM `user` WHERE `pol`='0' ORDER BY rating DESC LIMIT 1");

while ($ank_women = mysql_fetch_array($q_women)){
echo '<div class="p_m">';

if($ank_women['pol']=='0'){
echo 'Девушка:<br/>';
}
if($ank_women['ank_d_r']!=NULL && $ank_women['ank_m_r']!=NULL && $ank_women['ank_g_r']!=NULL){
$ank_women['ank_age']=date("Y")-$ank_women['ank_g_r'];

if(date("n")<$ank_women['ank_m_r']){
$ank_women['ank_age']=$ank_women['ank_age']-1;
}else if(date("n")==$ank_women['ank_m_r']&& date("j")<$ank_men['ank_d_r']){
$ank_women['ank_age']=$ank_women['ank_age']-1;
}
}
echo avatar($ank_women['id']);
echo '<br/><a href="/search.php?mode='.md5('info').'&id='.$ank_women['id'].'"><span style="color:'.$ank_women['ncolor'].'">'.$ank_women['nick'].'</span></a> '.$ank_women['ank_age'].' лет<br/>Рейтинг: '.$ank_women['rating'].'<br/>'.online($ank_women['id']).'';



echo '</div>';
}

// Лушие мужчины
$q_men=mysql_query("SELECT * FROM `user` WHERE `pol`='1' ORDER BY rating DESC LIMIT 1");

while ($ank_men = mysql_fetch_array($q_men)){
echo '<div class="p_m">';

if($ank_men['pol']=='1'){
echo 'Парень:<br/>';
}
if($ank_men['ank_d_r']!=NULL && $ank_men['ank_m_r']!=NULL && $ank_men['ank_g_r']!=NULL){
$ank_men['ank_age']=date("Y")-$ank_men['ank_g_r'];

if(date("n")<$ank_men['ank_m_r']){
$ank_men['ank_age']=$ank_men['ank_age']-1;
}else if(date("n")==$ank_men['ank_m_r']&& date("j")<$ank_men['ank_d_r']){
$ank_men['ank_age']=$ank_men['ank_age']-1;
}
}
echo avatar($ank_men['id']);
echo '<br/><a href="/search.php?mode='.md5('info').'&id='.$ank_men['id'].'"><span style="color:'.$ank_men['ncolor'].'">'.$ank_men['nick'].'</span></a> '.$ank_men['ank_age'].' лет<br/>Рейтинг: '.$ank_men['rating'].'<br/>'.online($ank_men['id']).'';

}

echo '</div>';


$q = mysql_query("select * from `user` ORDER BY `id` desc LIMIT 3;");
$post = mysql_fetch_array(mysql_query("select `nick` from `user` where `id` = '$id[0]';"));
echo "<img src='/love/People.gif' alt=''/>\n";
echo '<font color="red">Новички:</font></label><br />';
while ($post = mysql_fetch_array($q))
{
echo '<a href="/info.php?id='.$post['id'].'">'.$post['nick'].'</a><br />';
}
$q = mysql_query("SELECT * FROM `user` ORDER BY rand() LIMIT 4;");

# SQL запросы в базу данных для создания нужных таблиц:

"<div class='WhiteLine'></div>";
echo "<div style='font-size:small;background-color:#696969;'>";echo "<center>Знакомимся</center>";echo "</div>\n";

# Удаление сообщений:
if(isset($_GET['delete']) AND !empty($_GET['delete']))
{
$delete = (int)$_GET['delete'];
if($user['level'] > 3 OR $ank['id'] == $user['id'])
{
$query = @mysql_query("SELECT `id` FROM `wall` WHERE `user_id` = '$user_id' AND `id` = '$delete';");
if(@mysql_affected_rows() > 0)
{
@mysql_query("DELETE FROM `wall` WHERE `user_id` = '$user_id' AND `id` = '$delete' LIMIT 1;");
echo '<div class="news">Сообщение успешно удалено!</div>';
}
else
echo '<div class="news">Сообщение не найдено!</div>';
}
else
echo '<div class="news">У Вас нет прав для удаления этого сообщения!</div>';
}
# Добавление сообщений:
if(isset($_POST['message']) AND isset($user))
{
$message = $_POST['message'];
if(isset($_POST['translit']) AND $_POST['translit']) $message = translit($message);
$err = '';
if(strlen2($message) > 512) $err .= 'ffсообщение слишком длинное;<br/>';
if(strlen2($message) < 2) $err .= 'ffкороткое сообщение;<br/>';
if(@mysql_result(@mysql_query("SELECT COUNT(*) FROM `wall` WHERE `user_id` = '$user_id' AND `message` = '".@mysql_escape_string($message)."' AND `time` > '".($time - 300)."' LIMIT 1"), 0) != 0) $err .= 'ffваше сообщение повторяет предыдущее;<br/>';
if(time() - @mysql_result(@mysql_query("SELECT `time` FROM `wall` WHERE `user_id` = '$user_id' ORDER BY `id` DESC LIMIT 1;"), 0) < 30) $err .= 'ffне стоит писать сообщения так часто..<br/>';
if($err != '')
{
echo '<div class="news">При добавление сообщения произошли следующие ошибки:<br/>'.$err.'</div>';
}
else
{
$message = @mysql_escape_string($message);
@mysql_query("INSERT INTO `wall` (`user_id`, `who`, `time`, `message`) values('$user_id', '".$user['id']."', '".time()."', '$message')");
@mysql_query("UPDATE `user` SET `msg_on_wall` = `msg_on_wall` + 1 WHERE `id` = '".$user['id']."' LIMIT 1");
echo '<div class="news">Сообщение успешно добавлено!</div>';
}
}
# Вывод сообщений:
$k_post = @mysql_result(@mysql_query("SELECT COUNT(*) FROM `wall` WHERE `user_id` = '$user_id'"), 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)
{
echo 'Нет сообщений...';
}
function getAvatar($id)
{
global $set;
}
$query = @mysql_query("SELECT * FROM `wall` WHERE `user_id` = '$user_id' ORDER BY `time` DESC LIMIT $start, $set[p_str];");
while ($array = mysql_fetch_array($query))
{
$user_nick = @mysql_result(@mysql_query("SELECT `nick` FROM `user` WHERE `id` = '".$array['who']."';"), 0);
echo '<hr color="DeepSkyBlue1" hr noshade size="1"></font>';





echo'<a href="/info.php?id='.$array['who'].'">'.$user_nick.'</a>'.online($array['who']).' </a>
'.esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($array['message'])))))))).'</a>';
if ($user>1)
if ($user['level'] > 3 OR $ank['id'] == $user['id'])
{
echo '[<a href="index.php?id='.$user_id.'&delete='.$array['id'].'">х</a>]';
}

}
echo "<br />\n";
if ($user>1)
echo'<form method="post" action="index.php?id='.$user_id.'">
<u>~Добавь сообщение~</u><br/>
<textarea name="message"></textarea><br/>';
if ($user>1)
echo '<font color="red">Важно:</font> не оскорблять, не флудить, не спамить. Иначе будет БАН.</label><br/>';
if ($user>1)
echo'<input type="submit" value="Написать"/></form></a><br />';
if ($user>1)
echo "<a href=\"/smiles\"><u>Смайлики</u></a><br />\n";
else
{
echo'<font color="red">Для того чтобы написать</font>f';
echo "<a href='../aut.php'><u>войдите</u></a>\n";
echo'<font color="red">или</font>f';
echo "<a href='../reg.php'><u>зарегистрируйтесь</u></br>\n";
}
echo '<div class="foot"></div>';
include_once '../sys/inc/tfoot.php';
?>

