Файл: modules/users/search.php
Строк: 74
<?php
/**
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) 2013-2014, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
* @link http://perf-engine.net
* @package PerfEngine
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
$locate = 'in_users';
$id = @input($_GET['id']);
$title = _t('user_search');
include_header($title);
Template::div('title', $title);
if(isset($_GET['id']))
{
if(isset($_GET['type']))
{
$type = ($_GET['type'] == 0 ? 'nick' : ($_GET['type'] == 1 ? 'name' : ($_GET['type'] == 2 ? 'city' : ($_GET['type'] == 3 ? 'country' : 'name'))));
}
else
{
$type = 'nick';
}
if(isset($_GET['order']))
{
$order = ($_GET['order'] == 0 ? 'ASC' : ($_GET['type'] == 1 ? 'DESC' : 'DESC'));
}
else
{
$order = 'ASC';
}
$sql = (empty($id) ? "SELECT * FROM `users` ORDER BY time, $type $order " : "SELECT * FROM `users` WHERE `".$type."` LIKE '%".$id."%' ORDER BY time $order ");
$users_r = $db->query("SELECT * FROM `users`".(!empty($id) ? " WHERE `".$type."` LIKE '%".$id."%'" : null)."")->rowCount();
$pages = new Paginator($users_r, $ames);
if($users_r == 0)
{
Template::div('error', _t('not_found'));
}
else
{
$users = $db->query($sql."LIMIT $start, $ames");
// print_r($db->errorInfo());
foreach($users as $user)
{
$tpl->div('post', nick($user['id']));
}
$pages->view();
}
}
echo '<div class="menu">'. _t('search').':
<form action="/users/search" method="get">
<input type="text" name="id"'.(isset($_GET['id']) ? ' value="'.input($_GET['id']).'"' : null).' /><br/>
<select name="type">
<option value="0"'.(isset($_GET['type']) && $_GET['type'] == 0 ? ' selected="selected"' : null).'>'._t('search_by_nick').'</option>
<option value="1"'.(isset($_GET['type']) && $_GET['type'] == 1 ? ' selected="selected"' : null).'>'._t('search_in_names').'</option>
<option value="2"'.(isset($_GET['type']) && $_GET['type'] == 2 ? ' selected="selected"' : null).'>'._t('search_by_city').'</option>
<option value="3"'.(isset($_GET['type']) && $_GET['type'] == 3 ? ' selected="selected"' : null).'>'._t('search_by_country').'</option>
</select><br />
'._t('sort').'<br />
<select name="order">
<option value="0"'.(isset($_GET['type']) && $_GET['order'] == 0 ? ' selected="selected"' : null).'>'._t('sort_asc').'</option>
<option value="1"'.(isset($_GET['type']) && $_GET['order'] == 1 ? ' selected="selected"' : null).'>'._t('sort_desc').'</option>
</select>
<input type="submit" value="Go!" />
</form>
</div>';
echo '<div class="block">'.
NAV.' <a href="/users/">'._t('users').'</a><br/>'
.HICO.' <a href="/">'._t('home').'</a>
</div>';
include_footer();