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.

email_history.php 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. #declare(strict_types=1);
  3. /************************************************************************
  4. ||------------|| User email history page ||---------------------------||
  5. This page lists previous email addresses a user has used on the site. It
  6. gets called if $_GET['action'] == 'email'.
  7. It also requires $_GET['userid'] in order to get the data for the correct
  8. user.
  9. ************************************************************************/
  10. $UserID = $_GET['userid'];
  11. if (!is_number($UserID)) {
  12. error(404);
  13. }
  14. $DB->query("
  15. SELECT ui.JoinDate, p.Level AS Class
  16. FROM users_main AS um
  17. JOIN users_info AS ui ON um.ID = ui.UserID
  18. JOIN permissions AS p ON p.ID = um.PermissionID
  19. WHERE um.ID = $UserID");
  20. list($Joined, $Class) = $DB->next_record();
  21. if (!check_perms('users_view_email', $Class)) {
  22. error(403);
  23. }
  24. $UsersOnly = $_GET['usersonly'];
  25. $DB->query("
  26. SELECT Username
  27. FROM users_main
  28. WHERE ID = $UserID");
  29. list($Username)= $DB->next_record();
  30. View::show_header("Email history for $Username");
  31. if ($UsersOnly == 1) {
  32. $DB->query("
  33. SELECT
  34. u.Email,
  35. NOW() AS Time,
  36. u.IP,
  37. c.Code
  38. FROM users_main AS u
  39. LEFT JOIN users_main AS u2 ON u2.Email = u.Email AND u2.ID != '$UserID'
  40. WHERE u.ID = '$UserID'
  41. AND u2.ID > 0
  42. UNION
  43. SELECT
  44. h.Email,
  45. h.Time,
  46. h.IP,
  47. c.Code
  48. FROM users_history_emails AS h
  49. LEFT JOIN users_history_emails AS h2 ON h2.email = h.email and h2.UserID != '$UserID'
  50. WHERE h.UserID = '$UserID'
  51. AND h2.UserID > 0
  52. ORDER BY Time DESC");
  53. } else {
  54. $DB->query("
  55. SELECT
  56. u.Email,
  57. NOW() AS Time,
  58. u.IP,
  59. c.Code
  60. FROM users_main AS u
  61. WHERE u.ID = '$UserID'
  62. UNION
  63. SELECT
  64. h.Email,
  65. h.Time,
  66. h.IP,
  67. c.Code
  68. FROM users_history_emails AS h
  69. WHERE UserID = '$UserID'
  70. ORDER BY Time DESC");
  71. }
  72. $History = $DB->to_array();
  73. ?>
  74. <div class="header">
  75. <h2>Email history for <a href="user.php?id=<?=$UserID ?>"><?=$Username ?></a></h2>
  76. </div>
  77. <table width="100%">
  78. <tr class="colhead">
  79. <td>Email</td>
  80. <td>Set</td>
  81. <td>IP <a
  82. href="userhistory.php?action=ips&amp;userid=<?=$UserID ?>"
  83. class="brackets">H</a></td>
  84. <?php if ($UsersOnly == 1) {
  85. ?>
  86. <td>User</td>
  87. <?php
  88. }
  89. ?>
  90. </tr>
  91. <?php
  92. foreach ($History as $Key => $Values) {
  93. if (isset($History[$Key + 1])) {
  94. $Values['Time'] = $History[$Key + 1]['Time'];
  95. } else {
  96. $Values['Time'] = $Joined;
  97. }
  98. $ValuesIP = apcu_exists('DBKEY') ? Crypto::decrypt($Values['IP']) : '[Encrypted]'; ?>
  99. <tr class="row">
  100. <td><?=display_str($Values['Email'])?>
  101. </td>
  102. <td><?=time_diff($Values['Time'])?>
  103. </td>
  104. <td><?=display_str($ValuesIP)?> (<?=display_str($Values['Code'])?>) <a
  105. href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($ValuesIP)?>"
  106. class="brackets tooltip" title="Search">S</a></td>
  107. <?php
  108. if ($UsersOnly == 1) {
  109. $ueQuery = $DB->query("
  110. SELECT
  111. ue.UserID,
  112. um.Username,
  113. ue.Time,
  114. ue.IP
  115. FROM users_history_emails AS ue, users_main AS um
  116. WHERE ue.Email = '".db_string($Values['Email'])."'
  117. AND ue.UserID != $UserID
  118. AND um.ID = ue.UserID");
  119. while (list($UserID2, $Time, $IP) = $DB->next_record()) {
  120. $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]'; ?>
  121. </tr>
  122. <tr>
  123. <td></td>
  124. <td><?=time_diff($Time)?>
  125. </td>
  126. <td><?=display_str($IP)?>
  127. </td>
  128. <?php
  129. $UserURL = site_url()."user.php?id=$UserID2";
  130. $DB->query("
  131. SELECT Enabled
  132. FROM users_main
  133. WHERE ID = $UserID2");
  134. list($Enabled) = $DB->next_record();
  135. $DB->set_query_id($ueQuery); ?>
  136. <td><a href="<?=display_str($UserURL)?>"><?=Users::format_username($UserID2, false, false, true)?></a></td>
  137. </tr>
  138. <?php
  139. }
  140. }
  141. } ?>
  142. </table>
  143. <?php View::show_footer();