Gazelle/sections/tools/data/invite_pool.php

115 lines
2.8 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
2013-04-15 08:00:54 +00:00
if (!check_perms('users_view_invites')) {
error(403);
}
2014-03-23 08:00:50 +00:00
$Title = 'Invite Pool';
View::show_header($Title);
2011-03-28 14:21:28 +00:00
define('INVITES_PER_PAGE', 50);
2013-04-15 08:00:54 +00:00
list($Page, $Limit) = Format::page_limit(INVITES_PER_PAGE);
2011-03-28 14:21:28 +00:00
2013-04-15 08:00:54 +00:00
if (!empty($_POST['invitekey']) && check_perms('users_edit_invites')) {
2011-03-28 14:21:28 +00:00
authorize();
2013-07-13 08:00:46 +00:00
$DB->query("
DELETE FROM invites
WHERE InviteKey = '".db_string($_POST['invitekey'])."'");
2011-03-28 14:21:28 +00:00
}
2013-04-15 08:00:54 +00:00
if (!empty($_GET['search'])) {
2011-03-28 14:21:28 +00:00
$Search = db_string($_GET['search']);
} else {
2013-05-02 08:00:23 +00:00
$Search = '';
2011-03-28 14:21:28 +00:00
}
2013-05-02 08:00:23 +00:00
$sql = "
SELECT
SQL_CALC_FOUND_ROWS
um.ID,
um.IP,
i.InviteKey,
i.Expires,
i.Email
2013-11-17 08:00:47 +00:00
FROM invites AS i
2013-05-02 08:00:23 +00:00
JOIN users_main AS um ON um.ID = i.InviterID ";
2013-04-15 08:00:54 +00:00
if ($Search) {
2013-07-13 08:00:46 +00:00
$sql .= "
WHERE i.Email LIKE '%$Search%' ";
2011-03-28 14:21:28 +00:00
}
2013-07-13 08:00:46 +00:00
$sql .= "
ORDER BY i.Expires DESC
LIMIT $Limit";
2011-03-28 14:21:28 +00:00
$RS = $DB->query($sql);
2013-07-13 08:00:46 +00:00
$DB->query('SELECT FOUND_ROWS()');
2011-03-28 14:21:28 +00:00
list($Results) = $DB->next_record();
$DB->set_query_id($RS);
?>
2014-03-23 08:00:50 +00:00
<div class="header">
<h2><?=$Title?></h2>
</div>
2011-03-28 14:21:28 +00:00
<div class="box pad">
2013-04-15 08:00:54 +00:00
<p><?=number_format($Results)?> unused invites have been sent.</p>
2011-03-28 14:21:28 +00:00
</div>
<br />
<div>
2012-09-15 08:00:25 +00:00
<form class="search_form" name="invites" action="" method="get">
2012-09-01 08:00:24 +00:00
<table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
2011-03-28 14:21:28 +00:00
<tr>
2014-03-23 08:00:50 +00:00
<td class="label"><strong>Email address:</strong></td>
2011-03-28 14:21:28 +00:00
<td>
<input type="hidden" name="action" value="invite_pool" />
2014-03-23 08:00:50 +00:00
<input type="email" name="search" size="60" value="<?=display_str($Search)?>" />
2011-03-28 14:21:28 +00:00
&nbsp;
<input type="submit" value="Search log" />
</td>
</tr>
2013-02-22 08:00:24 +00:00
</table>
2011-03-28 14:21:28 +00:00
</form>
</div>
<div class="linkbox">
<?
2013-04-15 08:00:54 +00:00
$Pages = Format::get_pages($Page, $Results, INVITES_PER_PAGE, 11) ;
2011-03-28 14:21:28 +00:00
echo $Pages;
?>
</div>
<table width="100%">
<tr class="colhead">
<td>Inviter</td>
2014-03-23 08:00:50 +00:00
<td>Email address</td>
<td>IP address</td>
2011-03-28 14:21:28 +00:00
<td>InviteCode</td>
<td>Expires</td>
2013-05-02 08:00:23 +00:00
<? if (check_perms('users_edit_invites')) { ?>
2011-03-28 14:21:28 +00:00
<td>Controls</td>
<? } ?>
</tr>
<?
$Row = 'b';
2013-04-15 08:00:54 +00:00
while (list($UserID, $IP, $InviteKey, $Expires, $Email) = $DB->next_record()) {
2013-07-13 08:00:46 +00:00
$Row = $Row === 'b' ? 'a' : 'b';
2011-03-28 14:21:28 +00:00
?>
<tr class="row<?=$Row?>">
2012-10-11 08:00:15 +00:00
<td><?=Users::format_username($UserID, true, true, true, true)?></td>
2011-03-28 14:21:28 +00:00
<td><?=display_str($Email)?></td>
2013-04-15 08:00:54 +00:00
<td><?=Tools::display_ip($IP)?></td>
2011-03-28 14:21:28 +00:00
<td><?=display_str($InviteKey)?></td>
<td><?=time_diff($Expires)?></td>
2013-04-15 08:00:54 +00:00
<? if (check_perms('users_edit_invites')) { ?>
2011-03-28 14:21:28 +00:00
<td>
2012-09-15 08:00:25 +00:00
<form class="delete_form" name="invite" action="" method="post">
2011-03-28 14:21:28 +00:00
<input type="hidden" name="action" value="invite_pool" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="invitekey" value="<?=display_str($InviteKey)?>" />
<input type="submit" value="Delete" />
</form>
</td>
2013-04-15 08:00:54 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
</tr>
<? } ?>
</table>
2013-05-21 08:01:09 +00:00
<? if ($Pages) { ?>
<div class="linkbox pager"><?=($Pages)?></div>
<? }
View::show_footer(); ?>