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

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