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.

sessions.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. #declare(strict_types=1);
  3. //todo: restrict to viewing below class, username in h2
  4. if (isset($_GET['userid']) && check_perms('users_view_ips') && check_perms('users_logout')) {
  5. if (!is_number($_GET['userid'])) {
  6. error(404);
  7. }
  8. $UserID = $_GET['userid'];
  9. } else {
  10. $UserID = $LoggedUser['ID'];
  11. }
  12. if (isset($_POST['all'])) {
  13. authorize();
  14. $DB->query("
  15. DELETE FROM users_sessions
  16. WHERE UserID = '$UserID'
  17. AND SessionID != '$SessionID'");
  18. $Cache->delete_value("users_sessions_$UserID");
  19. }
  20. if (isset($_POST['session'])) {
  21. authorize();
  22. $DB->query("
  23. DELETE FROM users_sessions
  24. WHERE UserID = '$UserID'
  25. AND SessionID = '".db_string($_POST['session'])."'");
  26. $Cache->delete_value("users_sessions_$UserID");
  27. }
  28. $UserSessions = $Cache->get_value('users_sessions_'.$UserID);
  29. if (!is_array($UserSessions)) {
  30. $DB->query("
  31. SELECT
  32. SessionID,
  33. Browser,
  34. OperatingSystem,
  35. IP,
  36. LastUpdate
  37. FROM users_sessions
  38. WHERE UserID = '$UserID'
  39. ORDER BY LastUpdate DESC");
  40. $UserSessions = $DB->to_array('SessionID', MYSQLI_ASSOC);
  41. $Cache->cache_value("users_sessions_$UserID", $UserSessions, 0);
  42. }
  43. list($UserID, $Username) = array_values(Users::user_info($UserID));
  44. View::show_header($Username.' &gt; Sessions');
  45. ?>
  46. <div>
  47. <h2><?=Users::format_username($UserID, $Username)?> &gt; Sessions</h2>
  48. <div class="box pad">
  49. <p>Note: Clearing cookies can result in ghost sessions which are automatically removed after 30 days.</p>
  50. </div>
  51. <div class="box">
  52. <table cellpadding="5" cellspacing="1" border="0" class="session_table" width="100%">
  53. <tr class="colhead">
  54. <td class="nobr"><strong>IP address</strong></td>
  55. <td><strong>Browser</strong></td>
  56. <td><strong>Platform</strong></td>
  57. <td class="nobr"><strong>Last activity</strong></td>
  58. <td>
  59. <form class="manage_form" name="sessions" action="" method="post">
  60. <input type="hidden" name="action" value="sessions" />
  61. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  62. <input type="hidden" name="all" value="1" />
  63. <input type="submit" value="Log out all" />
  64. </form>
  65. </td>
  66. </tr>
  67. <?
  68. foreach ($UserSessions as $Session) {
  69. list($ThisSessionID, $Browser, $OperatingSystem, $IP, $LastUpdate) = array_values($Session);
  70. $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
  71. ?>
  72. <tr class="row">
  73. <td class="nobr"><?=$IP?></td>
  74. <td><?=$Browser?></td>
  75. <td><?=$OperatingSystem?></td>
  76. <td><?=time_diff($LastUpdate)?></td>
  77. <td>
  78. <form class="delete_form" name="session" action="" method="post">
  79. <input type="hidden" name="action" value="sessions" />
  80. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  81. <input type="hidden" name="session" value="<?=$ThisSessionID?>" />
  82. <input type="submit" value="<?=(($ThisSessionID == $SessionID) ? 'Current" disabled="disabled' : 'Log out') ?>" />
  83. </form>
  84. </td>
  85. </tr>
  86. <?php } ?>
  87. </table>
  88. </div>
  89. </div>
  90. <?
  91. View::show_footer();
  92. ?>