Gazelle/sections/user/search.php

96 lines
2.4 KiB
PHP
Raw Permalink Normal View History

2013-05-28 08:01:02 +00:00
<?php
2011-03-28 14:21:28 +00:00
/**********************************************************************
*>>>>>>>>>>>>>>>>>>>>>>>>>>> User search <<<<<<<<<<<<<<<<<<<<<<<<<<<<*
**********************************************************************/
if (!empty($_GET['search'])) {
2013-05-16 16:15:57 +00:00
2011-03-28 14:21:28 +00:00
$_GET['username'] = $_GET['search'];
}
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
define('USERS_PER_PAGE', 30);
2013-02-11 08:00:34 +00:00
if (isset($_GET['username'])) {
2013-05-16 16:15:57 +00:00
2011-03-28 14:21:28 +00:00
$_GET['username'] = trim($_GET['username']);
// form submitted
2014-02-27 08:00:30 +00:00
$Val->SetFields('username', '1', 'username', 'Please enter a username.');
2011-03-28 14:21:28 +00:00
$Err = $Val->ValidateForm($_GET);
2013-02-22 08:00:24 +00:00
2013-04-20 08:01:01 +00:00
if (!$Err) {
2011-03-28 14:21:28 +00:00
// Passed validation. Let's rock.
2013-05-28 08:01:02 +00:00
list($Page, $Limit) = Format::page_limit(USERS_PER_PAGE);
2012-11-28 08:00:17 +00:00
if ($Page > 10) {
$Page = 10;
2013-04-20 08:01:01 +00:00
$Limit = sprintf("%d, %d", ($Page - 1) * USERS_PER_PAGE, USERS_PER_PAGE);
2012-11-28 08:00:17 +00:00
}
2013-04-20 08:01:01 +00:00
$DB->query("
2013-05-29 08:00:51 +00:00
SELECT
SQL_CALC_FOUND_ROWS
2013-04-20 08:01:01 +00:00
ID,
Username,
Enabled,
PermissionID,
Donor,
Warned
2011-03-28 14:21:28 +00:00
FROM users_main AS um
2014-02-27 08:00:30 +00:00
JOIN users_info AS ui ON ui.UserID = um.ID
2016-11-01 08:00:28 +00:00
WHERE LCASE(Username) = LCASE('".db_string($_GET['username'], true)."')
2011-03-28 14:21:28 +00:00
ORDER BY Username
LIMIT $Limit");
$Results = $DB->to_array();
2012-09-05 08:00:24 +00:00
$DB->query('SELECT FOUND_ROWS()');
2011-03-28 14:21:28 +00:00
list($NumResults) = $DB->next_record();
2012-11-28 08:00:17 +00:00
if ($NumResults > 300) {
$NumResults = 300;
}
2011-03-28 14:21:28 +00:00
}
}
2013-12-13 08:00:46 +00:00
2012-10-11 08:00:15 +00:00
View::show_header('User search');
2011-03-28 14:21:28 +00:00
?>
<div class="thin">
2012-08-19 08:00:19 +00:00
<div class="header">
<h3>Search results</h3>
</div>
2013-05-21 08:01:09 +00:00
<? $Pages = Format::get_pages($Page, $NumResults, USERS_PER_PAGE, 9);
if ($Pages) { ?>
<div class="linkbox pager"><?=($Pages)?></div>
<? } ?>
2012-09-15 08:00:25 +00:00
<form class="search_form" name="users" action="user.php" method="get">
2013-04-01 08:00:47 +00:00
<input type="hidden" name="action" value="search" />
2012-09-01 08:00:24 +00:00
<table class="layout" width="100%">
2011-03-28 14:21:28 +00:00
<tr>
<td class="label nobr">Username:</td>
<td>
<input type="text" name="username" size="60" value="<?=display_str($_GET['username'])?>" />
&nbsp;
<input type="submit" value="Search users" />
</td>
</tr>
</table>
</form>
<br />
<div class="box pad center">
2013-04-01 08:00:47 +00:00
<table style="width: 400px; margin: 0px auto;">
2011-03-28 14:21:28 +00:00
<tr class="colhead">
<td width="50%">Username</td>
2013-04-01 08:00:47 +00:00
<td>Primary class</td>
2011-03-28 14:21:28 +00:00
</tr>
<?
2013-04-01 08:00:47 +00:00
foreach ($Results as $Result) {
list($UserID, $Username, $Enabled, $PermissionID, $Donor, $Warned) = $Result;
2011-03-28 14:21:28 +00:00
?>
<tr>
2012-10-11 08:00:15 +00:00
<td><?=Users::format_username($UserID, true, true, true, true);?></td>
<td><?=Users::make_class_string($PermissionID);?></td>
2011-03-28 14:21:28 +00:00
</tr>
2013-04-01 08:00:47 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
</table>
</div>
<div class="linkbox">
<?=$Pages?>
</div>
</div>
2012-10-11 08:00:15 +00:00
<? View::show_footer(); ?>