BioTorrents.de’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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <?php
  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)?>
  94. &gt; Invites</h2>
  95. <div class="linkbox">
  96. <a href="user.php?action=invitetree<?php if ($Sneaky) {
  97. echo '&amp;userid='.$UserID;
  98. } ?>" class="brackets">Invite tree</a>
  99. </div>
  100. </div>
  101. <?php if ($UserCount >= USER_LIMIT && !check_perms('site_can_invite_always')) { ?>
  102. <div class="box pad notice">
  103. <p>Because the user limit has been reached you are unable to send invites at this time.</p>
  104. </div>
  105. <?php }
  106. /*
  107. Users cannot send invites if they:
  108. - Are on ratio watch
  109. - Have disabled leeching
  110. - Have disabled invites
  111. - Have no invites (Unless have unlimited)
  112. - Cannot 'invite always' and the user limit is reached
  113. */
  114. $DB->query("
  115. SELECT can_leech
  116. FROM users_main
  117. WHERE ID = $UserID");
  118. list($CanLeech) = $DB->next_record();
  119. if (!$Sneaky
  120. && !$LoggedUser['RatioWatch']
  121. && $CanLeech
  122. && empty($LoggedUser['DisableInvites'])
  123. && ($LoggedUser['Invites'] > 0 || check_perms('site_send_unlimited_invites'))
  124. && ($UserCount <= USER_LIMIT || USER_LIMIT === 0 || check_perms('site_can_invite_always'))
  125. ) { ?>
  126. <div class="box pad">
  127. <p>
  128. Do not trade or sell invites under any circumstances.
  129. Do not send an invite to anyone who has previously had a <?=SITE_NAME?> account.
  130. Please direct them to <code>#disabled</code> on Slack if they wish to reactivate their account.
  131. </p>
  132. <p>
  133. 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.
  134. 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.
  135. For that reason, we stongly recommend you only invite people you personally know and trust.
  136. </p>
  137. <p><strong>Do not send an invite if you have not read or do not understand the information above.</strong></p>
  138. </div>
  139. <div class="box box2">
  140. <form class="send_form pad" name="invite" action="user.php" method="post">
  141. <input type="hidden" name="action" value="take_invite" />
  142. <input type="hidden" name="auth"
  143. value="<?=$LoggedUser['AuthKey']?>" />
  144. <div class="field_div">
  145. <div class="label"><strong>Email Address</strong></div>
  146. <div class="input">
  147. <input type="email" name="email" size="60" />
  148. <input type="submit" value="Invite" />
  149. </div>
  150. </div>
  151. <?php if (check_perms('users_invite_notes')) { ?>
  152. <div class="field_div">
  153. <div class="label"><strong>Staff Note</strong></div>
  154. <div class="input">
  155. <input type="text" name="reason" size="60" maxlength="255" />
  156. </div>
  157. </div>
  158. <?php } ?>
  159. </form>
  160. </div>
  161. <?php
  162. } elseif (!empty($LoggedUser['DisableInvites'])) { ?>
  163. <div class="box pad" style="text-align: center;">
  164. <strong class="important_text">Your invites have been disabled. Please read <a
  165. href="wiki.php?action=article&amp;name=cantinvite">this article</a> for more information.</strong>
  166. </div>
  167. <?php
  168. } elseif ($LoggedUser['RatioWatch'] || !$CanLeech) { ?>
  169. <div class="box pad" style="text-align: center;">
  170. <strong class="important_text">You may not send invites while on Ratio Watch or while your leeching privileges are
  171. disabled. Please read <a href="wiki.php?action=article&amp;name=cantinvite">this article</a> for more
  172. information.</strong>
  173. </div>
  174. <?php
  175. }
  176. if (!empty($Pending)) {
  177. ?>
  178. <h3>Pending Invites</h3>
  179. <div class="box">
  180. <table width="100%">
  181. <tr class="colhead">
  182. <td>Email Address</td>
  183. <td>Expires In</td>
  184. <td>Delete Invite</td>
  185. </tr>
  186. <?php
  187. foreach ($Pending as $Invite) {
  188. list($InviteKey, $Email, $Expires) = $Invite;
  189. $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]'; ?>
  190. <tr class="row">
  191. <td><?=display_str($Email)?>
  192. </td>
  193. <td><?=time_diff($Expires)?>
  194. </td>
  195. <td><a
  196. href="user.php?action=delete_invite&amp;invite=<?=$InviteKey?>&amp;auth=<?=$LoggedUser['AuthKey']?>"
  197. onclick="return confirm('Are you sure you want to delete this invite?');">Delete invite</a></td>
  198. </tr>
  199. <?php
  200. } ?>
  201. </table>
  202. </div>
  203. <?php
  204. }
  205. ?>
  206. <h3>Invitee List</h3>
  207. <div class="box">
  208. <table width="100%" , class="invite_table">
  209. <tr class="colhead">
  210. <td><a
  211. href="user.php?action=invite&amp;order=username&amp;sort=<?=(($CurrentOrder == 'username') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Username</a>
  212. </td>
  213. <td><a
  214. href="user.php?action=invite&amp;order=email&amp;sort=<?=(($CurrentOrder == 'email') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Email</a>
  215. </td>
  216. <td><a
  217. href="user.php?action=invite&amp;order=joined&amp;sort=<?=(($CurrentOrder == 'joined') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Joined</a>
  218. </td>
  219. <td><a
  220. href="user.php?action=invite&amp;order=lastseen&amp;sort=<?=(($CurrentOrder == 'lastseen') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Last
  221. Seen</a></td>
  222. <td><a
  223. href="user.php?action=invite&amp;order=uploaded&amp;sort=<?=(($CurrentOrder == 'uploaded') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Uploaded</a>
  224. </td>
  225. <td><a
  226. href="user.php?action=invite&amp;order=downloaded&amp;sort=<?=(($CurrentOrder == 'downloaded') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Downloaded</a>
  227. </td>
  228. <td><a
  229. href="user.php?action=invite&amp;order=ratio&amp;sort=<?=(($CurrentOrder == 'ratio') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Ratio</a>
  230. </td>
  231. </tr>
  232. <?php
  233. foreach ($Invited as $User) {
  234. list($ID, $Email, $Uploaded, $Downloaded, $JoinDate, $LastAccess) = $User;
  235. $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]'
  236. ?>
  237. <tr class="row">
  238. <td><?=Users::format_username($ID, true, true, true, true)?>
  239. </td>
  240. <td><?=display_str($Email)?>
  241. </td>
  242. <td><?=time_diff($JoinDate, 1)?>
  243. </td>
  244. <td><?=time_diff($LastAccess, 1); ?>
  245. </td>
  246. <td><?=Format::get_size($Uploaded)?>
  247. </td>
  248. <td><?=Format::get_size($Downloaded)?>
  249. </td>
  250. <td><?=Format::get_ratio_html($Uploaded, $Downloaded)?>
  251. </td>
  252. </tr>
  253. <?php
  254. } ?>
  255. </table>
  256. </div>
  257. </div>
  258. <?php View::show_footer();