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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <?php
  2. #declare(strict_types=1);
  3. $ENV = ENV::go();
  4. if (isset($_GET['userid']) && check_perms('users_view_invites')) {
  5. if (!is_number($_GET['userid'])) {
  6. error(403);
  7. }
  8. $UserID=$_GET['userid'];
  9. $Sneaky = true;
  10. } else {
  11. if (!$UserCount = $Cache->get_value('stats_user_count')) {
  12. $DB->query("
  13. SELECT COUNT(ID)
  14. FROM users_main
  15. WHERE Enabled = '1'");
  16. list($UserCount) = $DB->next_record();
  17. $Cache->cache_value('stats_user_count', $UserCount, 0);
  18. }
  19. $UserID = $LoggedUser['ID'];
  20. $Sneaky = false;
  21. }
  22. list($UserID, $Username, $PermissionID) = array_values(Users::user_info($UserID));
  23. $DB->query("
  24. SELECT InviteKey, Email, Expires
  25. FROM invites
  26. WHERE InviterID = '$UserID'
  27. ORDER BY Expires");
  28. $Pending = $DB->to_array();
  29. $OrderWays = array('username', 'email', 'joined', 'lastseen', 'uploaded', 'downloaded', 'ratio');
  30. if (empty($_GET['order'])) {
  31. $CurrentOrder = 'id';
  32. $CurrentSort = 'desc';
  33. $NewSort = 'asc';
  34. } else {
  35. if (in_array($_GET['order'], $OrderWays)) {
  36. $CurrentOrder = $_GET['order'];
  37. if ($_GET['sort'] === 'asc' || $_GET['sort'] === 'desc') {
  38. $CurrentSort = $_GET['sort'];
  39. $NewSort = ($_GET['sort'] === 'asc' ? 'desc' : 'asc');
  40. } else {
  41. error(404);
  42. }
  43. } else {
  44. error(404);
  45. }
  46. }
  47. switch ($CurrentOrder) {
  48. case 'username':
  49. $OrderBy = "um.Username";
  50. break;
  51. case 'email':
  52. $OrderBy = "um.Email";
  53. break;
  54. case 'joined':
  55. $OrderBy = "ui.JoinDate";
  56. break;
  57. case 'lastseen':
  58. $OrderBy = "um.LastAccess";
  59. break;
  60. case 'uploaded':
  61. $OrderBy = "um.Uploaded";
  62. break;
  63. case 'downloaded':
  64. $OrderBy = "um.Downloaded";
  65. break;
  66. case 'ratio':
  67. $OrderBy = "(um.Uploaded / um.Downloaded)";
  68. break;
  69. default:
  70. $OrderBy = "um.ID";
  71. break;
  72. }
  73. $CurrentURL = Format::get_url(array('action', 'order', 'sort'));
  74. $DB->query("
  75. SELECT
  76. ID,
  77. Email,
  78. Uploaded,
  79. Downloaded,
  80. JoinDate,
  81. LastAccess
  82. FROM users_main AS um
  83. LEFT JOIN users_info AS ui ON ui.UserID = um.ID
  84. WHERE ui.Inviter = '$UserID'
  85. ORDER BY $OrderBy $CurrentSort");
  86. $Invited = $DB->to_array();
  87. $JSIncludes = '';
  88. if (check_perms('users_mod') || check_perms('admin_advanced_user_search')) {
  89. $JSIncludes = 'invites';
  90. }
  91. View::show_header('Invites', $JSIncludes);
  92. ?>
  93. <div>
  94. <div class="header">
  95. <h2><?=Users::format_username($UserID, false, false, false)?>
  96. &gt; Invites</h2>
  97. <div class="linkbox">
  98. <a href="user.php?action=invitetree<?php if ($Sneaky) {
  99. echo '&amp;userid='.$UserID;
  100. } ?>" class="brackets">Invite tree</a>
  101. </div>
  102. </div>
  103. <?php if ($UserCount >= USER_LIMIT && !check_perms('site_can_invite_always')) { ?>
  104. <div class="box pad notice">
  105. <p>Because the user limit has been reached you are unable to send invites at this time.</p>
  106. </div>
  107. <?php }
  108. /*
  109. Users cannot send invites if they:
  110. - Are on ratio watch
  111. - Have disabled leeching
  112. - Have disabled invites
  113. - Have no invites (Unless have unlimited)
  114. - Cannot 'invite always' and the user limit is reached
  115. */
  116. $DB->query("
  117. SELECT can_leech
  118. FROM users_main
  119. WHERE ID = $UserID");
  120. list($CanLeech) = $DB->next_record();
  121. if (!$Sneaky
  122. && !$LoggedUser['RatioWatch']
  123. && $CanLeech
  124. && empty($LoggedUser['DisableInvites'])
  125. && ($LoggedUser['Invites'] > 0 || check_perms('site_send_unlimited_invites'))
  126. && ($UserCount <= USER_LIMIT || USER_LIMIT === 0 || check_perms('site_can_invite_always'))
  127. ) { ?>
  128. <div class="box pad">
  129. <p>
  130. Do not trade or sell invites under any circumstances.
  131. Do not send an invite to anyone who has previously had a <?= $ENV->SITE_NAME ?> account.
  132. Please direct them to <code>#disabled</code> on Slack if they wish to reactivate their account.
  133. </p>
  134. <p>
  135. You may invite anyone so long as you and they both lack malicious intent, but keep in mind that you are
  136. responsible for anyone you invite.
  137. If you invite someone you don't know well and they surprise you by breaking the rules or being a generally poor
  138. user, you will likely end up punished for it.
  139. For that reason, we stongly recommend you only invite people you personally know and trust.
  140. </p>
  141. <p><strong>Do not send an invite if you have not read or do not understand the information above.</strong></p>
  142. </div>
  143. <div class="box">
  144. <form class="send_form pad" name="invite" action="user.php" method="post">
  145. <input type="hidden" name="action" value="take_invite" />
  146. <input type="hidden" name="auth"
  147. value="<?=$LoggedUser['AuthKey']?>" />
  148. <div>
  149. <div class="label"><strong>Email Address</strong></div>
  150. <div class="input">
  151. <input type="email" name="email" size="60" />
  152. <input type="submit" value="Invite" />
  153. </div>
  154. </div>
  155. <?php if (check_perms('users_invite_notes')) { ?>
  156. <div>
  157. <div class="label"><strong>Staff Note</strong></div>
  158. <div class="input">
  159. <input type="text" name="reason" size="60" maxlength="255" />
  160. </div>
  161. </div>
  162. <?php } ?>
  163. </form>
  164. </div>
  165. <?php
  166. } elseif (!empty($LoggedUser['DisableInvites'])) { ?>
  167. <div class="box pad" style="text-align: center;">
  168. <strong class="important_text">Your invites have been disabled. Please read <a
  169. href="wiki.php?action=article&amp;name=cantinvite">this article</a> for more information.</strong>
  170. </div>
  171. <?php
  172. } elseif ($LoggedUser['RatioWatch'] || !$CanLeech) { ?>
  173. <div class="box pad" style="text-align: center;">
  174. <strong class="important_text">You may not send invites while on Ratio Watch or while your leeching privileges are
  175. disabled. Please read <a href="wiki.php?action=article&amp;name=cantinvite">this article</a> for more
  176. information.</strong>
  177. </div>
  178. <?php
  179. }
  180. if (!empty($Pending)) {
  181. ?>
  182. <h3>Pending Invites</h3>
  183. <div class="box">
  184. <table width="100%">
  185. <tr class="colhead">
  186. <td>Email Address</td>
  187. <td>Expires In</td>
  188. <td>Delete Invite</td>
  189. </tr>
  190. <?php
  191. foreach ($Pending as $Invite) {
  192. list($InviteKey, $Email, $Expires) = $Invite;
  193. $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]'; ?>
  194. <tr class="row">
  195. <td><?=display_str($Email)?>
  196. </td>
  197. <td><?=time_diff($Expires)?>
  198. </td>
  199. <td><a
  200. href="user.php?action=delete_invite&amp;invite=<?=$InviteKey?>&amp;auth=<?=$LoggedUser['AuthKey']?>"
  201. onclick="return confirm('Are you sure you want to delete this invite?');">Delete invite</a></td>
  202. </tr>
  203. <?php
  204. } ?>
  205. </table>
  206. </div>
  207. <?php
  208. }
  209. ?>
  210. <h3>Invitee List</h3>
  211. <div class="box">
  212. <table width="100%" , class="invite_table">
  213. <tr class="colhead">
  214. <td><a
  215. href="user.php?action=invite&amp;order=username&amp;sort=<?=(($CurrentOrder == 'username') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Username</a>
  216. </td>
  217. <td><a
  218. href="user.php?action=invite&amp;order=email&amp;sort=<?=(($CurrentOrder == 'email') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Email</a>
  219. </td>
  220. <td><a
  221. href="user.php?action=invite&amp;order=joined&amp;sort=<?=(($CurrentOrder == 'joined') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Joined</a>
  222. </td>
  223. <td><a
  224. href="user.php?action=invite&amp;order=lastseen&amp;sort=<?=(($CurrentOrder == 'lastseen') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Last
  225. Seen</a></td>
  226. <td><a
  227. href="user.php?action=invite&amp;order=uploaded&amp;sort=<?=(($CurrentOrder == 'uploaded') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Uploaded</a>
  228. </td>
  229. <td><a
  230. href="user.php?action=invite&amp;order=downloaded&amp;sort=<?=(($CurrentOrder == 'downloaded') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Downloaded</a>
  231. </td>
  232. <td><a
  233. href="user.php?action=invite&amp;order=ratio&amp;sort=<?=(($CurrentOrder == 'ratio') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Ratio</a>
  234. </td>
  235. </tr>
  236. <?php
  237. foreach ($Invited as $User) {
  238. list($ID, $Email, $Uploaded, $Downloaded, $JoinDate, $LastAccess) = $User;
  239. $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]'
  240. ?>
  241. <tr class="row">
  242. <td><?=Users::format_username($ID, true, true, true, true)?>
  243. </td>
  244. <td><?=display_str($Email)?>
  245. </td>
  246. <td><?=time_diff($JoinDate, 1)?>
  247. </td>
  248. <td><?=time_diff($LastAccess, 1); ?>
  249. </td>
  250. <td><?=Format::get_size($Uploaded)?>
  251. </td>
  252. <td><?=Format::get_size($Downloaded)?>
  253. </td>
  254. <td><?=Format::get_ratio_html($Uploaded, $Downloaded)?>
  255. </td>
  256. </tr>
  257. <?php
  258. } ?>
  259. </table>
  260. </div>
  261. </div>
  262. <?php View::show_footer();