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.

registration_log.php 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?php
  2. #declare(strict_types=1);
  3. if (!check_perms('users_view_ips') || !check_perms('users_view_email')) {
  4. error(403);
  5. }
  6. View::show_header('Registration log');
  7. define('USERS_PER_PAGE', 50);
  8. list($Page, $Limit) = Format::page_limit(USERS_PER_PAGE);
  9. $AfterDate = isset($_POST['after_date']) ? $_POST['after_date'] : null;
  10. $BeforeDate = isset($_POST['before_date']) ? $_POST['before_date'] : null;
  11. $DateSearch = false;
  12. if (!empty($AfterDate) && !empty($BeforeDate)) {
  13. list($Y, $M, $D) = explode('-', $AfterDate);
  14. if (!checkdate($M, $D, $Y)) {
  15. error('Incorrect "after" date format');
  16. }
  17. list($Y, $M, $D) = explode('-', $BeforeDate);
  18. if (!checkdate($M, $D, $Y)) {
  19. error('Incorrect "before" date format');
  20. }
  21. $AfterDate = db_string($AfterDate);
  22. $BeforeDate = db_string($BeforeDate);
  23. $DateSearch = true;
  24. }
  25. $RS = "
  26. SELECT
  27. SQL_CALC_FOUND_ROWS
  28. m.ID,
  29. m.IP,
  30. m.Email,
  31. m.Username,
  32. m.PermissionID,
  33. m.Uploaded,
  34. m.Downloaded,
  35. m.Enabled,
  36. i.Donor,
  37. i.Warned,
  38. i.JoinDate,
  39. (
  40. SELECT COUNT(h1.UserID)
  41. FROM users_history_ips AS h1
  42. WHERE h1.IP = m.IP
  43. ) AS Uses,
  44. im.ID,
  45. im.IP,
  46. im.Email,
  47. im.Username,
  48. im.PermissionID,
  49. im.Uploaded,
  50. im.Downloaded,
  51. im.Enabled,
  52. ii.Donor,
  53. ii.Warned,
  54. ii.JoinDate,
  55. (
  56. SELECT COUNT(h2.UserID)
  57. FROM users_history_ips AS h2
  58. WHERE h2.IP = im.IP
  59. ) AS InviterUses
  60. FROM users_main AS m
  61. LEFT JOIN users_info AS i ON i.UserID = m.ID
  62. LEFT JOIN users_main AS im ON i.Inviter = im.ID
  63. LEFT JOIN users_info AS ii ON i.Inviter = ii.UserID
  64. WHERE";
  65. if ($DateSearch) {
  66. $RS .= " i.JoinDate BETWEEN '$AfterDate' AND '$BeforeDate' ";
  67. } else {
  68. $RS .= " i.JoinDate > '".time_minus(3600 * 24 * 3)."'";
  69. }
  70. $RS .= "
  71. ORDER BY i.Joindate DESC
  72. LIMIT $Limit";
  73. $QueryID = $DB->query($RS);
  74. $DB->query('SELECT FOUND_ROWS()');
  75. list($Results) = $DB->next_record();
  76. $DB->set_query_id($QueryID);
  77. ?>
  78. <form action="" method="post" class="box pad">
  79. <input type="hidden" name="action" value="registration_log" />
  80. Joined after: <input type="date" name="after_date" />
  81. Joined before: <input type="date" name="before_date" />
  82. <input type="submit" />
  83. </form>
  84. <?php
  85. if ($DB->has_results()) {
  86. ?>
  87. <div class="linkbox">
  88. <?php
  89. $Pages = Format::get_pages($Page, $Results, USERS_PER_PAGE, 11) ;
  90. echo $Pages; ?>
  91. </div>
  92. <table width="100%">
  93. <tr class="colhead">
  94. <td>User</td>
  95. <td>Ratio</td>
  96. <td>Email</td>
  97. <td>IP address</td>
  98. <td>Country</td>
  99. <td>Host</td>
  100. <td>Registered</td>
  101. </tr>
  102. <?php
  103. while (list($UserID, $IP, $Email, $Username, $PermissionID, $Uploaded, $Downloaded, $Enabled, $Donor, $Warned, $Joined, $Uses, $InviterID, $InviterIP, $InviterEmail, $InviterUsername, $InviterPermissionID, $InviterUploaded, $InviterDownloaded, $InviterEnabled, $InviterDonor, $InviterWarned, $InviterJoined, $InviterUses) = $DB->next_record()) {
  104. $RowClass = $IP === $InviterIP ? 'warning' : '';
  105. $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';
  106. $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
  107. $InviterEmail = apcu_exists('DBKEY') ? Crypto::decrypt($InviterEmail) : '[Encrypted]';
  108. $InviterIP = apcu_exists('DBKEY') ? Crypto::decrypt($InviterIP) : '[Encrypted]'; ?>
  109. <tr class="<?=$RowClass?>">
  110. <td>
  111. <?=Users::format_username($UserID, true, true, true, true)?><br />
  112. <?=Users::format_username($InviterID, true, true, true, true)?>
  113. </td>
  114. <td>
  115. <?=Format::get_ratio_html($Uploaded, $Downloaded)?><br />
  116. <?=Format::get_ratio_html($InviterUploaded, $InviterDownloaded)?>
  117. </td>
  118. <td>
  119. <span class="float_left">
  120. <?=display_str($Email)?>
  121. </span>
  122. <span class="float_right">
  123. <a href="userhistory.php?action=email&amp;userid=<?=$UserID?>"
  124. title="History" class="brackets tooltip">H</a>
  125. <a href="/user.php?action=search&amp;email_history=on&amp;email=<?=display_str($Email)?>"
  126. title="Search" class="brackets tooltip">S</a>
  127. </span><br />
  128. <span class="float_left">
  129. <?=display_str($InviterEmail)?>
  130. </span>
  131. <span class="float_right">
  132. <a href="userhistory.php?action=email&amp;userid=<?=$InviterID?>"
  133. title="History" class="brackets tooltip">H</a>
  134. <a href="/user.php?action=search&amp;email_history=on&amp;email=<?=display_str($InviterEmail)?>"
  135. title="Search" class="brackets tooltip">S</a>
  136. </span><br />
  137. </td>
  138. <td>
  139. <span class="float_left">
  140. <?=display_str($IP)?>
  141. </span>
  142. <span class="float_right">
  143. <?=display_str($Uses)?>
  144. <a href="userhistory.php?action=ips&amp;userid=<?=$UserID?>"
  145. title="History" class="brackets tooltip">H</a>
  146. <a href="/user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($IP)?>"
  147. title="Search" class="brackets tooltip">S</a>
  148. <a href="http://whatismyipaddress.com/ip/<?=display_str($IP)?>"
  149. title="WI" class="brackets tooltip">WI</a>
  150. </span><br />
  151. <span class="float_left">
  152. <?=display_str($InviterIP)?>
  153. </span>
  154. <span class="float_right">
  155. <?=display_str($InviterUses)?>
  156. <a href="userhistory.php?action=ips&amp;userid=<?=$InviterID?>"
  157. title="History" class="brackets tooltip">H</a>
  158. <a href="/user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($InviterIP)?>"
  159. title="Search" class="brackets tooltip">S</a>
  160. <a href="http://whatismyipaddress.com/ip/<?=display_str($InviterIP)?>"
  161. title="WI" class="brackets tooltip">WI</a>
  162. </span><br />
  163. </td>
  164. <td>
  165. <?=Tools::get_host_by_ajax($IP)?><br />
  166. <?=Tools::get_host_by_ajax($InviterIP)?>
  167. </td>
  168. <td>
  169. <?=time_diff($Joined)?><br />
  170. <?=time_diff($InviterJoined)?>
  171. </td>
  172. </tr>
  173. <?php
  174. } ?>
  175. </table>
  176. <div class="linkbox">
  177. <?= $Pages; ?>
  178. </div>
  179. <?php
  180. } else { ?>
  181. <h2>There have been no new registrations in the past 72 hours.</h2>
  182. <?php
  183. }
  184. View::show_footer();