123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- <?php
-
- $ENV = ENV::go();
-
- if (isset($_GET['userid']) && check_perms('users_view_invites')) {
- if (!is_number($_GET['userid'])) {
- error(403);
- }
-
- $UserID=$_GET['userid'];
- $Sneaky = true;
- } else {
- if (!$UserCount = $Cache->get_value('stats_user_count')) {
- $DB->query("
- SELECT COUNT(ID)
- FROM users_main
- WHERE Enabled = '1'");
- list($UserCount) = $DB->next_record();
- $Cache->cache_value('stats_user_count', $UserCount, 0);
- }
-
- $UserID = $LoggedUser['ID'];
- $Sneaky = false;
- }
-
- list($UserID, $Username, $PermissionID) = array_values(Users::user_info($UserID));
-
- $DB->query("
- SELECT InviteKey, Email, Expires
- FROM invites
- WHERE InviterID = '$UserID'
- ORDER BY Expires");
- $Pending = $DB->to_array();
-
- $OrderWays = array('username', 'email', 'joined', 'lastseen', 'uploaded', 'downloaded', 'ratio');
-
- if (empty($_GET['order'])) {
- $CurrentOrder = 'id';
- $CurrentSort = 'desc';
- $NewSort = 'asc';
- } else {
- if (in_array($_GET['order'], $OrderWays)) {
- $CurrentOrder = $_GET['order'];
- if ($_GET['sort'] === 'asc' || $_GET['sort'] === 'desc') {
- $CurrentSort = $_GET['sort'];
- $NewSort = ($_GET['sort'] === 'asc' ? 'desc' : 'asc');
- } else {
- error(404);
- }
- } else {
- error(404);
- }
- }
-
- switch ($CurrentOrder) {
- case 'username':
- $OrderBy = "um.Username";
- break;
- case 'email':
- $OrderBy = "um.Email";
- break;
- case 'joined':
- $OrderBy = "ui.JoinDate";
- break;
- case 'lastseen':
- $OrderBy = "um.LastAccess";
- break;
- case 'uploaded':
- $OrderBy = "um.Uploaded";
- break;
- case 'downloaded':
- $OrderBy = "um.Downloaded";
- break;
- case 'ratio':
- $OrderBy = "(um.Uploaded / um.Downloaded)";
- break;
- default:
- $OrderBy = "um.ID";
- break;
- }
-
- $CurrentURL = Format::get_url(array('action', 'order', 'sort'));
-
- $DB->query("
- SELECT
- ID,
- Email,
- Uploaded,
- Downloaded,
- JoinDate,
- LastAccess
- FROM users_main AS um
- LEFT JOIN users_info AS ui ON ui.UserID = um.ID
- WHERE ui.Inviter = '$UserID'
- ORDER BY $OrderBy $CurrentSort");
-
- $Invited = $DB->to_array();
-
- $JSIncludes = '';
- if (check_perms('users_mod') || check_perms('admin_advanced_user_search')) {
- $JSIncludes = 'invites';
- }
-
- View::show_header('Invites', $JSIncludes);
- ?>
- <div>
- <div class="header">
- <h2><?=Users::format_username($UserID, false, false, false)?>
- > Invites</h2>
- <div class="linkbox">
- <a href="user.php?action=invitetree<?php if ($Sneaky) {
- echo '&userid='.$UserID;
- } ?>" class="brackets">Invite tree</a>
- </div>
- </div>
- <?php if ($UserCount >= USER_LIMIT && !check_perms('site_can_invite_always')) { ?>
- <div class="box pad notice">
- <p>Because the user limit has been reached you are unable to send invites at this time.</p>
- </div>
- <?php }
-
- /*
- Users cannot send invites if they:
- - Are on ratio watch
- - Have disabled leeching
- - Have disabled invites
- - Have no invites (Unless have unlimited)
- - Cannot 'invite always' and the user limit is reached
- */
-
- $DB->query("
- SELECT can_leech
- FROM users_main
- WHERE ID = $UserID");
- list($CanLeech) = $DB->next_record();
-
- if (!$Sneaky
- && !$LoggedUser['RatioWatch']
- && $CanLeech
- && empty($LoggedUser['DisableInvites'])
- && ($LoggedUser['Invites'] > 0 || check_perms('site_send_unlimited_invites'))
- && ($UserCount <= USER_LIMIT || USER_LIMIT === 0 || check_perms('site_can_invite_always'))
- ) { ?>
- <div class="box pad">
- <p>
- Do not trade or sell invites under any circumstances.
- Do not send an invite to anyone who has previously had a <?= $ENV->SITE_NAME ?> account.
- Please direct them to <code>#disabled</code> on Slack if they wish to reactivate their account.
- </p>
-
- <p>
- You may invite anyone so long as you and they both lack malicious intent, but keep in mind that you are
- responsible for anyone you invite.
- If you invite someone you don't know well and they surprise you by breaking the rules or being a generally poor
- user, you will likely end up punished for it.
- For that reason, we stongly recommend you only invite people you personally know and trust.
- </p>
-
- <p><strong>Do not send an invite if you have not read or do not understand the information above.</strong></p>
- </div>
- <div class="box">
- <form class="send_form pad" name="invite" action="user.php" method="post">
- <input type="hidden" name="action" value="take_invite" />
- <input type="hidden" name="auth"
- value="<?=$LoggedUser['AuthKey']?>" />
- <div>
- <div class="label"><strong>Email Address</strong></div>
- <div class="input">
- <input type="email" name="email" size="60" />
- <input type="submit" value="Invite" />
- </div>
- </div>
- <?php if (check_perms('users_invite_notes')) { ?>
- <div>
- <div class="label"><strong>Staff Note</strong></div>
- <div class="input">
- <input type="text" name="reason" size="60" maxlength="255" />
- </div>
- </div>
- <?php } ?>
- </form>
- </div>
-
- <?php
- } elseif (!empty($LoggedUser['DisableInvites'])) { ?>
- <div class="box pad" style="text-align: center;">
- <strong class="important_text">Your invites have been disabled. Please read <a
- href="wiki.php?action=article&name=cantinvite">this article</a> for more information.</strong>
- </div>
- <?php
- } elseif ($LoggedUser['RatioWatch'] || !$CanLeech) { ?>
- <div class="box pad" style="text-align: center;">
- <strong class="important_text">You may not send invites while on Ratio Watch or while your leeching privileges are
- disabled. Please read <a href="wiki.php?action=article&name=cantinvite">this article</a> for more
- information.</strong>
- </div>
- <?php
- }
-
- if (!empty($Pending)) {
- ?>
- <h3>Pending Invites</h3>
- <div class="box">
- <table width="100%">
- <tr class="colhead">
- <td>Email Address</td>
- <td>Expires In</td>
- <td>Delete Invite</td>
- </tr>
- <?php
- foreach ($Pending as $Invite) {
- list($InviteKey, $Email, $Expires) = $Invite;
- $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]'; ?>
- <tr class="row">
- <td><?=display_str($Email)?>
- </td>
- <td><?=time_diff($Expires)?>
- </td>
- <td><a
- href="user.php?action=delete_invite&invite=<?=$InviteKey?>&auth=<?=$LoggedUser['AuthKey']?>"
- onclick="return confirm('Are you sure you want to delete this invite?');">Delete invite</a></td>
- </tr>
- <?php
- } ?>
- </table>
- </div>
- <?php
- }
- ?>
-
- <h3>Invitee List</h3>
- <div class="box">
- <table width="100%" , class="invite_table">
- <tr class="colhead">
- <td><a
- href="user.php?action=invite&order=username&sort=<?=(($CurrentOrder == 'username') ? $NewSort : 'desc')?>&<?=$CurrentURL ?>">Username</a>
- </td>
- <td><a
- href="user.php?action=invite&order=email&sort=<?=(($CurrentOrder == 'email') ? $NewSort : 'desc')?>&<?=$CurrentURL ?>">Email</a>
- </td>
- <td><a
- href="user.php?action=invite&order=joined&sort=<?=(($CurrentOrder == 'joined') ? $NewSort : 'desc')?>&<?=$CurrentURL ?>">Joined</a>
- </td>
- <td><a
- href="user.php?action=invite&order=lastseen&sort=<?=(($CurrentOrder == 'lastseen') ? $NewSort : 'desc')?>&<?=$CurrentURL ?>">Last
- Seen</a></td>
- <td><a
- href="user.php?action=invite&order=uploaded&sort=<?=(($CurrentOrder == 'uploaded') ? $NewSort : 'desc')?>&<?=$CurrentURL ?>">Uploaded</a>
- </td>
- <td><a
- href="user.php?action=invite&order=downloaded&sort=<?=(($CurrentOrder == 'downloaded') ? $NewSort : 'desc')?>&<?=$CurrentURL ?>">Downloaded</a>
- </td>
- <td><a
- href="user.php?action=invite&order=ratio&sort=<?=(($CurrentOrder == 'ratio') ? $NewSort : 'desc')?>&<?=$CurrentURL ?>">Ratio</a>
- </td>
- </tr>
- <?php
- foreach ($Invited as $User) {
- list($ID, $Email, $Uploaded, $Downloaded, $JoinDate, $LastAccess) = $User;
- $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]'
- ?>
- <tr class="row">
- <td><?=Users::format_username($ID, true, true, true, true)?>
- </td>
- <td><?=display_str($Email)?>
- </td>
- <td><?=time_diff($JoinDate, 1)?>
- </td>
- <td><?=time_diff($LastAccess, 1); ?>
- </td>
- <td><?=Format::get_size($Uploaded)?>
- </td>
- <td><?=Format::get_size($Downloaded)?>
- </td>
- <td><?=Format::get_ratio_html($Uploaded, $Downloaded)?>
- </td>
- </tr>
- <?php
- } ?>
- </table>
- </div>
- </div>
- <?php View::show_footer();
|