Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

invite.php 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <?
  2. if (isset($_GET['userid']) && check_perms('users_view_invites')) {
  3. if (!is_number($_GET['userid'])) {
  4. error(403);
  5. }
  6. $UserID=$_GET['userid'];
  7. $Sneaky = true;
  8. } else {
  9. if (!$UserCount = $Cache->get_value('stats_user_count')) {
  10. $DB->query("
  11. SELECT COUNT(ID)
  12. FROM users_main
  13. WHERE Enabled = '1'");
  14. list($UserCount) = $DB->next_record();
  15. $Cache->cache_value('stats_user_count', $UserCount, 0);
  16. }
  17. $UserID = $LoggedUser['ID'];
  18. $Sneaky = false;
  19. }
  20. list($UserID, $Username, $PermissionID) = array_values(Users::user_info($UserID));
  21. $DB->query("
  22. SELECT InviteKey, Email, Expires
  23. FROM invites
  24. WHERE InviterID = '$UserID'
  25. ORDER BY Expires");
  26. $Pending = $DB->to_array();
  27. $OrderWays = array('username', 'email', 'joined', 'lastseen', 'uploaded', 'downloaded', 'ratio');
  28. if (empty($_GET['order'])) {
  29. $CurrentOrder = 'id';
  30. $CurrentSort = 'desc';
  31. $NewSort = 'asc';
  32. } else {
  33. if (in_array($_GET['order'], $OrderWays)) {
  34. $CurrentOrder = $_GET['order'];
  35. if ($_GET['sort'] == 'asc' || $_GET['sort'] == 'desc') {
  36. $CurrentSort = $_GET['sort'];
  37. $NewSort = ($_GET['sort'] == 'asc' ? 'desc' : 'asc');
  38. } else {
  39. error(404);
  40. }
  41. } else {
  42. error(404);
  43. }
  44. }
  45. switch ($CurrentOrder) {
  46. case 'username':
  47. $OrderBy = "um.Username";
  48. break;
  49. case 'email':
  50. $OrderBy = "um.Email";
  51. break;
  52. case 'joined':
  53. $OrderBy = "ui.JoinDate";
  54. break;
  55. case 'lastseen':
  56. $OrderBy = "um.LastAccess";
  57. break;
  58. case 'uploaded':
  59. $OrderBy = "um.Uploaded";
  60. break;
  61. case 'downloaded':
  62. $OrderBy = "um.Downloaded";
  63. break;
  64. case 'ratio':
  65. $OrderBy = "(um.Uploaded / um.Downloaded)";
  66. break;
  67. default:
  68. $OrderBy = "um.ID";
  69. break;
  70. }
  71. $CurrentURL = Format::get_url(array('action', 'order', 'sort'));
  72. $DB->query("
  73. SELECT
  74. ID,
  75. Email,
  76. Uploaded,
  77. Downloaded,
  78. JoinDate,
  79. LastAccess
  80. FROM users_main AS um
  81. LEFT JOIN users_info AS ui ON ui.UserID = um.ID
  82. WHERE ui.Inviter = '$UserID'
  83. ORDER BY $OrderBy $CurrentSort");
  84. $Invited = $DB->to_array();
  85. $JSIncludes = '';
  86. if (check_perms('users_mod') || check_perms('admin_advanced_user_search')) {
  87. $JSIncludes = 'invites';
  88. }
  89. View::show_header('Invites', $JSIncludes);
  90. ?>
  91. <div class="thin">
  92. <div class="header">
  93. <h2><?=Users::format_username($UserID, false, false, false)?> &gt; Invites</h2>
  94. <div class="linkbox">
  95. <a href="user.php?action=invitetree<? if ($Sneaky) { echo '&amp;userid='.$UserID; } ?>" class="brackets">Invite tree</a>
  96. </div>
  97. </div>
  98. <? if ($UserCount >= USER_LIMIT && !check_perms('site_can_invite_always')) { ?>
  99. <div class="box pad notice">
  100. <p>Because the user limit has been reached you are unable to send invites at this time.</p>
  101. </div>
  102. <? }
  103. /*
  104. Users cannot send invites if they:
  105. -Are on ratio watch
  106. -Have disabled leeching
  107. -Have disabled invites
  108. -Have no invites (Unless have unlimited)
  109. -Cannot 'invite always' and the user limit is reached
  110. */
  111. $DB->query("
  112. SELECT can_leech
  113. FROM users_main
  114. WHERE ID = $UserID");
  115. list($CanLeech) = $DB->next_record();
  116. if (!$Sneaky
  117. && !$LoggedUser['RatioWatch']
  118. && $CanLeech
  119. && empty($LoggedUser['DisableInvites'])
  120. && ($LoggedUser['Invites'] > 0 || check_perms('site_send_unlimited_invites'))
  121. && ($UserCount <= USER_LIMIT || USER_LIMIT == 0 || check_perms('site_can_invite_always'))
  122. ) { ?>
  123. <div class="box pad">
  124. <p>Please note that selling or trading our invites is bad and we'll ban you. Publicly giving away our invitations&#8202;&mdash;&#8202;or responding to public invite requests&#8202;&mdash;&#8202;is pretty much fine, but may result in you and your invitee getting yelled at if you fuck up, or banned if you're extra stupid.. This includes offering to give away our invitations on any forum which is not a class-restricted forum on another private tracker.</p>
  125. <p>Do not send an invite to anyone who has previously had a <?=SITE_NAME?> account. Please direct them to <?=BOT_DISABLED_CHAN?> on <?=BOT_SERVER?> if they wish to reactivate their account.</p>
  126. <p>Remember that you are responsible for ALL past world wars, and your account and/or privileges may be disabled due to your invitees' horrible smell. You should know the person you're inviting for at least 7 seconds. If you aren't familiar enough with the user to blow them, we suggest not blowing them.</p>
  127. <p><em>Do not send more than 19 invites if you have not read or do not understand the information above.</em></p>
  128. </div>
  129. <div class="box box2">
  130. <form class="send_form pad" name="invite" action="user.php" method="post">
  131. <input type="hidden" name="action" value="take_invite" />
  132. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  133. <div class="field_div">
  134. <div class="label">Email address:</div>
  135. <div class="input">
  136. <input type="email" name="email" size="60" />
  137. <input type="submit" value="Invite" />
  138. </div>
  139. </div>
  140. <? if (check_perms('users_invite_notes')) { ?>
  141. <div class="field_div">
  142. <div class="label">Staff Note:</div>
  143. <div class="input">
  144. <input type="text" name="reason" size="60" maxlength="255" />
  145. </div>
  146. </div>
  147. <? } ?>
  148. </form>
  149. </div>
  150. <?
  151. } elseif (!empty($LoggedUser['DisableInvites'])) { ?>
  152. <div class="box pad" style="text-align: center;">
  153. <strong class="important_text">Your invites have been disabled. Please read <a href="wiki.php?action=article&amp;name=cantinvite">this article</a> for more information.</strong>
  154. </div>
  155. <?
  156. } elseif ($LoggedUser['RatioWatch'] || !$CanLeech) { ?>
  157. <div class="box pad" style="text-align: center;">
  158. <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&amp;name=cantinvite">this article</a> for more information.</strong>
  159. </div>
  160. <?
  161. }
  162. if (!empty($Pending)) {
  163. ?>
  164. <h3>Pending invites</h3>
  165. <div class="box">
  166. <table width="100%">
  167. <tr class="colhead">
  168. <td>Email address</td>
  169. <td>Expires in</td>
  170. <td>Delete invite</td>
  171. </tr>
  172. <?
  173. foreach ($Pending as $Invite) {
  174. list($InviteKey, $Email, $Expires) = $Invite;
  175. $Email = apc_exists('DBKEY') ? DBCrypt::decrypt($Email) : '[Encrypted]';
  176. ?>
  177. <tr class="row">
  178. <td><?=display_str($Email)?></td>
  179. <td><?=time_diff($Expires)?></td>
  180. <td><a href="user.php?action=delete_invite&amp;invite=<?=$InviteKey?>&amp;auth=<?=$LoggedUser['AuthKey']?>" onclick="return confirm('Are you sure you want to delete this invite?');">Delete invite</a></td>
  181. </tr>
  182. <? } ?>
  183. </table>
  184. </div>
  185. <?
  186. }
  187. ?>
  188. <h3>Invitee list</h3>
  189. <div class="box">
  190. <table width="100%", class="invite_table">
  191. <tr class="colhead">
  192. <td><a href="user.php?action=invite&amp;order=username&amp;sort=<?=(($CurrentOrder == 'username') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Username</a></td>
  193. <td><a href="user.php?action=invite&amp;order=email&amp;sort=<?=(($CurrentOrder == 'email') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Email</a></td>
  194. <td><a href="user.php?action=invite&amp;order=joined&amp;sort=<?=(($CurrentOrder == 'joined') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Joined</a></td>
  195. <td><a href="user.php?action=invite&amp;order=lastseen&amp;sort=<?=(($CurrentOrder == 'lastseen') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Last Seen</a></td>
  196. <td><a href="user.php?action=invite&amp;order=uploaded&amp;sort=<?=(($CurrentOrder == 'uploaded') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Uploaded</a></td>
  197. <td><a href="user.php?action=invite&amp;order=downloaded&amp;sort=<?=(($CurrentOrder == 'downloaded') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Downloaded</a></td>
  198. <td><a href="user.php?action=invite&amp;order=ratio&amp;sort=<?=(($CurrentOrder == 'ratio') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Ratio</a></td>
  199. </tr>
  200. <?
  201. foreach ($Invited as $User) {
  202. list($ID, $Email, $Uploaded, $Downloaded, $JoinDate, $LastAccess) = $User;
  203. $Email = apc_exists('DBKEY') ? DBCrypt::decrypt($Email) : '[Encrypted]'
  204. ?>
  205. <tr class="row">
  206. <td><?=Users::format_username($ID, true, true, true, true)?></td>
  207. <td><?=display_str($Email)?></td>
  208. <td><?=time_diff($JoinDate, 1)?></td>
  209. <td><?=time_diff($LastAccess, 1);?></td>
  210. <td><?=Format::get_size($Uploaded)?></td>
  211. <td><?=Format::get_size($Downloaded)?></td>
  212. <td><?=Format::get_ratio_html($Uploaded, $Downloaded)?></td>
  213. </tr>
  214. <? } ?>
  215. </table>
  216. </div>
  217. </div>
  218. <? View::show_footer(); ?>