Gazelle/sections/user/search.php

97 lines
2.3 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
/**********************************************************************
*>>>>>>>>>>>>>>>>>>>>>>>>>>> User search <<<<<<<<<<<<<<<<<<<<<<<<<<<<*
**********************************************************************/
if (!empty($_GET['search'])) {
$_GET['username'] = $_GET['search'];
}
define('USERS_PER_PAGE', 30);
if(isset($_GET['username'])){
2012-11-17 08:00:19 +00:00
2011-03-28 14:21:28 +00:00
$_GET['username'] = trim($_GET['username']);
// form submitted
$Val->SetFields('username','1','username','Please enter a username.');
$Err = $Val->ValidateForm($_GET);
if(!$Err){
// Passed validation. Let's rock.
2012-10-11 08:00:15 +00:00
list($Page,$Limit) = Format::page_limit(USERS_PER_PAGE);
2012-11-28 08:00:17 +00:00
if ($Page > 10) {
$Page = 10;
$Limit = sprintf("%d, %d", ($Page-1)*USERS_PER_PAGE, USERS_PER_PAGE);
}
2011-03-28 14:21:28 +00:00
$DB->query("SELECT SQL_CALC_FOUND_ROWS
ID,
Username,
Enabled,
PermissionID,
Donor,
Warned
FROM users_main AS um
JOIN users_info AS ui ON ui.UserID=um.ID
2012-09-05 08:00:24 +00:00
WHERE Username LIKE '%".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
}
}
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>
2011-03-28 14:21:28 +00:00
<div class="linkbox">
<?
2012-10-11 08:00:15 +00:00
$Pages=Format::get_pages($Page,$NumResults,USERS_PER_PAGE,9);
2011-03-28 14:21:28 +00:00
echo $Pages;
?>
</div>
2012-09-15 08:00:25 +00:00
<form class="search_form" name="users" action="user.php" method="get">
2011-03-28 14:21:28 +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">
<table style="width:400px;margin:0px auto;">
<tr class="colhead">
<td width="50%">Username</td>
<td>Class</td>
</tr>
<?
foreach($Results as $Result) {
list($UserID, $Username, $Enabled, $PermissionID, $Donor, $Warned) = $Result;
?>
<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>
<? } ?>
</table>
</div>
<div class="linkbox">
<?=$Pages?>
</div>
</div>
2012-10-11 08:00:15 +00:00
<? View::show_footer(); ?>