Файл: user/inc/people_search.php
Строк: 72
<?php
only_reg();
$set['title'] = 'Поиск людей';
if (@$_SESSION['save_z'] == 1) {
@$_SESSION['usearchs'] = null;
@$_SESSION['usearchs_pol'] = null;
}
#если поисковой запрос не содержит сессии ,выбираем противоположный пол по умолчанию
if (@$_SESSION['usearchs_pol'] == null) {
@$_SESSION['usearchs_pol'] = $user['pol'] == 0 ? 1 : 0;
}
if (!isset($_POST['search'])) {
echo "<form class='list-group-item' method='post'>";
} else {
echo "<div class='list-group-item'>";
}
echo "<input type='text' class='form-control' name='search' value='" . @$_SESSION['usearchs'] . "'>";
echo "<label class='c-input c-checkbox'><input type='checkbox'" . (@$_SESSION['save_z'] ? " checked='checked'" : null) . " name='save_z' value='1' /><span class='c-indicator'></span> " . lang('Сохранять поисковой запрос') . "</label><br />n";
echo "<select class='c-select' name='pol'>";
echo "<option value='0' " . (@$_SESSION['usearchs_pol'] == 0 ? " selected='selected'" : false ) . "> " . lang('Женский') . "</option>";
echo "<option value='1' " . (@$_SESSION['usearchs_pol'] == 1 ? " selected='selected'" : false ) . "> " . lang('Мужской') . "</option>";
echo "</select>";
echo " <button class='btn btn-success'>" . lang('Искать') . "</button>";
if (!isset($_POST['search'])) {
echo "</form>";
} else {
echo "</div>";
}
echo "<div class='list-group-item'>";
echo "
* Пример: Saint Андрей Волгоград <br/>
* Пример: Saint 17.04.1992 <br/>";
echo "</div>";
#Поиск S30N1K and Saint dcms-fiera <- Умнички, но есть недоработки
if (!empty($_POST['search']) and $search = my_esc($_POST['search'])) {
@$_SESSION['usearchs'] = $_POST['search'];
$arg = array();
$_SESSION['usearchs_pol'] = intval($_POST['pol']);
$_SESSION['save_z'] = (isset($_POST['save_z']) && $_POST['save_z']);
$pol = my_esc($_POST['pol']);
$search = explode(' ', $search);
foreach ($search as $key) {
if ($data = explode('.', $key) and count($data) === 3) {
$arg[] = "`ank_d_r` like '%{$data[0]}%' AND `ank_m_r` like '%{$data[1]}%' AND `ank_g_r` like '%{$data[2]}%'";
continue;
}
$arg[] = "`id` = '{$key}'";
$arg[] = "`nick` like '%{$key}%'";
$arg[] = "`ank_name` like '%{$key}%'";
$arg[] = "`ank_icq` like '%{$key}%'";
$arg[] = "`ank_o_sebe` like '%{$key}%'";
$arg[] = "`ank_mail` like '%{$key}%'";
$arg[] = "`mylink` like '%{$key}%'";
}
$search = implode(' OR ', $arg);
$k_post = count::query('user', $search . ' AND `pol` = ' . $pol);
if (!$k_post) {
msg("Ничего не найдено");
}
msg("Результатов - ({$k_post})");
echo "<a href='?'><div class='list-group-item'> Искать снова</div></a>";
$sql_s = query("SELECT * FROM `user` WHERE `pol` = '{$pol}' AND {$search} ORDER BY `date_last` DESC");
while ($ank = mysql_fetch_assoc($sql_s)) {
echo "<table class='list-group-item'>";
echo "<tr><td class='icon14'>";
avatar($ank['id'], 110, 110);
echo "</td><td class='null'>";
echo nick($ank['id']);
echo ($ank['ank_name'] != null ? ' , <b>' . output_text($ank['ank_name']) . '</b>' : false) . " " . ($ank['ank_city'] != null ? ' , <b>' . output_text($ank['ank_city']) . '</b>' : false);
if ($ank['status_ank'] != NULL) {
$text = output_text($ank['status_ank']);
$res = mb_substr($text, 0, 99);
if ($text != $res)
$res .= '...';
echo "<div class='status_o_s'> </div><div class='status_o' > " . $res . " </div>";
}
echo "</td></tr></table>";
}
echo "<a href='?'><div class='list-group-item'> Искать снова</div></a>";
}
?>