2011-03-28 14:21:28 +00:00
< ?
2015-08-22 08:00:28 +00:00
2013-04-17 08:00:58 +00:00
if ( isset ( $_GET [ 'userid' ]) && check_perms ( 'users_view_invites' )) {
if ( ! is_number ( $_GET [ 'userid' ])) {
error ( 403 );
}
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
$UserID = $_GET [ 'userid' ];
$Sneaky = true ;
} else {
2013-04-17 08:00:58 +00:00
if ( ! $UserCount = $Cache -> get_value ( 'stats_user_count' )) {
2013-06-09 08:01:21 +00:00
$DB -> query ( "
SELECT COUNT ( ID )
FROM users_main
WHERE Enabled = '1' " );
2011-03-28 14:21:28 +00:00
list ( $UserCount ) = $DB -> next_record ();
$Cache -> cache_value ( 'stats_user_count' , $UserCount , 0 );
}
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
$UserID = $LoggedUser [ 'ID' ];
$Sneaky = false ;
}
2012-10-11 08:00:15 +00:00
list ( $UserID , $Username , $PermissionID ) = array_values ( Users :: user_info ( $UserID ));
2011-03-28 14:21:28 +00:00
2013-06-09 08:01:21 +00:00
$DB -> query ( "
SELECT InviteKey , Email , Expires
FROM invites
WHERE InviterID = '$UserID'
ORDER BY Expires " );
2011-03-28 14:21:28 +00:00
$Pending = $DB -> to_array ();
2013-04-17 08:00:58 +00:00
$OrderWays = array ( 'username' , 'email' , 'joined' , 'lastseen' , 'uploaded' , 'downloaded' , 'ratio' );
2011-03-28 14:21:28 +00:00
2013-04-17 08:00:58 +00:00
if ( empty ( $_GET [ 'order' ])) {
$CurrentOrder = 'id' ;
$CurrentSort = 'asc' ;
$NewSort = 'desc' ;
2011-03-28 14:21:28 +00:00
} else {
2013-04-17 08:00:58 +00:00
if ( in_array ( $_GET [ 'order' ], $OrderWays )) {
2011-03-28 14:21:28 +00:00
$CurrentOrder = $_GET [ 'order' ];
2013-04-17 08:00:58 +00:00
if ( $_GET [ 'sort' ] == 'asc' || $_GET [ 'sort' ] == 'desc' ) {
2011-03-28 14:21:28 +00:00
$CurrentSort = $_GET [ 'sort' ];
$NewSort = ( $_GET [ 'sort' ] == 'asc' ? 'desc' : 'asc' );
} else {
error ( 404 );
}
} else {
error ( 404 );
}
}
2013-05-01 08:00:16 +00:00
switch ( $CurrentOrder ) {
2013-09-17 08:00:49 +00:00
case 'username' :
2011-03-28 14:21:28 +00:00
$OrderBy = " um.Username " ;
break ;
2013-09-17 08:00:49 +00:00
case 'email' :
2011-03-28 14:21:28 +00:00
$OrderBy = " um.Email " ;
break ;
2013-09-17 08:00:49 +00:00
case 'joined' :
2011-03-28 14:21:28 +00:00
$OrderBy = " ui.JoinDate " ;
break ;
2013-09-17 08:00:49 +00:00
case 'lastseen' :
2011-03-28 14:21:28 +00:00
$OrderBy = " um.LastAccess " ;
break ;
2013-09-17 08:00:49 +00:00
case 'uploaded' :
2011-03-28 14:21:28 +00:00
$OrderBy = " um.Uploaded " ;
break ;
2013-09-17 08:00:49 +00:00
case 'downloaded' :
2011-03-28 14:21:28 +00:00
$OrderBy = " um.Downloaded " ;
break ;
2013-09-17 08:00:49 +00:00
case 'ratio' :
2011-03-28 14:21:28 +00:00
$OrderBy = " (um.Uploaded / um.Downloaded) " ;
break ;
2013-09-17 08:00:49 +00:00
default :
2011-03-28 14:21:28 +00:00
$OrderBy = " um.ID " ;
break ;
}
2012-10-11 08:00:15 +00:00
$CurrentURL = Format :: get_url ( array ( 'action' , 'order' , 'sort' ));
2011-03-28 14:21:28 +00:00
2013-06-09 08:01:21 +00:00
$DB -> query ( "
SELECT
ID ,
Email ,
Uploaded ,
Downloaded ,
JoinDate ,
LastAccess
2013-11-17 08:00:47 +00:00
FROM users_main AS um
2013-09-17 08:00:49 +00:00
LEFT JOIN users_info AS ui ON ui . UserID = um . ID
2013-06-09 08:01:21 +00:00
WHERE ui . Inviter = '$UserID'
ORDER BY $OrderBy $CurrentSort " );
2011-03-28 14:21:28 +00:00
$Invited = $DB -> to_array ();
2013-09-17 08:00:49 +00:00
$JSIncludes = '' ;
2013-07-25 08:00:49 +00:00
if ( check_perms ( 'users_mod' ) || check_perms ( 'admin_advanced_user_search' )) {
2013-09-17 08:00:49 +00:00
$JSIncludes = 'invites' ;
2013-07-25 08:00:49 +00:00
}
View :: show_header ( 'Invites' , $JSIncludes );
2011-03-28 14:21:28 +00:00
?>
< div class = " thin " >
2012-08-19 08:00:19 +00:00
< div class = " header " >
2012-10-11 08:00:15 +00:00
< h2 >< ? = Users :: format_username ( $UserID , false , false , false ) ?> > Invites</h2>
2012-08-19 08:00:19 +00:00
< div class = " linkbox " >
2013-04-17 08:00:58 +00:00
< a href = " user.php?action=invitetree<? if ( $Sneaky ) { echo '&userid='. $UserID ; } ?> " class = " brackets " > Invite tree </ a >
2012-08-19 08:00:19 +00:00
</ div >
2011-03-28 14:21:28 +00:00
</ div >
< ? 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 >
< ? }
/*
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
*/
2013-06-09 08:01:21 +00:00
$DB -> query ( "
SELECT can_leech
FROM users_main
WHERE ID = $UserID " );
2011-03-28 14:21:28 +00:00
list ( $CanLeech ) = $DB -> next_record ();
2015-08-22 08:00:28 +00:00
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' ))
2013-04-17 08:00:58 +00:00
) { ?>
2011-03-28 14:21:28 +00:00
< div class = " box pad " >
2014-01-22 08:00:56 +00:00
< p > Please note that the selling , trading , or publicly giving away our invitations & #8202;— or responding to public invite requests — is strictly forbidden, and may result in you and your entire invite tree being banned. This includes offering to give away our invitations on any forum which is not a class-restricted forum on another private tracker.</p>
2013-03-09 08:00:18 +00:00
< p > Remember that you are responsible for ALL invitees , and your account and / or privileges may be disabled due to your invitees ' actions. You should know the person you' re inviting . If you aren ' t familiar enough with the user to trust them , we suggest not inviting them .</ p >
2014-01-22 08:00:56 +00:00
< p >< em > Do not send an invite if you have not read or do not understand the information above .</ em ></ p >
2011-03-28 14:21:28 +00:00
</ div >
2014-04-15 08:00:45 +00:00
< div class = " box box2 " >
< form class = " send_form pad " name = " invite " action = " user.php " method = " post " >
2013-11-17 08:00:47 +00:00
< input type = " hidden " name = " action " value = " take_invite " />
2011-03-28 14:21:28 +00:00
< input type = " hidden " name = " auth " value = " <?= $LoggedUser['AuthKey'] ?> " />
2014-04-15 08:00:45 +00:00
< div class = " field_div " >
< div class = " label " > Email address :</ div >
< div class = " input " >
< input type = " email " name = " email " size = " 60 " />
< input type = " submit " value = " Invite " />
</ div >
</ div >
< ? if ( check_perms ( 'users_invite_notes' )) { ?>
< div class = " field_div " >
< div class = " label " > Staff Note :</ div >
< div class = " input " >
< input type = " text " name = " reason " size = " 60 " maxlength = " 255 " />
</ div >
</ div >
< ? } ?>
2014-01-22 08:00:56 +00:00
</ form >
2011-03-28 14:21:28 +00:00
</ div >
2013-07-25 08:00:49 +00:00
2011-03-28 14:21:28 +00:00
< ?
2013-04-17 08:00:58 +00:00
} elseif ( ! empty ( $LoggedUser [ 'DisableInvites' ])) { ?>
2013-06-09 08:01:21 +00:00
< div class = " box pad " style = " text-align: center; " >
2012-09-15 08:00:25 +00:00
< strong class = " important_text " > Your invites have been disabled . Please read < a href = " wiki.php?action=article&id=310 " > this article </ a > for more information .</ strong >
2012-02-27 08:00:22 +00:00
</ div >
< ?
} elseif ( $LoggedUser [ 'RatioWatch' ] || ! $CanLeech ) { ?>
2013-06-09 08:01:21 +00:00
< div class = " box pad " style = " text-align: center; " >
2013-02-07 08:00:47 +00:00
< 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&id=310 " > this article </ a > for more information .</ strong >
2012-02-27 08:00:22 +00:00
</ div >
< ?
2011-03-28 14:21:28 +00:00
}
if ( ! empty ( $Pending )) {
?>
< h3 > Pending invites </ h3 >
< div class = " box pad " >
< table width = " 100% " >
< tr class = " colhead " >
2014-03-23 08:00:50 +00:00
< td > Email address </ td >
2011-03-28 14:21:28 +00:00
< td > Expires in </ td >
< td > Delete invite </ td >
</ tr >
< ?
$Row = 'a' ;
foreach ( $Pending as $Invite ) {
list ( $InviteKey , $Email , $Expires ) = $Invite ;
2013-07-29 08:00:49 +00:00
$Row = $Row === 'a' ? 'b' : 'a' ;
2011-03-28 14:21:28 +00:00
?>
< tr class = " row<?= $Row ?> " >
< td >< ? = display_str ( $Email ) ?> </td>
< td >< ? = time_diff ( $Expires ) ?> </td>
2013-11-17 08:00:47 +00:00
< 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 >
2011-03-28 14:21:28 +00:00
</ tr >
2013-02-22 08:00:24 +00:00
< ? } ?>
2011-03-28 14:21:28 +00:00
</ table >
</ div >
< ?
}
2013-02-22 08:00:24 +00:00
?>
2011-03-28 14:21:28 +00:00
< h3 > Invitee list </ h3 >
< div class = " box pad " >
< table width = " 100% " >
< 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 >
2013-01-15 08:00:37 +00:00
< td >< a href = " user.php?action=invite&order=downloaded&sort=<?=(( $CurrentOrder == 'downloaded') ? $NewSort : 'desc')?>&<?= $CurrentURL ?> " > Downloaded </ a ></ td >
2011-03-28 14:21:28 +00:00
< td >< a href = " user.php?action=invite&order=ratio&sort=<?=(( $CurrentOrder == 'ratio') ? $NewSort : 'desc')?>&<?= $CurrentURL ?> " > Ratio </ a ></ td >
</ tr >
< ?
$Row = 'a' ;
foreach ( $Invited as $User ) {
2012-03-28 08:00:20 +00:00
list ( $ID , $Email , $Uploaded , $Downloaded , $JoinDate , $LastAccess ) = $User ;
2013-07-29 08:00:49 +00:00
$Row = $Row === 'a' ? 'b' : 'a' ;
2013-02-22 08:00:24 +00:00
?>
2011-03-28 14:21:28 +00:00
< tr class = " row<?= $Row ?> " >
2012-10-11 08:00:15 +00:00
< td >< ? = Users :: format_username ( $ID , true , true , true , true ) ?> </td>
2011-03-28 14:21:28 +00:00
< td >< ? = display_str ( $Email ) ?> </td>
2013-06-09 08:01:21 +00:00
< td >< ? = time_diff ( $JoinDate , 1 ) ?> </td>
< td >< ? = time_diff ( $LastAccess , 1 ); ?> </td>
2012-10-11 08:00:15 +00:00
< td >< ? = Format :: get_size ( $Uploaded ) ?> </td>
< td >< ? = Format :: get_size ( $Downloaded ) ?> </td>
< td >< ? = Format :: get_ratio_html ( $Uploaded , $Downloaded ) ?> </td>
2011-03-28 14:21:28 +00:00
</ tr >
2013-04-17 08:00:58 +00:00
< ? } ?>
2011-03-28 14:21:28 +00:00
</ table >
</ div >
</ div >
2012-10-11 08:00:15 +00:00
< ? View :: show_footer (); ?>