<?php

require '../system/start.php';
require '../system/functions.php';
$str['mesto'] = 'Знакомства';
$str['block'] = $set['site'].' / Знакомства';
reg();
include '../style/'.$style.'/head.php';
$znak = mysql_result(mysql_query("select count(*) from `users` where `where` = 'Знакомства' and time > ".(time()-300).""),0);
switch($act)
{
default:
echo '<div class="mess">
<form action="index.php?act=go" method="post"><div>
Город:
<input name="city" type="text" value=""/><br/>
Пол:
<select size="1" name="pol">
<option value="0">Любой</option>
<option value="1">Мужской</option>
<option value="2">Женский</option>
</select><br/>

Возраст:
от<input name="ageot" type="text" size="2" value=""/>&nbsp;
до<input name="agedo" type="text" size="2" value=""/><br/>
Цель знакомств:
<select size="1" name="purpose">
<option value="0">Любая</option>
<option value="1">Дружба и общение</option>
<option value="2">Флирт, СМС-переписка</option>
<option value="3">Любовь, отношения</option>
<option value="4">Брак, создание семьи</option>
<option value="5">Ищу спонсора</option>
<option value="6">Стану спонсором</option>
</select><br/>
<input type="submit" value="Искать"/>
</div></form>
</div>';
echo '<div class="where">В знакомствах '.$znak.' человек</div>';
break;
case 'go':
$city = protect($_POST['city']);
$pol = int($_POST['pol']);
if(isset($_POST['orient']))
{
	$orient = int($_POST['orient']);
}
else
{
	$orient = "";
}
$ageot = int($_POST['ageot']);
$agedo = int($_POST['agedo']);
$purpose = int($_POST['purpose']);
if(!empty($city))
{
	$cityq = " and `city` LIKE '%".$city."%'";
}
else
{
	$cityq = '';
}
if($pol != 0)
{
	$polq = ' and `gender` = '.$pol;
}
else
{
	$polq = "";
}

if(isset($ageot) and !empty($ageot))
{
	$ageotq = ' and `age` => '.$ageot;
}
else
{
	$ageotq = "";
}
if(isset($agedo) and !empty($agedo))
{
	$agedoq = ' and `age` => '.$agedo;
}
else
{
	$agedoq = "";
}
if($purpose != 0)
{
	$purposeq = ' and `purpose` = '.$purpose;
}
else
{
	$purposeq = "";
}
$query = mysql_query("select * from `users` where `id` > 0".$cityq."".$polq."".$orientq."".$ageotq."".$agedoq."".$purposeq."");
$total = mysql_result(mysql_query("select count(*) from `users` where `id` > 0".$cityq."".$polq."".$orientq."".$ageotq."".$agedoq."".$purposeq.""),0);
if($total == 0)
{
	echo '<div class="forum1">Совпадений не найдено!</div>';
}
while($row = mysql_fetch_assoc($query))
{
	$i++;
	if($i%2)
	{
		echo '<div class="forum1"><div class="row4">';
	} else
	{
		echo '<div class="forum2"><div class="row4">';
	}
	if(empty($row['foto']))
	{
		echo '<img src="../style/'.$style.'/'.$row['gender'].'.png"  width="60" height="60" align="left" alt="" style="margin-right:4px;border-right:1px solid #99ccff"/>';
    }
    elseif(!empty($row['foto']))
	{
		echo '<img src="../files/avatars/'.$row['foto'].'"  width="60" height="60" align="left" alt="" style="margin-right:4px;border-right:1px solid #99ccff"/>';
    }
	echo '<a href="../p/'.$row['login'].'">'.$row['login'].'</a>';
	echo status($row['id']);
	echo '<div class="ftext">
	Имя: '.$row['name'].'<br/>
	Рейтинг: '.$row['rate'].'<br/>
	Последний вход: '.clock($row['time']).'<br/>
	Зарегистрирован: '.clock($row['reg_time']).'
	</div>
	<div class="clear"></div>
	</div>
	</div>';
}
break;
}
include '../style/'.$style.'/foot.php';
?>