Browse Source

Delete table users_history_ips, etc.

biotorrents 4 years ago
parent
commit
c05b533887

+ 0
- 38
classes/loginwatch.class.php View File

68
         return ($this->watchId = G::$DB->inserted_id());
68
         return ($this->watchId = G::$DB->inserted_id());
69
     }
69
     }
70
 
70
 
71
-    /**
72
-     * Record another failure attempt on this watch. If the user has not
73
-     * logged in recently from this IP address then subsequent logins
74
-     * will be blocked for increasingly longer times, otherwise 1 minute.
75
-     *
76
-     * @param int $userId The ID of the user
77
-     * @param string $ipaddr The IP the user is coming from
78
-     * @param string $capture The username captured on the form
79
-     * @return int 1 if the watch was updated
80
-     */
81
-    public function increment(int $userId, string $ipaddr, ?string $capture): int
82
-    {
83
-        $seen = G::$DB->query("
84
-        SELECT
85
-          1
86
-        FROM
87
-          `users_history_ips`
88
-        WHERE
89
-          (
90
-            `EndTime` IS NULL
91
-            OR `EndTime` > NOW() - INTERVAL 1 WEEK
92
-          )
93
-          AND `UserID` = '$userId'
94
-          AND `IP` = '$ipaddr'
95
-        ");
96
-
97
-        $delay = $seen ? 60 : LOGIN_ATTEMPT_BACKOFF[min($this->nrAttempts(), count(LOGIN_ATTEMPT_BACKOFF)-1)];
98
-        G::$DB->prepare_query("
99
-            UPDATE `login_attempts` SET
100
-                `Attempts` = `Attempts` + 1,
101
-                `LastAttempt` = now(),
102
-                `BannedUntil` = now() + INTERVAL '$delay' SECOND,
103
-                `UserID` = '$userId',
104
-                `Capture` ='$capture' 
105
-            WHERE `ID` = '$this->watchId' 
106
-            ");
107
-        return G::$DB->affected_rows();
108
-    }
109
 
71
 
110
     /**
72
     /**
111
      * Ban subsequent attempts to login from this watched IP address for 6 hours
73
      * Ban subsequent attempts to login from this watched IP address for 6 hours

+ 0
- 2
classes/permissions_form.php View File

39
   'site_recommend_own' => 'Can recommend own torrents.',
39
   'site_recommend_own' => 'Can recommend own torrents.',
40
   'site_manage_recommendations' => 'Recommendations management access.',
40
   'site_manage_recommendations' => 'Recommendations management access.',
41
   'site_delete_tag' => 'Can delete tags.',
41
   'site_delete_tag' => 'Can delete tags.',
42
-  'site_disable_ip_history' => 'Disable IP history.',
43
   'zip_downloader' => 'Download multiple torrents at once.',
42
   'zip_downloader' => 'Download multiple torrents at once.',
44
   'site_debug' => 'Developer access.',
43
   'site_debug' => 'Developer access.',
45
   'site_proxy_images' => 'Image proxy & anti-canary.',
44
   'site_proxy_images' => 'Image proxy & anti-canary.',
154
     display_perm('site_recommend_own', 'Can add own torrents to recommendations list.');
153
     display_perm('site_recommend_own', 'Can add own torrents to recommendations list.');
155
     display_perm('site_manage_recommendations', 'Can edit recommendations list.');
154
     display_perm('site_manage_recommendations', 'Can edit recommendations list.');
156
     display_perm('site_delete_tag', 'Can delete tags.');
155
     display_perm('site_delete_tag', 'Can delete tags.');
157
-    display_perm('site_disable_ip_history', 'Disable IP history.');
158
     display_perm('zip_downloader', 'Download multiple torrents at once.');
156
     display_perm('zip_downloader', 'Download multiple torrents at once.');
159
     display_perm('site_debug', 'View site debug tables.');
157
     display_perm('site_debug', 'View site debug tables.');
160
     display_perm('site_proxy_images', 'Proxy images through the server.');
158
     display_perm('site_proxy_images', 'Proxy images through the server.');

+ 1
- 32
classes/script_start.php View File

319
     // Change necessary triggers in external components
319
     // Change necessary triggers in external components
320
     $Cache->CanClear = check_perms('admin_clear_cache');
320
     $Cache->CanClear = check_perms('admin_clear_cache');
321
 
321
 
322
-    // Because we <3 our staff
323
-    if (check_perms('site_disable_ip_history')) {
324
-        $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
325
-    }
326
-
327
     // Update LastUpdate every 10 minutes
322
     // Update LastUpdate every 10 minutes
328
     if (strtotime($UserSessions[$SessionID]['LastUpdate']) + 600 < time()) {
323
     if (strtotime($UserSessions[$SessionID]['LastUpdate']) + 600 < time()) {
329
         $DB->query("
324
         $DB->query("
383
     }
378
     }
384
 
379
 
385
     // IP changed
380
     // IP changed
386
-    if (apcu_exists('DBKEY') && Crypto::decrypt($LoggedUser['IP']) != $_SERVER['REMOTE_ADDR'] && !check_perms('site_disable_ip_history')) {
381
+    if (apcu_exists('DBKEY') && Crypto::decrypt($LoggedUser['IP']) != $_SERVER['REMOTE_ADDR']) {
387
         if (Tools::site_ban_ip($_SERVER['REMOTE_ADDR'])) {
382
         if (Tools::site_ban_ip($_SERVER['REMOTE_ADDR'])) {
388
             error('Your IP address has been banned.');
383
             error('Your IP address has been banned.');
389
         }
384
         }
390
 
385
 
391
         $CurIP = db_string($LoggedUser['IP']);
386
         $CurIP = db_string($LoggedUser['IP']);
392
         $NewIP = db_string($_SERVER['REMOTE_ADDR']);
387
         $NewIP = db_string($_SERVER['REMOTE_ADDR']);
393
-        $DB->query("
394
-        SELECT IP
395
-        FROM users_history_ips
396
-          WHERE EndTime IS NULL
397
-          AND UserID = '$LoggedUser[ID]'");
398
-
399
-        while (list($EncIP) = $DB->next_record()) {
400
-            if (Crypto::decrypt($EncIP) == $CurIP) {
401
-                $CurIP = $EncIP;
402
-                // CurIP is now the encrypted IP that was already in the database (for matching)
403
-                break;
404
-            }
405
-        }
406
-
407
-        $DB->query("
408
-        UPDATE users_history_ips
409
-        SET EndTime = NOW()
410
-          WHERE EndTime IS NULL
411
-          AND UserID = '$LoggedUser[ID]'
412
-          AND IP = '$CurIP'");
413
-
414
-        $DB->query("
415
-        INSERT IGNORE INTO users_history_ips
416
-          (UserID, IP, StartTime)
417
-        VALUES
418
-          ('$LoggedUser[ID]', '".Crypto::encrypt($NewIP)."', NOW())");
419
 
388
 
420
         $Cache->begin_transaction('user_info_heavy_'.$LoggedUser['ID']);
389
         $Cache->begin_transaction('user_info_heavy_'.$LoggedUser['ID']);
421
         $Cache->update_row(false, array('IP' => Crypto::encrypt($_SERVER['REMOTE_ADDR'])));
390
         $Cache->update_row(false, array('IP' => Crypto::encrypt($_SERVER['REMOTE_ADDR'])));

+ 1
- 12
classes/tools.class.php View File

122
         return trim($Output[4]);
122
         return trim($Output[4]);
123
     }
123
     }
124
 
124
 
125
-    /**
126
-     * Format an IP address with links to IP history.
127
-     *
128
-     * @param string IP
129
-     * @return string The HTML
130
-     */
131
-    public static function display_ip($IP)
132
-    {
133
-        return $Line = '<a href="user.php?action=search&amp;ip_history=on&amp;ip='.display_str($IP).'&amp;matchtype=strict" title="Search" class="brackets tooltip">S</a>';
134
-    }
135
-
136
-
125
+    
137
     /**
126
     /**
138
      * Disable an array of users.
127
      * Disable an array of users.
139
      *
128
      *

+ 0
- 13
gazelle.sql View File

1409
 ) ENGINE=InnoDB CHARSET=utf8mb4;
1409
 ) ENGINE=InnoDB CHARSET=utf8mb4;
1410
 
1410
 
1411
 
1411
 
1412
-CREATE TABLE `users_history_ips` (
1413
-  `UserID` int NOT NULL,
1414
-  `IP` varchar(90) NOT NULL DEFAULT '0.0.0.0',
1415
-  `StartTime` datetime,
1416
-  `EndTime` datetime DEFAULT NULL,
1417
-  PRIMARY KEY (`UserID`,`IP`,`StartTime`),
1418
-  KEY `UserID` (`UserID`),
1419
-  KEY `IP` (`IP`),
1420
-  KEY `StartTime` (`StartTime`),
1421
-  KEY `EndTime` (`EndTime`)
1422
-) ENGINE=InnoDB CHARSET=utf8mb4;
1423
-
1424
-
1425
 CREATE TABLE `users_history_passkeys` (
1412
 CREATE TABLE `users_history_passkeys` (
1426
   `UserID` int NOT NULL,
1413
   `UserID` int NOT NULL,
1427
   `OldPassKey` varchar(32) DEFAULT NULL,
1414
   `OldPassKey` varchar(32) DEFAULT NULL,

+ 0
- 61
sections/login/index.php View File

286
                         # todo: Make sure the type is (int)
286
                         # todo: Make sure the type is (int)
287
                         if ($Enabled === '1') {
287
                         if ($Enabled === '1') {
288
 
288
 
289
-                            // Check if the current login attempt is from a location previously logged in from
290
-                            if (apcu_exists('DBKEY')) {
291
-                                $DB->query("
292
-                                SELECT
293
-                                  `IP`
294
-                                FROM
295
-                                  `users_history_ips`
296
-                                WHERE
297
-                                  `UserID` = '$UserID'
298
-                                ");
299
-
300
-                                $IPs = $DB->to_array(false, MYSQLI_NUM);
301
-                                $QueryParts = [];
302
-
303
-                                foreach ($IPs as $i => $IP) {
304
-                                    $IPs[$i] = Crypto::decrypt($IP[0]);
305
-                                }
306
-
307
-                                $IPs = array_unique($IPs);
308
-                                if (count($IPs) > 0) { // Always allow first login
309
-                                    foreach ($IPs as $IP) {
310
-                                        $QueryParts[] = "(StartIP<=INET6_ATON('$IP') AND EndIP>=INET6_ATON('$IP'))";
311
-                                    }
312
-
313
-                                    $DB->query('SELECT ASN FROM geoip_asn WHERE '.implode(' OR ', $QueryParts));
314
-                                    $PastASNs = array_column($DB->to_array(false, MYSQLI_NUM), 0);
315
-                                    $DB->query("SELECT ASN FROM geoip_asn WHERE StartIP<=INET6_ATON('$_SERVER[REMOTE_ADDR]') AND EndIP>=INET6_ATON('$_SERVER[REMOTE_ADDR]')");
316
-                                    list($CurrentASN) = $DB->next_record();
317
-
318
-                                    // If FEATURE_ENFORCE_LOCATIONS is enabled, require users to confirm new logins
319
-                                    if (!in_array($CurrentASN, $PastASNs) && $ENV->FEATURE_ENFORCE_LOCATIONS) {
320
-                                        // Never logged in from this location before
321
-                                        if ($Cache->get_value('new_location_'.$UserID.'_'.$CurrentASN) !== true) {
322
-                                            $DB->query("
323
-                                            SELECT
324
-                                              `UserName`,
325
-                                              `Email`
326
-                                            FROM
327
-                                              `users_main`
328
-                                            WHERE
329
-                                              `ID` = '$UserID'
330
-                                            ");
331
-                                            
332
-                                            list($Username, $Email) = $DB->next_record();
333
-                                            Users::auth_location($UserID, $Username, $CurrentASN, Crypto::decrypt($Email));
334
-                                            require('newlocation.php');
335
-                                            error();
336
-                                        }
337
-                                    }
338
-                                }
339
-                            }
340
-
341
                             $U2FRegs = [];
289
                             $U2FRegs = [];
342
                             $DB->query("
290
                             $DB->query("
343
                             SELECT KeyHandle, PublicKey, Certificate, Counter, Valid
291
                             SELECT KeyHandle, PublicKey, Certificate, Counter, Valid
392
                                 setcookie('session', $SessionID, (time()+60*60*24*365), '/', '', true, true);
340
                                 setcookie('session', $SessionID, (time()+60*60*24*365), '/', '', true, true);
393
                                 setcookie('userid', $UserID, (time()+60*60*24*365), '/', '', true, true);
341
                                 setcookie('userid', $UserID, (time()+60*60*24*365), '/', '', true, true);
394
 
342
 
395
-                                // Because we <3 our staff
396
-                                $Permissions = Permissions::get_permissions($PermissionID);
397
-                                $CustomPermissions = unserialize($CustomPermissions);
398
-                                if (isset($Permissions['Permissions']['site_disable_ip_history'])
399
-                                 || isset($CustomPermissions['site_disable_ip_history'])
400
-                ) {
401
-                                    $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
402
-                                }
403
-
404
                                 $DB->query("
343
                                 $DB->query("
405
                                 INSERT INTO users_sessions
344
                                 INSERT INTO users_sessions
406
                                   (UserID, SessionID, KeepLogged, Browser, OperatingSystem, IP, LastUpdate, FullUA)
345
                                   (UserID, SessionID, KeepLogged, Browser, OperatingSystem, IP, LastUpdate, FullUA)

+ 0
- 25
sections/login/newlocation.php View File

1
-<?
2
-if (!empty($LoggedUser['ID'])) {
3
-  header('Location: login.php');
4
-  error();
5
-}
6
-
7
-View::show_header('Authorize Location');
8
-
9
-if (isset($_REQUEST['act'])) {
10
-?>
11
-
12
-Your location is now authorized to access this account.<br><br>
13
-Click <a href="login.php">here</a> to login again.
14
-
15
-<? } else { ?>
16
-
17
-This appears to be the first time you've logged in from this location.<br><br>
18
-
19
-As a security measure to ensure that you are really the owner of this account,<br>
20
-an email has been sent to the address in your profile settings. Please<br>
21
-click the link contained in that email to allow access from<br>
22
-your location, and then log in again.
23
-
24
-<? }
25
-View::show_footer(); ?>

+ 0
- 5
sections/register/index.php View File

153
         VALUES
153
         VALUES
154
           ('$UserID', '$StyleID', '".db_string($AuthKey)."', '$InviterID', NOW(), '$InviteReason')");
154
           ('$UserID', '$StyleID', '".db_string($AuthKey)."', '$InviterID', NOW(), '$InviteReason')");
155
 
155
 
156
-            $DB->query("
157
-        INSERT INTO users_history_ips
158
-          (UserID, IP, StartTime)
159
-        VALUES
160
-          ('$UserID', '".Crypto::encrypt($_SERVER['REMOTE_ADDR'])."', NOW())");
161
             $DB->query("
156
             $DB->query("
162
         INSERT INTO users_notifications_settings
157
         INSERT INTO users_notifications_settings
163
           (UserID)
158
           (UserID)

+ 1
- 1
sections/tools/data/invite_pool.php View File

116
     </td>
116
     </td>
117
 
117
 
118
     <td>
118
     <td>
119
-      <?=Tools::display_ip($IP)?>
119
+      <?=display_str($IP)?>
120
     </td>
120
     </td>
121
 
121
 
122
     <td>
122
     <td>

+ 1
- 31
sections/tools/data/registration_log.php View File

43
     i.Donor,
43
     i.Donor,
44
     i.Warned,
44
     i.Warned,
45
     i.JoinDate,
45
     i.JoinDate,
46
-    (
47
-      SELECT COUNT(h1.UserID)
48
-      FROM users_history_ips AS h1
49
-      WHERE h1.IP = m.IP
50
-    ) AS Uses,
51
     im.ID,
46
     im.ID,
52
     im.IP,
47
     im.IP,
53
     im.Email,
48
     im.Email,
59
     ii.Donor,
54
     ii.Donor,
60
     ii.Warned,
55
     ii.Warned,
61
     ii.JoinDate,
56
     ii.JoinDate,
62
-    (
63
-      SELECT COUNT(h2.UserID)
64
-      FROM users_history_ips AS h2
65
-      WHERE h2.IP = im.IP
66
-    ) AS InviterUses
67
   FROM users_main AS m
57
   FROM users_main AS m
68
     LEFT JOIN users_info AS i ON i.UserID = m.ID
58
     LEFT JOIN users_info AS i ON i.UserID = m.ID
69
     LEFT JOIN users_main AS im ON i.Inviter = im.ID
59
     LEFT JOIN users_main AS im ON i.Inviter = im.ID
114
   </tr>
104
   </tr>
115
 
105
 
116
   <?php
106
   <?php
117
-  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()) {
107
+  while (list($UserID, $IP, $Email, $Username, $PermissionID, $Uploaded, $Downloaded, $Enabled, $Donor, $Warned, $Joined, $InviterID, $InviterIP, $InviterEmail, $InviterUsername, $InviterPermissionID, $InviterUploaded, $InviterDownloaded, $InviterEnabled, $InviterDonor, $InviterWarned, $InviterJoined) = $DB->next_record()) {
118
       $RowClass = $IP === $InviterIP ? 'warning' : '';
108
       $RowClass = $IP === $InviterIP ? 'warning' : '';
119
       $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';
109
       $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';
120
       $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
110
       $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
148
         <?=display_str($IP)?>
138
         <?=display_str($IP)?>
149
       </span>
139
       </span>
150
 
140
 
151
-      <span class="float_right">
152
-        <?=display_str($Uses)?>
153
-        <a href="userhistory.php?action=ips&amp;userid=<?=$UserID?>"
154
-          title="History" class="brackets tooltip">H</a>
155
-        <a href="/user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($IP)?>"
156
-          title="Search" class="brackets tooltip">S</a>
157
-        <a href="http://whatismyipaddress.com/ip/<?=display_str($IP)?>"
158
-          title="WI" class="brackets tooltip">WI</a>
159
-      </span><br />
160
-
161
       <span class="float_left">
141
       <span class="float_left">
162
         <?=display_str($InviterIP)?>
142
         <?=display_str($InviterIP)?>
163
       </span>
143
       </span>
164
-
165
-      <span class="float_right">
166
-        <?=display_str($InviterUses)?>
167
-        <a href="userhistory.php?action=ips&amp;userid=<?=$InviterID?>"
168
-          title="History" class="brackets tooltip">H</a>
169
-        <a href="/user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($InviterIP)?>"
170
-          title="Search" class="brackets tooltip">S</a>
171
-        <a href="http://whatismyipaddress.com/ip/<?=display_str($InviterIP)?>"
172
-          title="WI" class="brackets tooltip">WI</a>
173
-      </span><br />
174
     </td>
144
     </td>
175
 
145
 
176
     <td>
146
     <td>

+ 0
- 4
sections/tools/index.php View File

413
   // END Data
413
   // END Data
414
 
414
 
415
   // Misc
415
   // Misc
416
-  case 'dupe_ips':
417
-    include SERVER_ROOT.'/sections/tools/misc/dupe_ip.php';
418
-    break;
419
-
420
   case 'clear_cache':
416
   case 'clear_cache':
421
     include SERVER_ROOT.'/sections/tools/development/clear_cache.php';
417
     include SERVER_ROOT.'/sections/tools/development/clear_cache.php';
422
     break;
418
     break;

+ 0
- 6
sections/tools/managers/enable_requests.php View File

47
     case 'perfect':
47
     case 'perfect':
48
         $Where[] = "um.`Email` = uer.`Email`";
48
         $Where[] = "um.`Email` = uer.`Email`";
49
         $Joins[] = "JOIN `users_main` um ON um.`ID` = uer.`UserID`";
49
         $Joins[] = "JOIN `users_main` um ON um.`ID` = uer.`UserID`";
50
-        $Where[] = "uer.`IP` = (SELECT `IP` FROM `users_history_ips` uhi1 WHERE uhi1.`StartTime` = (SELECT MAX(`StartTime`) FROM `users_history_ips` uhi2 WHERE uhi2.`UserID` = uer.`UserID` ORDER BY `StartTime` DESC LIMIT 1))";
51
-        $Where[] = "(SELECT 1 FROM `users_history_ips` uhi WHERE uhi.`IP` = uer.`IP` AND uhi.`UserID` != uer.`UserID`) IS NULL";
52
         $Where[] = "ui.`BanReason` = '3'";
50
         $Where[] = "ui.`BanReason` = '3'";
53
         break;
51
         break;
54
 
52
 
63
         $Where[] = "um.`Email` != uer.`Email`";
61
         $Where[] = "um.`Email` != uer.`Email`";
64
         break;
62
         break;
65
 
63
 
66
-    case 'ip_overlap':
67
-        $Joins[] = "JOIN `users_history_ips` uhi ON uhi.`IP` = uer.`IP` AND uhi.`UserID` != uer.`UserID`";
68
-        break;
69
-
70
     case 'manual_disable':
64
     case 'manual_disable':
71
         $Where[] = "ui.`BanReason` != '3'";
65
         $Where[] = "ui.`BanReason` != '3'";
72
         break;
66
         break;

+ 0
- 81
sections/tools/misc/dupe_ip.php View File

1
-<?php
2
-if (!check_perms('users_view_ips')) {
3
-  error(403);
4
-}
5
-View::show_header('Dupe IPs');
6
-define('USERS_PER_PAGE', 50);
7
-define('IP_OVERLAPS', 2);
8
-list($Page, $Limit) = Format::page_limit(USERS_PER_PAGE);
9
-
10
-
11
-$RS = $DB->query("
12
-    SELECT
13
-      SQL_CALC_FOUND_ROWS
14
-      m.ID,
15
-      m.IP,
16
-      m.Username,
17
-      m.PermissionID,
18
-      m.Enabled,
19
-      i.Donor,
20
-      i.Warned,
21
-      i.JoinDate,
22
-      (
23
-        SELECT COUNT(DISTINCT h.UserID)
24
-        FROM users_history_ips AS h
25
-        WHERE h.IP = m.IP
26
-      ) AS Uses
27
-    FROM users_main AS m
28
-      LEFT JOIN users_info AS i ON i.UserID = m.ID
29
-    WHERE
30
-      (
31
-        SELECT COUNT(DISTINCT h.UserID)
32
-        FROM users_history_ips AS h
33
-        WHERE h.IP = m.IP
34
-      ) >= ".IP_OVERLAPS."
35
-      AND m.Enabled = '1'
36
-      AND m.IP != '127.0.0.1'
37
-    ORDER BY Uses DESC
38
-    LIMIT $Limit");
39
-$DB->query('SELECT FOUND_ROWS()');
40
-list($Results) = $DB->next_record();
41
-$DB->set_query_id($RS);
42
-
43
-if ($DB->has_results()) {
44
-?>
45
-  <div class="linkbox">
46
-<?
47
-  $Pages = Format::get_pages($Page, $Results, USERS_PER_PAGE, 11);
48
-  echo $Pages;
49
-?>
50
-  </div>
51
-  <table width="100%">
52
-    <tr class="colhead">
53
-      <td>User</td>
54
-      <td>IP address</td>
55
-      <td>Dupes</td>
56
-      <td>Registered</td>
57
-    </tr>
58
-<?
59
-  $Row = 'b';
60
-  while (list($UserID, $IP, $Username, $PermissionID, $Enabled, $Donor, $Warned, $Joined, $Uses) = $DB->next_record()) {
61
-  $Row = $Row === 'b' ? 'a' : 'b';
62
-?>
63
-    <tr class="row<?=$Row?>">
64
-      <td><?=Users::format_username($UserID, true, true, true, true)?></td>
65
-      <td>
66
-        <span class="float_left"><?=Tools::get_host_by_ajax($IP)." ($IP)"?></span><span class="float_right"><a href="userhistory.php?action=ips&amp;userid=<?=$UserID?>" title="History" class="brackets tooltip">H</a> <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($IP)?>" title="Search" class="brackets tooltip">S</a></span>
67
-      </td>
68
-      <td><?=display_str($Uses)?></td>
69
-      <td><?=time_diff($Joined)?></td>
70
-    </tr>
71
-<?php } ?>
72
-  </table>
73
-  <div class="linkbox">
74
-<?= $Pages; ?>
75
-  </div>
76
-<?php } else { ?>
77
-  <h2>There are currently no users with more than <?=IP_OVERLAPS?> IP overlaps.</h2>
78
-<?
79
-  }
80
-View::show_footer();
81
-?>

+ 0
- 1
sections/tools/tools.php View File

144
   $ToolsHTML = "";
144
   $ToolsHTML = "";
145
   create_row("Email blacklist", "tools.php?action=email_blacklist", check_perms("users_view_email"));
145
   create_row("Email blacklist", "tools.php?action=email_blacklist", check_perms("users_view_email"));
146
   create_row("IP address bans", "tools.php?action=ip_ban", check_perms("admin_manage_ipbans"));
146
   create_row("IP address bans", "tools.php?action=ip_ban", check_perms("admin_manage_ipbans"));
147
-  create_row("Duplicate IP addresses", "tools.php?action=dupe_ips", check_perms("users_view_ips"));
148
   create_row("Manipulate invite tree", "tools.php?action=manipulate_tree", check_perms("users_mod"));
147
   create_row("Manipulate invite tree", "tools.php?action=manipulate_tree", check_perms("users_mod"));
149
 
148
 
150
   if ($ToolsHTML) {
149
   if ($ToolsHTML) {

+ 0
- 29
sections/user/advancedsearch.php View File

262
         }
262
         }
263
 
263
 
264
         if (!empty($_GET['ip'])) {
264
         if (!empty($_GET['ip'])) {
265
-            if (isset($_GET['ip_history'])) {
266
-                $Distinct = 'DISTINCT ';
267
-            }
268
             $Join['tip'] = ' JOIN users_ips_decrypted AS tip ON tip.ID = um1.ID ';
265
             $Join['tip'] = ' JOIN users_ips_decrypted AS tip ON tip.ID = um1.ID ';
269
             $Where[] = ' tip.IP '.$Match.wrap($_GET['ip'], '', true);
266
             $Where[] = ' tip.IP '.$Match.wrap($_GET['ip'], '', true);
270
         }
267
         }
386
 
383
 
387
         if ($_GET['disabled_ip']) {
384
         if ($_GET['disabled_ip']) {
388
             $Distinct = 'DISTINCT ';
385
             $Distinct = 'DISTINCT ';
389
-            if ($_GET['ip_history']) {
390
-                if (!isset($Join['tip'])) {
391
-                    $Join['tip'] = ' JOIN users_ips_decrypted AS tip ON tip.ID = um1.ID ';
392
-                }
393
-                $Join['tip2'] = ' JOIN users_ips_decrypted2 AS tip2 ON tip2.IP = tip.IP ';
394
-                $Join['um2'] = ' JOIN users_main AS um2 ON um2.ID = tip2.ID AND um2.Enabled = \'2\' ';
395
-            } else {
396
                 $Join['um2'] = ' JOIN users_main AS um2 ON um2.IP = um1.IP AND um2.Enabled = \'2\' ';
386
                 $Join['um2'] = ' JOIN users_main AS um2 ON um2.IP = um1.IP AND um2.Enabled = \'2\' ';
397
-            }
398
         }
387
         }
399
 
388
 
400
         if (!empty($_GET['passkey'])) {
389
         if (!empty($_GET['passkey'])) {
619
         </td>
608
         </td>
620
       </tr>
609
       </tr>
621
       <tr>
610
       <tr>
622
-        <td class="label nobr">Extra:</td>
623
-        <td>
624
-          <ul class="options_list nobullet">
625
-            <li>
626
-              <input type="checkbox" name="ip_history" id="ip_history" <?php if ($_GET['ip_history']) {
627
-      echo ' checked="checked"' ;
628
-  } ?> />
629
-              <label for="ip_history">IP history</label>
630
-            </li>
631
-          </ul>
632
-        </td>
633
         <td class="label nobr">Ratio:</td>
611
         <td class="label nobr">Ratio:</td>
634
         <td width="30%">
612
         <td width="30%">
635
           <select name="ratio">
613
           <select name="ratio">
1013
 <?php
991
 <?php
1014
 if ($RunQuery) {
992
 if ($RunQuery) {
1015
                 if (!empty($_GET['ip'])) {
993
                 if (!empty($_GET['ip'])) {
1016
-                    if (isset($_GET['ip_history'])) {
1017
-                        $DB->query("SELECT UserID, IP FROM users_history_ips");
1018
-                    } else {
1019
                         $DB->query("SELECT ID, IP FROM users_main");
994
                         $DB->query("SELECT ID, IP FROM users_main");
1020
-                    }
1021
                     while (list($ID, $EncIP) = $DB->next_record()) {
995
                     while (list($ID, $EncIP) = $DB->next_record()) {
1022
                         $IPs[] = $ID.", '".Crypto::decrypt($EncIP)."'";
996
                         $IPs[] = $ID.", '".Crypto::decrypt($EncIP)."'";
1023
                     }
997
                     }
1024
                     $DB->query("CREATE TEMPORARY TABLE users_ips_decrypted (ID INT(10) UNSIGNED NOT NULL, IP VARCHAR(45) NOT NULL, PRIMARY KEY (ID,IP)) ENGINE=MEMORY");
998
                     $DB->query("CREATE TEMPORARY TABLE users_ips_decrypted (ID INT(10) UNSIGNED NOT NULL, IP VARCHAR(45) NOT NULL, PRIMARY KEY (ID,IP)) ENGINE=MEMORY");
1025
                     $DB->query("INSERT IGNORE INTO users_ips_decrypted (ID, IP) VALUES(".implode("),(", $IPs).")");
999
                     $DB->query("INSERT IGNORE INTO users_ips_decrypted (ID, IP) VALUES(".implode("),(", $IPs).")");
1026
-                    if ($_GET['disabled_ip'] && $_GET['ip_history']) {
1027
-                        $DB->query("CREATE TEMPORARY TABLE users_ips_decrypted2 SELECT * FROM users_ips_decrypted");
1028
-                    }
1029
                 }
1000
                 }
1030
                 if (!empty($_GET['email'])) {
1001
                 if (!empty($_GET['email'])) {
1031
                         $DB->query("SELECT ID, Email FROM users_main");
1002
                         $DB->query("SELECT ID, Email FROM users_main");

+ 0
- 32
sections/user/takemoderate.php View File

237
     $EditSummary[] = 'RatioWatch history reset';
237
     $EditSummary[] = 'RatioWatch history reset';
238
 }
238
 }
239
 
239
 
240
-if ($_POST['ResetIPHistory'] && check_perms('users_edit_reset_keys')) {
241
-    $GenericIP = Crypto::encrypt('127.0.0.1');
242
-    $DB->query("
243
-      DELETE FROM users_history_ips
244
-      WHERE UserID = '$UserID'");
245
-
246
-    $DB->query("
247
-      UPDATE users_main
248
-      SET IP = '$GenericIP'
249
-      WHERE ID = '$UserID'");
250
-
251
-    $DB->query("
252
-      UPDATE xbt_snatched
253
-      SET IP = ''
254
-      WHERE uid = '$UserID'");
255
-
256
-    $DB->query("
257
-      UPDATE users_history_passwords
258
-      SET ChangerIP = ''
259
-      WHERE UserID = $UserID");
260
-
261
-    $DB->query("
262
-      UPDATE users_history_passkeys
263
-      SET ChangerIP = ''
264
-      WHERE UserID = $UserID");
265
-
266
-    $DB->query("
267
-      UPDATE users_sessions
268
-      SET IP = '$GenericIP'
269
-      WHERE UserID = $UserID");
270
-}
271
-
272
 if ($_POST['ResetSnatchList'] && check_perms('users_edit_reset_keys')) {
240
 if ($_POST['ResetSnatchList'] && check_perms('users_edit_reset_keys')) {
273
     $DB->query("
241
     $DB->query("
274
       DELETE FROM xbt_snatched
242
       DELETE FROM xbt_snatched

+ 1
- 19
sections/user/user.php View File

273
       class="brackets">Settings</a>
273
       class="brackets">Settings</a>
274
     <?php
274
     <?php
275
 }
275
 }
276
-if ($LoggedUser['ID'] == $UserID) {
277
-    ?>
278
-    <a href="userhistory.php?action=userip&userid=<?=$UserID?>"
279
-      class="brackets">IP History</a>
280
-    <?php
281
-}
282
 if (check_perms('users_view_invites', $Class)) {
276
 if (check_perms('users_view_invites', $Class)) {
283
     ?>
277
     ?>
284
     <a href="user.php?action=invite&amp;userid=<?=$UserID?>"
278
     <a href="user.php?action=invite&amp;userid=<?=$UserID?>"
579
       if (check_perms('users_view_ips', $Class)) {
573
       if (check_perms('users_view_ips', $Class)) {
580
           $DB->query("
574
           $DB->query("
581
         SELECT COUNT(DISTINCT IP)
575
         SELECT COUNT(DISTINCT IP)
582
-        FROM users_history_ips
583
-        WHERE UserID = '$UserID'");
584
-          list($IPChanges) = $DB->next_record();
585
-          $DB->query("
586
-        SELECT COUNT(DISTINCT IP)
587
         FROM xbt_snatched
576
         FROM xbt_snatched
588
         WHERE uid = '$UserID'
577
         WHERE uid = '$UserID'
589
           AND IP != ''");
578
           AND IP != ''");
596
         <?php
585
         <?php
597
       if (check_perms('users_view_ips', $Class)) {
586
       if (check_perms('users_view_ips', $Class)) {
598
           ?>
587
           ?>
599
-        <li>IPs: <?=number_format($IPChanges)?> <a
600
-            href="userhistory.php?action=ips&amp;userid=<?=$UserID?>"
601
-            class="brackets">View</a>&nbsp;<a
602
-            href="userhistory.php?action=ips&amp;userid=<?=$UserID?>&amp;usersonly=1"
603
-            class="brackets">View users</a></li>
604
         <?php if (check_perms('users_view_ips', $Class) && check_perms('users_mod', $Class)) { ?>
588
         <?php if (check_perms('users_view_ips', $Class) && check_perms('users_mod', $Class)) { ?>
605
         <li>Tracker IPs: <?=number_format($TrackerIPs)?> <a
589
         <li>Tracker IPs: <?=number_format($TrackerIPs)?> <a
606
             href="userhistory.php?action=tracker_ips&amp;userid=<?=$UserID?>"
590
             href="userhistory.php?action=tracker_ips&amp;userid=<?=$UserID?>"
673
 
657
 
674
 if (check_perms('users_view_ips', $Class)) {
658
 if (check_perms('users_view_ips', $Class)) {
675
     $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]'; ?>
659
     $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]'; ?>
676
-        <li>IP: <?=Tools::display_ip($IP)?>
660
+        <li>IP: <?=display_str($IP)?>
677
         </li>
661
         </li>
678
         <li>Host: <?=Tools::get_host_by_ajax($IP)?>
662
         <li>Host: <?=Tools::get_host_by_ajax($IP)?>
679
         </li>
663
         </li>
1442
             watch</label> |
1426
             watch</label> |
1443
           <input type="checkbox" name="ResetPasskey" id="ResetPasskey" /> <label for="ResetPasskey">Passkey</label> |
1427
           <input type="checkbox" name="ResetPasskey" id="ResetPasskey" /> <label for="ResetPasskey">Passkey</label> |
1444
           <input type="checkbox" name="ResetAuthkey" id="ResetAuthkey" /> <label for="ResetAuthkey">Authkey</label> |
1428
           <input type="checkbox" name="ResetAuthkey" id="ResetAuthkey" /> <label for="ResetAuthkey">Authkey</label> |
1445
-          <input type="checkbox" name="ResetIPHistory" id="ResetIPHistory" /> <label for="ResetIPHistory">IP
1446
-            history</label> |
1447
           <br />
1429
           <br />
1448
           <input type="checkbox" name="ResetSnatchList" id="ResetSnatchList" /> <label for="ResetSnatchList">Snatch
1430
           <input type="checkbox" name="ResetSnatchList" id="ResetSnatchList" /> <label for="ResetSnatchList">Snatch
1449
             list</label> |
1431
             list</label> |

+ 0
- 19
sections/userhistory/index.php View File

9
 
9
 
10
 if ($_GET['action']) {
10
 if ($_GET['action']) {
11
     switch ($_GET['action']) {
11
     switch ($_GET['action']) {
12
-    case 'ips':
13
-      //Load IP history page
14
-      include('ip_history.php');
15
-      break;
16
-
17
     case 'tracker_ips':
12
     case 'tracker_ips':
18
       include('ip_tracker_history.php');
13
       include('ip_tracker_history.php');
19
       break;
14
       break;
20
 
15
 
21
-    case 'passwords':
22
-      //Load Password history page
23
-      include('password_history.php');
24
-      break;
25
-
26
-    case 'userip':
27
-      include('ip_history_userview.php');
28
-      break;
29
-
30
-    case 'passkeys':
31
-      //Load passkey history page
32
-      include('passkey_history.php');
33
-      break;
34
-
35
     case 'posts':
16
     case 'posts':
36
       //Load ratio history page
17
       //Load ratio history page
37
       include('post_history.php');
18
       include('post_history.php');

+ 0
- 299
sections/userhistory/ip_history.php View File

1
-<?php
2
-#declare(strict_types=1);
3
-
4
-/************************************************************************
5
-||------------|| User IP history page ||---------------------------||
6
-
7
-This page lists previous IPs a user has connected to the site with. It
8
-gets called if $_GET['action'] == 'ips'.
9
-
10
-It also requires $_GET['userid'] in order to get the data for the correct
11
-user.
12
-
13
-************************************************************************/
14
-
15
-define('IPS_PER_PAGE', 25);
16
-
17
-$UserID = $_GET['userid'];
18
-if (!is_number($UserID)) {
19
-    error(404);
20
-}
21
-
22
-$DB->query("
23
-  SELECT
24
-    um.Username,
25
-    p.Level AS Class
26
-  FROM users_main AS um
27
-    LEFT JOIN permissions AS p ON p.ID = um.PermissionID
28
-  WHERE um.ID = $UserID");
29
-list($Username, $Class) = $DB->next_record();
30
-
31
-if (!check_perms('users_view_ips', $Class)) {
32
-    error(403);
33
-}
34
-
35
-$UsersOnly = isset($_GET['usersonly']) ? $_GET['usersonly'] : 0;
36
-
37
-if (isset($_POST['ip'])) {
38
-    $SearchIP = db_string(str_replace("*", "%", trim($_POST['ip'])));
39
-    $SearchIPQuery = " AND h1.IP LIKE '$SearchIP' ";
40
-} else {
41
-    $SearchIPQuery = "";
42
-}
43
-
44
-View::show_header("IP address history for $Username");
45
-?>
46
-<script type="text/javascript">
47
-  //<![CDATA[
48
-  function ShowIPs(rowname) {
49
-    $('tr[name="' + rowname + '"]').gtoggle();
50
-
51
-  }
52
-
53
-  function Ban(ip, id, elemID) {
54
-    var notes = prompt("Enter notes for this ban");
55
-    if (notes != null && notes.length > 0) {
56
-      var xmlhttp;
57
-      if (window.XMLHttpRequest) {
58
-        xmlhttp = new XMLHttpRequest();
59
-      } else {
60
-        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
61
-      }
62
-      xmlhttp.onreadystatechange = function() {
63
-        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
64
-          document.getElementById(elemID).innerHTML = "<strong>[Banned]</strong>";
65
-        }
66
-      }
67
-      xmlhttp.open("GET", "tools.php?action=quick_ban&perform=create&ip=" + ip + "&notes=" + notes, true);
68
-      xmlhttp.send();
69
-    }
70
-
71
-  }
72
-  /*
73
-  function UnBan(ip, id, elemID) {
74
-      var xmlhttp;
75
-      if (window.XMLHttpRequest) {
76
-        xmlhttp = new XMLHttpRequest();
77
-      } else {
78
-        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
79
-      }
80
-      xmlhttp.onreadystatechange = function() {
81
-        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
82
-          document.getElementById(elemID).innerHTML = "Ban";
83
-          document.getElementById(elemID).onclick = function() { Ban(ip, id, elemID); return false; };
84
-        }
85
-      }
86
-      xmlhttp.open("GET","tools.php?action=quick_ban&perform=delete&id=" + id + "&ip=" + ip, true);
87
-      xmlhttp.send();
88
-  }
89
-  */
90
-  //]]>
91
-</script>
92
-<?php
93
-list($Page, $Limit) = Format::page_limit(IPS_PER_PAGE);
94
-
95
-if ($UsersOnly == 1) {
96
-    $RS = $DB->query("
97
-    SELECT
98
-      SQL_CALC_FOUND_ROWS
99
-      h1.IP,
100
-      h1.StartTime,
101
-      h1.EndTime,
102
-      GROUP_CONCAT(h2.UserID SEPARATOR '|'),
103
-      GROUP_CONCAT(h2.StartTime SEPARATOR '|'),
104
-      GROUP_CONCAT(IFNULL(h2.EndTime,0) SEPARATOR '|'),
105
-      GROUP_CONCAT(um2.Username SEPARATOR '|'),
106
-      GROUP_CONCAT(um2.Enabled SEPARATOR '|'),
107
-      GROUP_CONCAT(ui2.Donor SEPARATOR '|'),
108
-      GROUP_CONCAT(ui2.Warned SEPARATOR '|')
109
-    FROM users_history_ips AS h1
110
-      LEFT JOIN users_history_ips AS h2 ON h2.IP = h1.IP AND h2.UserID != $UserID
111
-      LEFT JOIN users_main AS um2 ON um2.ID = h2.UserID
112
-      LEFT JOIN users_info AS ui2 ON ui2.UserID = h2.UserID
113
-    WHERE h1.UserID = '$UserID'
114
-      AND h2.UserID > 0 $SearchIPQuery
115
-    GROUP BY h1.IP, h1.StartTime
116
-    ORDER BY h1.StartTime DESC
117
-    LIMIT $Limit");
118
-} else {
119
-    $RS = $DB->query("
120
-    SELECT
121
-      SQL_CALC_FOUND_ROWS
122
-      h1.IP,
123
-      h1.StartTime,
124
-      h1.EndTime,
125
-      GROUP_CONCAT(h2.UserID SEPARATOR '|'),
126
-      GROUP_CONCAT(h2.StartTime SEPARATOR '|'),
127
-      GROUP_CONCAT(IFNULL(h2.EndTime,0) SEPARATOR '|'),
128
-      GROUP_CONCAT(um2.Username SEPARATOR '|'),
129
-      GROUP_CONCAT(um2.Enabled SEPARATOR '|'),
130
-      GROUP_CONCAT(ui2.Donor SEPARATOR '|'),
131
-      GROUP_CONCAT(ui2.Warned SEPARATOR '|')
132
-    FROM users_history_ips AS h1
133
-      LEFT JOIN users_history_ips AS h2 ON h2.IP = h1.IP AND h2.UserID != $UserID
134
-      LEFT JOIN users_main AS um2 ON um2.ID = h2.UserID
135
-      LEFT JOIN users_info AS ui2 ON ui2.UserID = h2.UserID
136
-    WHERE h1.UserID = '$UserID' $SearchIPQuery
137
-    GROUP BY h1.IP, h1.StartTime
138
-    ORDER BY h1.StartTime DESC
139
-    LIMIT $Limit");
140
-}
141
-$DB->query('SELECT FOUND_ROWS()');
142
-list($NumResults) = $DB->next_record();
143
-$DB->set_query_id($RS);
144
-
145
-$Pages = Format::get_pages($Page, $NumResults, IPS_PER_PAGE, 9);
146
-
147
-?>
148
-<div>
149
-  <div class="header">
150
-    <h2>IP address history for <a
151
-        href="user.php?id=<?=$UserID?>"><?=$Username?></a></h2>
152
-    <div class="linkbox">
153
-      <?php if ($UsersOnly) { ?>
154
-      <a href="userhistory.php?action=ips&amp;userid=<?=$UserID?>"
155
-        class="brackets">View all IP addresses</a>
156
-      <?php } else { ?>
157
-      <a href="userhistory.php?action=ips&amp;userid=<?=$UserID?>&amp;usersonly=1"
158
-        class="brackets">View IP addresses with users</a>
159
-      <?php } ?>
160
-    </div>
161
-    <?php if ($Pages) { ?>
162
-    <div class="linkbox pager"><?=$Pages?>
163
-    </div>
164
-    <?php } ?>
165
-  </div>
166
-  <table>
167
-    <tr class="colhead">
168
-      <td>IP address search</td>
169
-    </tr>
170
-
171
-    <tr>
172
-      <td>
173
-        <form class="search_form" name="ip_log" method="post" action="">
174
-          <input type="text" name="ip" />
175
-          <input type="submit" value="Search" />
176
-          Wildcard (*) search examples: 127.0.* or 1*2.0.*.1 or *.*.*.*
177
-        </form>
178
-      </td>
179
-    </tr>
180
-  </table>
181
-
182
-  <table id="iphistory">
183
-    <tr class="colhead">
184
-      <td>IP address</td>
185
-      <td>Started <a href="#"
186
-          onclick="$('#iphistory td:nth-child(2), #iphistory td:nth-child(4)').ghide(); $('#iphistory td:nth-child(3), #iphistory td:nth-child(5)').gshow(); return false;"
187
-          class="brackets">Toggle</a></td>
188
-      <td class="hidden">Started <a href="#"
189
-          onclick="$('#iphistory td:nth-child(2), #iphistory td:nth-child(4)').gshow(); $('#iphistory td:nth-child(3), #iphistory td:nth-child(5)').ghide(); return false;"
190
-          class="brackets">Toggle</a></td>
191
-      <td>Ended</td>
192
-      <td class="hidden">Ended</td>
193
-      <td>Elapsed</td>
194
-    </tr>
195
-    <?php
196
-$counter = 0;
197
-$IPs = [];
198
-$Results = $DB->to_array();
199
-$CanManageIPBans = check_perms('admin_manage_ipbans');
200
-
201
-foreach ($Results as $Index => $Result) {
202
-    list($IP, $StartTime, $EndTime, $UserIDs, $UserStartTimes, $UserEndTimes, $Usernames, $UsersEnabled, $UsersDonor, $UsersWarned) = $Result;
203
-
204
-    $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
205
-
206
-    $HasDupe = false;
207
-    $UserIDs = explode('|', $UserIDs);
208
-    if (!$EndTime) {
209
-        $EndTime = sqltime();
210
-    }
211
-    if ($UserIDs[0] != 0) {
212
-        $HasDupe = true;
213
-        $UserStartTimes = explode('|', $UserStartTimes);
214
-        $UserEndTimes = explode('|', $UserEndTimes);
215
-        $Usernames = explode('|', $Usernames);
216
-        $UsersEnabled = explode('|', $UsersEnabled);
217
-        $UsersDonor = explode('|', $UsersDonor);
218
-        $UsersWarned = explode('|', $UsersWarned);
219
-    } ?>
220
-    <tr class="row">
221
-      <td>
222
-        <?=$IP?>
223
-        <?php
224
-  if ($CanManageIPBans) {
225
-      if (!isset($IPs[$IP])) {
226
-          $sql = "
227
-        SELECT ID, FromIP, ToIP
228
-        FROM ip_bans
229
-        WHERE '".Tools::ip_to_unsigned($IP)."' BETWEEN FromIP AND ToIP
230
-        LIMIT 1";
231
-          $DB->query($sql);
232
-
233
-          if ($DB->has_results()) {
234
-              $IPs[$IP] = true; ?>
235
-        <strong>[Banned]</strong>
236
-        <?php
237
-          } else {
238
-              $IPs[$IP] = false; ?>
239
-        <a id="<?=$counter?>" href="#"
240
-          onclick="Ban('<?=$IP?>', '', '<?=$counter?>'); this.onclick = null; return false;"
241
-          class="brackets">Ban</a>
242
-        <?php
243
-          }
244
-          $counter++;
245
-      }
246
-  } ?>
247
-        <br />
248
-        <?=Tools::get_host_by_ajax($IP)?>
249
-        <?=($HasDupe ? '<a href="#" onclick="ShowIPs('.$Index.'); return false;">('.count($UserIDs).')</a>' : '(0)')?>
250
-      </td>
251
-      <td><?=time_diff($StartTime)?>
252
-      </td>
253
-      <td class="hidden"><?=$StartTime?>
254
-      </td>
255
-      <td><?=time_diff($EndTime)?>
256
-      </td>
257
-      <td class="hidden"><?=$EndTime?>
258
-      </td>
259
-      <td>
260
-        <?//time_diff(strtotime($StartTime), strtotime($EndTime));?>
261
-      </td>
262
-    </tr>
263
-    <?php
264
-  if ($HasDupe) {
265
-      $HideMe = (count($UserIDs) > 10);
266
-      foreach ($UserIDs as $Key => $Val) {
267
-          if (!$UserEndTimes[$Key]) {
268
-              $UserEndTimes[$Key] = sqltime();
269
-          } ?>
270
-    <tr
271
-      class="row<?=($HideMe ? ' hidden' : '')?>"
272
-      name="<?=$Index?>">
273
-      <td>&nbsp;&nbsp;&#187;&nbsp;<?=Users::format_username($Val, true, true, true)?>
274
-      </td>
275
-      <td><?=time_diff($UserStartTimes[$Key])?>
276
-      </td>
277
-      <td class="hidden"><?=$UserStartTimes[$Key]?>
278
-      </td>
279
-      <td><?=time_diff($UserEndTimes[$Key])?>
280
-      </td>
281
-      <td class="hidden"><?=$UserEndTimes[$Key]?>
282
-      </td>
283
-      <td>
284
-        <?//time_diff(strtotime($UserStartTimes[$Key]), strtotime($UserEndTimes[$Key]));?>
285
-      </td>
286
-    </tr>
287
-    <?php
288
-      }
289
-  }
290
-}
291
-?>
292
-  </table>
293
-
294
-  <div class="linkbox">
295
-    <?=$Pages?>
296
-  </div>
297
-</div>
298
-
299
-<?php View::show_footer();

+ 0
- 80
sections/userhistory/ip_history_userview.php View File

1
-<?
2
-$UserID = $_GET['userid'];
3
-if (!is_number($UserID)) {
4
-  error(404);
5
-}
6
-
7
-$Self = ($UserID == $LoggedUser['ID']);
8
-
9
-if (!check_perms('users_mod') && !$Self) {
10
-  error(403);
11
-}
12
-
13
-if (!apcu_exists('DBKEY')) {
14
-  error('The site is currently running with partial database access. Please wait for staff to fully decrypt it');
15
-}
16
-
17
-$DB->query("
18
-  SELECT IP
19
-  FROM users_history_ips
20
-  WHERE UserID = '$UserID'");
21
-
22
-$EncIPs = $DB->collect("IP");
23
-$IPs = [];
24
-
25
-foreach ($EncIPs as $Enc) {
26
-  if (!isset($IPs[Crypto::decrypt($Enc)])) {
27
-    $IPs[Crypto::decrypt($Enc)] = [];
28
-  }
29
-  $IPs[Crypto::decrypt($Enc)][] = $Enc;
30
-}
31
-
32
-$DB->query("
33
-  SELECT IP
34
-  FROM users_main
35
-  WHERE ID = '$UserID'");
36
-
37
-list($Curr) = $DB->next_record();
38
-$Curr = Crypto::decrypt($Curr);
39
-
40
-if (!$Self) {
41
-  $DB->query("SELECT Username FROM users_main WHERE ID = '$UserID'");
42
-  list($Username) = $DB->next_record();
43
-
44
-  View::show_header("IP history for $Username");
45
-} else {
46
-  View::show_header("Your IP history");
47
-}
48
-
49
-?>
50
-
51
-<div class="header">
52
-<? if ($Self) { ?>
53
-  <h2>Your IP history</h2>
54
-<? } else { ?>
55
-  <h2>IP history for <a href="user.php?id=<?=$UserID?>"><?=$Username?></a></h2>
56
-<? } ?>
57
-</div>
58
-<table class="alternate_rows" width="100%">
59
-  <tr class="colhead">
60
-    <td>IP</td>
61
-    <td>Expunge</td>
62
-  </tr>
63
-<? foreach ($IPs as $IP => $Encs) { ?>
64
-  <tr class="row">
65
-    <td><?=display_str($IP)?></td>
66
-    <td>
67
-    <? if ($IP != $Curr) { ?>
68
-      <form action="delete.php" method="post">
69
-        <input type="hidden" name="action" value="ip">
70
-        <? foreach ($Encs as $Enc) { ?>
71
-        <input type="hidden" name="ips[]" value="<?=$Enc?>">
72
-        <? } ?>
73
-        <input type="submit" value="X">
74
-      </form>
75
-    <? } ?>
76
-    </td>
77
-  </tr>
78
-<? } ?>
79
-</table>
80
-<? View::show_footer(); ?>

+ 0
- 63
sections/userhistory/passkey_history.php View File

1
-<?
2
-/************************************************************************
3
-||------------|| User passkey history page ||--------------------------||
4
-
5
-This page lists previous passkeys a user has used on the site. It gets
6
-called if $_GET['action'] == 'passkey'.
7
-
8
-It also requires $_GET['userid'] in order to get the data for the correct
9
-user.
10
-
11
-************************************************************************/
12
-
13
-$UserID = $_GET['userid'];
14
-if (!is_number($UserID)) {
15
-  error(404);
16
-}
17
-
18
-$DB->query("
19
-  SELECT
20
-    um.Username,
21
-    p.Level AS Class
22
-  FROM users_main AS um
23
-    LEFT JOIN permissions AS p ON p.ID = um.PermissionID
24
-  WHERE um.ID = $UserID");
25
-list($Username, $Class) = $DB->next_record();
26
-
27
-if (!check_perms('users_view_keys', $Class)) {
28
-  error(403);
29
-}
30
-
31
-View::show_header("Passkey history for $Username");
32
-
33
-$DB->query("
34
-  SELECT
35
-    OldPassKey,
36
-    NewPassKey,
37
-    ChangeTime,
38
-    ChangerIP
39
-  FROM users_history_passkeys
40
-  WHERE UserID = $UserID
41
-  ORDER BY ChangeTime DESC");
42
-
43
-?>
44
-<div class="header">
45
-  <h2>Passkey history for <a href="/user.php?id=<?=$UserID?>"><?=$Username?></a></h2>
46
-</div>
47
-<table width="100%">
48
-  <tr class="colhead">
49
-    <td>Old</td>
50
-    <td>New</td>
51
-    <td>Changed</td>
52
-    <td>IP <a href="/userhistory.php?action=ips&amp;userid=<?=$UserID?>" class="brackets">H</a></td>
53
-  </tr>
54
-<? while (list($OldPassKey, $NewPassKey, $ChangeTime, $ChangerIP) = $DB->next_record()) { ?>
55
-  <tr class="row">
56
-    <td><?=display_str($OldPassKey)?></td>
57
-    <td><?=display_str($NewPassKey)?></td>
58
-    <td><?=time_diff($ChangeTime)?></td>
59
-    <td><?=display_str($ChangerIP)?> <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($ChangerIP)?>" class="brackets tooltip" title="Search">S</a><br /><?=display_str(Tools::get_host_by_ip($ChangerIP))?></td>
60
-  </tr>
61
-<? } ?>
62
-</table>
63
-<? View::show_footer(); ?>

+ 0
- 60
sections/userhistory/password_history.php View File

1
-<?
2
-/************************************************************************
3
-||------------|| Password reset history page ||------------------------||
4
-
5
-This page lists password reset IP and Times a user has made on the site.
6
-It gets called if $_GET['action'] == 'password'.
7
-
8
-It also requires $_GET['userid'] in order to get the data for the correct
9
-user.
10
-
11
-************************************************************************/
12
-
13
-$UserID = $_GET['userid'];
14
-if (!is_number($UserID)) {
15
-  error(404);
16
-}
17
-
18
-$DB->query("
19
-  SELECT
20
-    um.Username,
21
-    p.Level AS Class
22
-  FROM users_main AS um
23
-    LEFT JOIN permissions AS p ON p.ID = um.PermissionID
24
-  WHERE um.ID = $UserID");
25
-list($Username, $Class) = $DB->next_record();
26
-
27
-if (!check_perms('users_view_keys', $Class)) {
28
-  error(403);
29
-}
30
-
31
-View::show_header("Password reset history for $Username");
32
-
33
-$DB->query("
34
-  SELECT
35
-    ChangeTime,
36
-    ChangerIP
37
-  FROM users_history_passwords
38
-  WHERE UserID = $UserID
39
-  ORDER BY ChangeTime DESC");
40
-
41
-?>
42
-<div class="header">
43
-  <h2>Password reset history for <a href="/user.php?id=<?=$UserID?>"><?=$Username?></a></h2>
44
-</div>
45
-<table width="100%">
46
-  <tr class="colhead">
47
-    <td>Changed</td>
48
-    <td>IP <a href="/userhistory.php?action=ips&amp;userid=<?=$UserID?>" class="brackets">H</a></td>
49
-  </tr>
50
-<?
51
-while (list($ChangeTime, $ChangerIP) = $DB->next_record()) {
52
-  $ChangerIP = (apcu_exists('DBKEY')) ? Crypto::decrypt($ChangerIP) : '[Encrypted]';
53
-?>
54
-  <tr class="row">
55
-    <td><?=time_diff($ChangeTime)?></td>
56
-    <td><?=display_str($ChangerIP)?> <a href="/user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($ChangerIP)?>" class="brackets tooltip" title="Search">S</a><br /><?=Tools::get_host_by_ajax($ChangerIP)?></td>
57
-  </tr>
58
-<? } ?>
59
-</table>
60
-<? View::show_footer(); ?>

+ 0
- 15
templates/admin/advanced-user-search.twig View File

70
             <input type="text" name="lastfm" size="20" value="{{ lastfm }}" />
70
             <input type="text" name="lastfm" size="20" value="{{ lastfm }}" />
71
         </td>
71
         </td>
72
         </tr>
72
         </tr>
73
-
74
-        <tr>
75
-        <td class="nobr" colspan="2">
76
-        <h4>Extra</h4>
77
-        <ul class="options_list nobullet">
78
-            <li title="Only display users that have a disabled account linked by IP address">
79
-                <input type="checkbox" name="disabled_ip" id="disabled_ip"{{ checked(check_disabled_ip) }} />
80
-                <label for="disabled_ip">Disabled accounts linked by IP</label>
81
-            </li>
82
-            <li>
83
-                <input type="checkbox" name="ip_history" id="ip_history"{{ checked(check_ip_history) }} />
84
-                <label title="Disabled accounts linked by IP must also be checked" for="ip_history">IP history</label>
85
-            </li>
86
-        </ul>
87
-        </tr>
88
     </table></td>
73
     </table></td>
89
 
74
 
90
 {# new column #}
75
 {# new column #}

+ 2
- 3
templates/admin/announcekey-history.twig View File

6
         <td>Old</td>
6
         <td>Old</td>
7
         <td>New</td>
7
         <td>New</td>
8
         <td>Changed</td>
8
         <td>Changed</td>
9
-        <td>IP <a href="/userhistory.php?action=ips&amp;userid={{ user.id }}" class="brackets">H</a></td>
9
+        <td>IP</td>
10
     </tr>
10
     </tr>
11
 {% for change in user.announceKeyHistory %}
11
 {% for change in user.announceKeyHistory %}
12
     <tr class="row{{ cycle(['a', 'b'], loop.index0) }}">
12
     <tr class="row{{ cycle(['a', 'b'], loop.index0) }}">
13
         <td>{{ change.old }}</td>
13
         <td>{{ change.old }}</td>
14
         <td>{{ change.new }}</td>
14
         <td>{{ change.new }}</td>
15
         <td>{{ change.date|time_diff }}</td>
15
         <td>{{ change.date|time_diff }}</td>
16
-        <td>{{ change.ipaddr }} <a href="user.php?action=search&amp;ip_history=on&amp;ip={{
17
-            change.ipaddr }}" class="brackets tooltip" title="Search">S</a><br />{{ resolveIpv4(change.ipaddr) }}</td>
16
+        <td>{{ change.ipaddr }}</td>
18
     </tr>
17
     </tr>
19
 {% endfor %}
18
 {% endfor %}
20
 </table>
19
 </table>

+ 0
- 1
templates/admin/privilege-list.twig View File

32
                     {{ privilege(default, user, 'site_view_full_log') }}
32
                     {{ privilege(default, user, 'site_view_full_log') }}
33
                     {{ privilege(default, user, 'site_view_torrent_snatchlist') }}
33
                     {{ privilege(default, user, 'site_view_torrent_snatchlist') }}
34
                     {{ privilege(default, user, 'site_delete_tag') }}
34
                     {{ privilege(default, user, 'site_delete_tag') }}
35
-                    {{ privilege(default, user, 'site_disable_ip_history') }}
36
                     {{ privilege(default, user, 'zip_downloader') }}
35
                     {{ privilege(default, user, 'zip_downloader') }}
37
                     {{ privilege(default, user, 'site_debug') }}
36
                     {{ privilege(default, user, 'site_debug') }}
38
                     {{ privilege(default, user, 'site_analysis') }}
37
                     {{ privilege(default, user, 'site_analysis') }}

+ 0
- 4
templates/admin/registration.twig View File

101
         {% endif %}
101
         {% endif %}
102
             </td>
102
             </td>
103
             <td style="vertical-align: top">
103
             <td style="vertical-align: top">
104
-                <a href="userhistory.php?action=ips&amp;userid{{ user.id }}" title="IP History" class="brackets tooltip">H</a>
105
-                <a href="/user.php?action=search&amp;ip_history=on&amp;ip={{ user.ipaddr }}" title="IP Search" class="brackets tooltip">S</a>
106
                 <a href="http://whatismyipaddress.com/ip/{{ user.ipaddr }}" title="whatismyipaddress.com" class="brackets tooltip">WI</a>
104
                 <a href="http://whatismyipaddress.com/ip/{{ user.ipaddr }}" title="whatismyipaddress.com" class="brackets tooltip">WI</a>
107
         {% if user.inviter.id and user.inviter.ipaddr != user.ipaddr %}
105
         {% if user.inviter.id and user.inviter.ipaddr != user.ipaddr %}
108
                 <br />
106
                 <br />
109
-                <a href="userhistory.php?action=ips&amp;userid={{ user.inviter.id }}" title="IP History" class="brackets tooltip">H</a>
110
-                <a href="/user.php?action=search&amp;ip_history=on&amp;ip={{ user.inviter.ipaddr }}" title="IP Search" class="brackets tooltip">S</a>
111
                 <a href="http://whatismyipaddress.com/ip/{{ user.inviter.ipaddr }}" title="WI" class="brackets tooltip">WI</a>
107
                 <a href="http://whatismyipaddress.com/ip/{{ user.inviter.ipaddr }}" title="WI" class="brackets tooltip">WI</a>
112
         {% endif %}
108
         {% endif %}
113
             </td>
109
             </td>

+ 0
- 1
templates/admin/user-info-ipv4.twig View File

7
 {% for i in info %}
7
 {% for i in info %}
8
 <tr class="row{{ cycle(['a', 'b'], loop.index0) }}">
8
 <tr class="row{{ cycle(['a', 'b'], loop.index0) }}">
9
     <td>{{ i.0 }}
9
     <td>{{ i.0 }}
10
-        <a href="user.php?action=search&amp;ip_history=on&amp;ip={{ i.0 }}" class="brackets tooltip" title="Shared with other users?">S</a>
11
         <a href="https://whatismyipaddress.com/ip/{{ i.0 }}" class="brackets tooltip" title="Search WIMIA.com">WI</a>
10
         <a href="https://whatismyipaddress.com/ip/{{ i.0 }}" class="brackets tooltip" title="Search WIMIA.com">WI</a>
12
     </td>
11
     </td>
13
     <td>{{ i.1 }}</td>
12
     <td>{{ i.1 }}</td>

+ 0
- 2
templates/user/edit-reset.twig View File

7
         <label for="ResetPasskey">Passkey</label></span>
7
         <label for="ResetPasskey">Passkey</label></span>
8
         <span style="white-space: nowrap; padding-right: 15px"><input type="checkbox" name="ResetAuthkey" id="ResetAuthkey" />
8
         <span style="white-space: nowrap; padding-right: 15px"><input type="checkbox" name="ResetAuthkey" id="ResetAuthkey" />
9
         <label for="ResetAuthkey">Authkey</label></span>
9
         <label for="ResetAuthkey">Authkey</label></span>
10
-        <span style="white-space: nowrap; padding-right: 15px"><input type="checkbox" name="ResetIPHistory" id="ResetIPHistory" />
11
-        <label for="ResetIPHistory">IP history</label></span>
12
         <span style="white-space: nowrap; padding-right: 15px"><input type="checkbox" name="ResetSnatchList" id="ResetSnatchList" />
10
         <span style="white-space: nowrap; padding-right: 15px"><input type="checkbox" name="ResetSnatchList" id="ResetSnatchList" />
13
         <label for="ResetSnatchList">Snatch list</label></span>
11
         <label for="ResetSnatchList">Snatch list</label></span>
14
         <span style="white-space: nowrap; padding-right: 15px"><input type="checkbox" name="ResetDownloadList" id="ResetDownloadList" />
12
         <span style="white-space: nowrap; padding-right: 15px"><input type="checkbox" name="ResetDownloadList" id="ResetDownloadList" />

+ 0
- 16
templates/user/password-history.twig View File

1
-<div class="header">
2
-    <h2><a href="/user.php?id={{ user.id  }}">{{ user.username }}</a> &rsaquo; Password reset history</h2>
3
-</div>
4
-<table width="100%">
5
-    <tr class="colhead">
6
-        <td>Changed</td>
7
-        <td>IP <a href="/userhistory.php?action=ips&amp;userid={{ user.id }}" class="brackets">H</a></td>
8
-    </tr>
9
-{% for change in list %}
10
-    <tr class="row{{ cycle(['a', 'b'], loop.index0) }}">
11
-        <td>{{ change.date|time_diff }}</td>
12
-        <td>{{ change.ipaddr }} <a href="/user.php?action=search&amp;ip_history=on&amp;ip={{ change.ipaddr }}" class="brackets tooltip" title="Search">S</a><br />{{ resolveIpv4(change.ipaddr)  }}</td>
13
-    </tr>
14
-{% endfor %}
15
-</table>
16
-<?php

Loading…
Cancel
Save