Browse Source

Remove GeoIP features and data

biotorrents 4 years ago
parent
commit
67aa729cc8

+ 2
- 3
classes/permissions_form.php View File

1
 <?php
1
 <?php
2
+declare(strict_types=1);
2
 
3
 
3
 /********************************************************************************
4
 /********************************************************************************
4
  ************ Permissions form ********************** user.php and tools.php ****
5
  ************ Permissions form ********************** user.php and tools.php ****
98
   'admin_schedule' => 'Can run the site schedule.',
99
   'admin_schedule' => 'Can run the site schedule.',
99
   'admin_login_watch' => 'Can manage login watch.',
100
   'admin_login_watch' => 'Can manage login watch.',
100
   'admin_manage_wiki' => 'Can manage wiki access.',
101
   'admin_manage_wiki' => 'Can manage wiki access.',
101
-  'admin_update_geoip' => 'Can update geoIP data.',
102
   'site_collages_recover' => 'Can recover \'deleted\' collages.',
102
   'site_collages_recover' => 'Can recover \'deleted\' collages.',
103
   'torrents_add_artist' => 'Can add artists to any group.',
103
   'torrents_add_artist' => 'Can add artists to any group.',
104
   'edit_unknowns' => 'Can edit unknown release information.',
104
   'edit_unknowns' => 'Can edit unknown release information.',
261
     display_perm('admin_manage_permissions', 'Can edit permission classes/user permissions.');
261
     display_perm('admin_manage_permissions', 'Can edit permission classes/user permissions.');
262
     display_perm('admin_schedule', 'Can run the site schedule.');
262
     display_perm('admin_schedule', 'Can run the site schedule.');
263
     display_perm('admin_login_watch', 'Can manage login watch.');
263
     display_perm('admin_login_watch', 'Can manage login watch.');
264
-    display_perm('admin_manage_wiki', 'Can manage wiki access.');
265
-    display_perm('admin_update_geoip', 'Can update geoIP data.'); ?>
264
+    display_perm('admin_manage_wiki', 'Can manage wiki access.'); ?>
266
         </td>
265
         </td>
267
       </tr>
266
       </tr>
268
     </table>
267
     </table>

+ 0
- 6
classes/script_start.php View File

417
         VALUES
417
         VALUES
418
           ('$LoggedUser[ID]', '".Crypto::encrypt($NewIP)."', NOW())");
418
           ('$LoggedUser[ID]', '".Crypto::encrypt($NewIP)."', NOW())");
419
 
419
 
420
-        $ipcc = Tools::geoip($NewIP);
421
-        $DB->query("
422
-        UPDATE users_main
423
-        SET IP = '".Crypto::encrypt($NewIP)."', ipcc = '$ipcc'
424
-          WHERE ID = '$LoggedUser[ID]'");
425
-
426
         $Cache->begin_transaction('user_info_heavy_'.$LoggedUser['ID']);
420
         $Cache->begin_transaction('user_info_heavy_'.$LoggedUser['ID']);
427
         $Cache->update_row(false, array('IP' => Crypto::encrypt($_SERVER['REMOTE_ADDR'])));
421
         $Cache->update_row(false, array('IP' => Crypto::encrypt($_SERVER['REMOTE_ADDR'])));
428
         $Cache->commit_transaction(0);
422
         $Cache->commit_transaction(0);

+ 2
- 50
classes/tools.class.php View File

1
 <?php
1
 <?php
2
+#declare(strict_types=1);
2
 
3
 
3
-# todo: Check strick equality gently
4
 class Tools
4
 class Tools
5
 {
5
 {
6
     /**
6
     /**
60
         return $IPnum;
60
         return $IPnum;
61
     }
61
     }
62
 
62
 
63
-    /**
64
-     * Geolocate an IP address using the database
65
-     *
66
-     * @param $IP the ip to fetch the country for
67
-     * @return the country of origin
68
-     */
69
-    public static function geoip($IP)
70
-    {
71
-        static $IPs = [];
72
-        if (isset($IPs[$IP])) {
73
-            return $IPs[$IP];
74
-        }
75
-
76
-        if (is_number($IP)) {
77
-            $Long = $IP;
78
-        } else {
79
-            $Long = Tools::ip_to_unsigned($IP);
80
-        }
81
-
82
-        if (!$Long || $Long == 2130706433) { // No need to check cc for 127.0.0.1
83
-            return false;
84
-        }
85
-
86
-        $QueryID = G::$DB->get_query_id();
87
-        G::$DB->query("
88
-        SELECT EndIP, Code
89
-        FROM geoip_country
90
-          WHERE $Long >= StartIP
91
-          ORDER BY StartIP DESC
92
-          LIMIT 1");
93
-
94
-        if ((!list($EndIP, $Country) = G::$DB->next_record()) || $EndIP < $Long) {
95
-            $Country = '?';
96
-        }
97
-
98
-        G::$DB->set_query_id($QueryID);
99
-        $IPs[$IP] = $Country;
100
-        return $Country;
101
-    }
102
 
63
 
103
     /**
64
     /**
104
      * Gets the hostname for an IP address
65
      * Gets the hostname for an IP address
169
      */
130
      */
170
     public static function display_ip($IP)
131
     public static function display_ip($IP)
171
     {
132
     {
172
-        $Line = display_str($IP).' ('.Tools::get_country_code_by_ajax($IP).') ';
173
-        $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>';
174
-        return $Line;
175
-    }
176
-
177
-    public static function get_country_code_by_ajax($IP)
178
-    {
179
-        static $ID = 0;
180
-        ++$ID;
181
-        return '<span id="cc_'.$ID.'">Resolving CC...<script type="text/javascript">ajax.get(\'tools.php?action=get_cc&ip='.$IP.'\', function(cc) {$(\'#cc_'.$ID.'\').raw().innerHTML = cc;});</script></span>';
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>';
182
     }
134
     }
183
 
135
 
184
 
136
 

+ 0
- 1
classes/util.php View File

208
             . $LoggedUser['Username']
208
             . $LoggedUser['Username']
209
             . ")" : $_SERVER['REMOTE_ADDR']
209
             . ")" : $_SERVER['REMOTE_ADDR']
210
             . " ("
210
             . " ("
211
-            . Tools::geoip($_SERVER['REMOTE_ADDR'])
212
         . ")")
211
         . ")")
213
         
212
         
214
         . " accessing https://"
213
         . " accessing https://"

+ 1
- 17
gazelle.sql View File

483
   KEY `FriendID` (`FriendID`)
483
   KEY `FriendID` (`FriendID`)
484
 ) ENGINE=InnoDB CHARSET=utf8mb4;
484
 ) ENGINE=InnoDB CHARSET=utf8mb4;
485
 
485
 
486
-CREATE TABLE `geoip_asn` (
487
-  `StartIP` varbinary(16) NOT NULL,
488
-  `EndIP` varbinary(16) NOT NULL,
489
-  `ASN` decimal(10,0) NOT NULL,
490
-  PRIMARY KEY (`StartIP`,`EndIP`)
491
-) ENGINE=InnoDB CHARSET=utf8mb4;
492
-
493
-CREATE TABLE `geoip_country` (
494
-  `StartIP` decimal(39,0) NOT NULL,
495
-  `EndIP` decimal(39,0) NOT NULL,
496
-  `Code` varchar(2) NOT NULL,
497
-  PRIMARY KEY (`StartIP`,`EndIP`)
498
-) ENGINE=InnoDB CHARSET=utf8mb4;
499
-
500
 -- 2020-03-09
486
 -- 2020-03-09
501
 CREATE TABLE `group_log` (
487
 CREATE TABLE `group_log` (
502
   `ID` int NOT NULL AUTO_INCREMENT,
488
   `ID` int NOT NULL AUTO_INCREMENT,
1493
   `torrent_pass` char(32) NOT NULL DEFAULT '',
1477
   `torrent_pass` char(32) NOT NULL DEFAULT '',
1494
   `RequiredRatio` double(10,8) NOT NULL DEFAULT '0.00000000',
1478
   `RequiredRatio` double(10,8) NOT NULL DEFAULT '0.00000000',
1495
   `RequiredRatioWork` double(10,8) NOT NULL DEFAULT '0.00000000',
1479
   `RequiredRatioWork` double(10,8) NOT NULL DEFAULT '0.00000000',
1496
-  `ipcc` varchar(2) NOT NULL DEFAULT '',
1497
   `FLTokens` int NOT NULL DEFAULT '0',
1480
   `FLTokens` int NOT NULL DEFAULT '0',
1498
   `BonusPoints` int unsigned NOT NULL DEFAULT '0',
1481
   `BonusPoints` int unsigned NOT NULL DEFAULT '0',
1499
   `IRCLines` int unsigned NOT NULL DEFAULT '0',
1482
   `IRCLines` int unsigned NOT NULL DEFAULT '0',
1511
   KEY `Invites` (`Invites`),
1494
   KEY `Invites` (`Invites`),
1512
   KEY `torrent_pass` (`torrent_pass`),
1495
   KEY `torrent_pass` (`torrent_pass`),
1513
   KEY `RequiredRatio` (`RequiredRatio`),
1496
   KEY `RequiredRatio` (`RequiredRatio`),
1514
-  KEY `cc_index` (`ipcc`),
1515
   KEY `PermissionID` (`PermissionID`)
1497
   KEY `PermissionID` (`PermissionID`)
1516
 ) ENGINE=InnoDB CHARSET=utf8mb4;
1498
 ) ENGINE=InnoDB CHARSET=utf8mb4;
1517
 
1499
 
1778
 SET FOREIGN_KEY_CHECKS = 1;
1760
 SET FOREIGN_KEY_CHECKS = 1;
1779
 
1761
 
1780
 INSERT INTO permissions (ID, Level, Name, `Values`, DisplayStaff) VALUES
1762
 INSERT INTO permissions (ID, Level, Name, `Values`, DisplayStaff) VALUES
1781
-  (15, 1000, 'Sysop', 'a:100:{s:10:\"site_leech\";i:1;s:11:\"site_upload\";i:1;s:9:\"site_vote\";i:1;s:20:\"site_submit_requests\";i:1;s:20:\"site_advanced_search\";i:1;s:10:\"site_top10\";i:1;s:19:\"site_advanced_top10\";i:1;s:16:\"site_album_votes\";i:1;s:20:\"site_torrents_notify\";i:1;s:20:\"site_collages_create\";i:1;s:20:\"site_collages_manage\";i:1;s:20:\"site_collages_delete\";i:1;s:23:\"site_collages_subscribe\";i:1;s:22:\"site_collages_personal\";i:1;s:28:\"site_collages_renamepersonal\";i:1;s:19:\"site_make_bookmarks\";i:1;s:14:\"site_edit_wiki\";i:1;s:22:\"site_can_invite_always\";i:1;s:27:\"site_send_unlimited_invites\";i:1;s:22:\"site_moderate_requests\";i:1;s:18:\"site_delete_artist\";i:1;s:20:\"site_moderate_forums\";i:1;s:17:\"site_admin_forums\";i:1;s:23:\"site_forums_double_post\";i:1;s:14:\"site_view_flow\";i:1;s:18:\"site_view_full_log\";i:1;s:28:\"site_view_torrent_snatchlist\";i:1;s:18:\"site_recommend_own\";i:1;s:27:\"site_manage_recommendations\";i:1;s:15:\"site_delete_tag\";i:1;s:23:\"site_disable_ip_history\";i:1;s:14:\"zip_downloader\";i:1;s:10:\"site_debug\";i:1;s:17:\"site_proxy_images\";i:1;s:16:\"site_search_many\";i:1;s:20:\"users_edit_usernames\";i:1;s:16:\"users_edit_ratio\";i:1;s:20:\"users_edit_own_ratio\";i:1;s:17:\"users_edit_titles\";i:1;s:18:\"users_edit_avatars\";i:1;s:18:\"users_edit_invites\";i:1;s:22:\"users_edit_watch_hours\";i:1;s:21:\"users_edit_reset_keys\";i:1;s:19:\"users_edit_profiles\";i:1;s:18:\"users_view_friends\";i:1;s:20:\"users_reset_own_keys\";i:1;s:19:\"users_edit_password\";i:1;s:19:\"users_promote_below\";i:1;s:16:\"users_promote_to\";i:1;s:16:\"users_give_donor\";i:1;s:10:\"users_warn\";i:1;s:19:\"users_disable_users\";i:1;s:19:\"users_disable_posts\";i:1;s:17:\"users_disable_any\";i:1;s:18:\"users_delete_users\";i:1;s:18:\"users_view_invites\";i:1;s:20:\"users_view_seedleech\";i:1;s:19:\"users_view_uploaded\";i:1;s:15:\"users_view_keys\";i:1;s:14:\"users_view_ips\";i:1;s:16:\"users_view_email\";i:1;s:18:\"users_invite_notes\";i:1;s:23:\"users_override_paranoia\";i:1;s:12:\"users_logout\";i:1;s:20:\"users_make_invisible\";i:1;s:9:\"users_mod\";i:1;s:13:\"torrents_edit\";i:1;s:15:\"torrents_delete\";i:1;s:20:\"torrents_delete_fast\";i:1;s:18:\"torrents_freeleech\";i:1;s:20:\"torrents_search_fast\";i:1;i:1;s:19:\"torrents_fix_ghosts\";i:1;s:17:\"admin_manage_news\";i:1;s:17:\"admin_manage_blog\";i:1;s:18:\"admin_manage_polls\";i:1;s:19:\"admin_manage_forums\";i:1;s:16:\"admin_manage_fls\";i:1;s:13:\"admin_reports\";i:1;s:26:\"admin_advanced_user_search\";i:1;s:18:\"admin_create_users\";i:1;s:15:\"admin_donor_log\";i:1;s:19:\"admin_manage_ipbans\";i:1;i:1;s:17:\"admin_clear_cache\";i:1;s:15:\"admin_whitelist\";i:1;s:24:\"admin_manage_permissions\";i:1;s:14:\"admin_schedule\";i:1;s:17:\"admin_login_watch\";i:1;s:17:\"admin_manage_wiki\";i:1;s:18:\"admin_update_geoip\";i:1;s:21:\"site_collages_recover\";i:1;s:19:\"torrents_add_artist\";i:1;s:13:\"edit_unknowns\";i:1;s:19:\"forums_polls_create\";i:1;s:21:\"forums_polls_moderate\";i:1;s:12:\"project_team\";i:1;s:25:\"torrents_edit_vanityhouse\";i:1;s:23:\"artist_edit_vanityhouse\";i:1;s:21:\"site_tag_aliases_read\";i:1;}', '1'),
1763
+  (15, 1000, 'Sysop', 'a:100:{s:10:\"site_leech\";i:1;s:11:\"site_upload\";i:1;s:9:\"site_vote\";i:1;s:20:\"site_submit_requests\";i:1;s:20:\"site_advanced_search\";i:1;s:10:\"site_top10\";i:1;s:19:\"site_advanced_top10\";i:1;s:16:\"site_album_votes\";i:1;s:20:\"site_torrents_notify\";i:1;s:20:\"site_collages_create\";i:1;s:20:\"site_collages_manage\";i:1;s:20:\"site_collages_delete\";i:1;s:23:\"site_collages_subscribe\";i:1;s:22:\"site_collages_personal\";i:1;s:28:\"site_collages_renamepersonal\";i:1;s:19:\"site_make_bookmarks\";i:1;s:14:\"site_edit_wiki\";i:1;s:22:\"site_can_invite_always\";i:1;s:27:\"site_send_unlimited_invites\";i:1;s:22:\"site_moderate_requests\";i:1;s:18:\"site_delete_artist\";i:1;s:20:\"site_moderate_forums\";i:1;s:17:\"site_admin_forums\";i:1;s:23:\"site_forums_double_post\";i:1;s:14:\"site_view_flow\";i:1;s:18:\"site_view_full_log\";i:1;s:28:\"site_view_torrent_snatchlist\";i:1;s:18:\"site_recommend_own\";i:1;s:27:\"site_manage_recommendations\";i:1;s:15:\"site_delete_tag\";i:1;s:23:\"site_disable_ip_history\";i:1;s:14:\"zip_downloader\";i:1;s:10:\"site_debug\";i:1;s:17:\"site_proxy_images\";i:1;s:16:\"site_search_many\";i:1;s:20:\"users_edit_usernames\";i:1;s:16:\"users_edit_ratio\";i:1;s:20:\"users_edit_own_ratio\";i:1;s:17:\"users_edit_titles\";i:1;s:18:\"users_edit_avatars\";i:1;s:18:\"users_edit_invites\";i:1;s:22:\"users_edit_watch_hours\";i:1;s:21:\"users_edit_reset_keys\";i:1;s:19:\"users_edit_profiles\";i:1;s:18:\"users_view_friends\";i:1;s:20:\"users_reset_own_keys\";i:1;s:19:\"users_edit_password\";i:1;s:19:\"users_promote_below\";i:1;s:16:\"users_promote_to\";i:1;s:16:\"users_give_donor\";i:1;s:10:\"users_warn\";i:1;s:19:\"users_disable_users\";i:1;s:19:\"users_disable_posts\";i:1;s:17:\"users_disable_any\";i:1;s:18:\"users_delete_users\";i:1;s:18:\"users_view_invites\";i:1;s:20:\"users_view_seedleech\";i:1;s:19:\"users_view_uploaded\";i:1;s:15:\"users_view_keys\";i:1;s:14:\"users_view_ips\";i:1;s:16:\"users_view_email\";i:1;s:18:\"users_invite_notes\";i:1;s:23:\"users_override_paranoia\";i:1;s:12:\"users_logout\";i:1;s:20:\"users_make_invisible\";i:1;s:9:\"users_mod\";i:1;s:13:\"torrents_edit\";i:1;s:15:\"torrents_delete\";i:1;s:20:\"torrents_delete_fast\";i:1;s:18:\"torrents_freeleech\";i:1;s:20:\"torrents_search_fast\";i:1;i:1;s:19:\"torrents_fix_ghosts\";i:1;s:17:\"admin_manage_news\";i:1;s:17:\"admin_manage_blog\";i:1;s:18:\"admin_manage_polls\";i:1;s:19:\"admin_manage_forums\";i:1;s:16:\"admin_manage_fls\";i:1;s:13:\"admin_reports\";i:1;s:26:\"admin_advanced_user_search\";i:1;s:18:\"admin_create_users\";i:1;s:15:\"admin_donor_log\";i:1;s:19:\"admin_manage_ipbans\";i:1;i:1;s:17:\"admin_clear_cache\";i:1;s:15:\"admin_whitelist\";i:1;s:24:\"admin_manage_permissions\";i:1;s:14:\"admin_schedule\";i:1;s:17:\"admin_login_watch\";i:1;s:17:\"admin_manage_wiki\";i:1;i:1;s:21:\"site_collages_recover\";i:1;s:19:\"torrents_add_artist\";i:1;s:13:\"edit_unknowns\";i:1;s:19:\"forums_polls_create\";i:1;s:21:\"forums_polls_moderate\";i:1;s:12:\"project_team\";i:1;s:25:\"torrents_edit_vanityhouse\";i:1;s:23:\"artist_edit_vanityhouse\";i:1;s:21:\"site_tag_aliases_read\";i:1;}', '1'),
1782
   (11, 800, 'Moderator', 'a:89:{s:26:\"admin_advanced_user_search\";i:1;s:17:\"admin_clear_cache\";i:1;s:18:\"admin_create_users\";i:1;i:1;s:15:\"admin_donor_log\";i:1;s:17:\"admin_login_watch\";i:1;s:17:\"admin_manage_blog\";i:1;s:19:\"admin_manage_ipbans\";i:1;s:17:\"admin_manage_news\";i:1;s:18:\"admin_manage_polls\";i:1;s:17:\"admin_manage_wiki\";i:1;s:13:\"admin_reports\";i:1;s:23:\"artist_edit_vanityhouse\";i:1;s:13:\"edit_unknowns\";i:1;s:19:\"forums_polls_create\";i:1;s:21:\"forums_polls_moderate\";i:1;s:12:\"project_team\";i:1;s:17:\"site_admin_forums\";i:1;s:20:\"site_advanced_search\";i:1;s:19:\"site_advanced_top10\";i:1;s:16:\"site_album_votes\";i:1;s:22:\"site_can_invite_always\";i:1;s:20:\"site_collages_create\";i:1;s:20:\"site_collages_delete\";i:1;s:20:\"site_collages_manage\";i:1;s:22:\"site_collages_personal\";i:1;s:21:\"site_collages_recover\";i:1;s:28:\"site_collages_renamepersonal\";i:1;s:23:\"site_collages_subscribe\";i:1;s:18:\"site_delete_artist\";i:1;s:15:\"site_delete_tag\";i:1;s:23:\"site_disable_ip_history\";i:1;s:14:\"site_edit_wiki\";i:1;s:23:\"site_forums_double_post\";i:1;s:10:\"site_leech\";i:1;s:19:\"site_make_bookmarks\";i:1;s:27:\"site_manage_recommendations\";i:1;s:20:\"site_moderate_forums\";i:1;s:22:\"site_moderate_requests\";i:1;s:17:\"site_proxy_images\";i:1;s:18:\"site_recommend_own\";i:1;s:16:\"site_search_many\";i:1;s:27:\"site_send_unlimited_invites\";i:1;s:20:\"site_submit_requests\";i:1;s:21:\"site_tag_aliases_read\";i:1;s:10:\"site_top10\";i:1;s:20:\"site_torrents_notify\";i:1;s:11:\"site_upload\";i:1;s:14:\"site_view_flow\";i:1;s:18:\"site_view_full_log\";i:1;s:28:\"site_view_torrent_snatchlist\";i:1;s:9:\"site_vote\";i:1;s:19:\"torrents_add_artist\";i:1;s:15:\"torrents_delete\";i:1;s:20:\"torrents_delete_fast\";i:1;s:13:\"torrents_edit\";i:1;s:25:\"torrents_edit_vanityhouse\";i:1;s:19:\"torrents_fix_ghosts\";i:1;s:18:\"torrents_freeleech\";i:1;i:1;s:20:\"torrents_search_fast\";i:1;s:18:\"users_delete_users\";i:1;s:17:\"users_disable_any\";i:1;s:19:\"users_disable_posts\";i:1;s:19:\"users_disable_users\";i:1;s:18:\"users_edit_avatars\";i:1;s:18:\"users_edit_invites\";i:1;s:20:\"users_edit_own_ratio\";i:1;s:19:\"users_edit_password\";i:1;s:19:\"users_edit_profiles\";i:1;s:16:\"users_edit_ratio\";i:1;s:21:\"users_edit_reset_keys\";i:1;s:17:\"users_edit_titles\";i:1;s:16:\"users_give_donor\";i:1;s:12:\"users_logout\";i:1;s:20:\"users_make_invisible\";i:1;s:9:\"users_mod\";i:1;s:23:\"users_override_paranoia\";i:1;s:19:\"users_promote_below\";i:1;s:20:\"users_reset_own_keys\";i:1;s:10:\"users_warn\";i:1;s:16:\"users_view_email\";i:1;s:18:\"users_view_friends\";i:1;s:18:\"users_view_invites\";i:1;s:14:\"users_view_ips\";i:1;s:15:\"users_view_keys\";i:1;s:20:\"users_view_seedleech\";i:1;s:19:\"users_view_uploaded\";i:1;s:14:\"zip_downloader\";i:1;}', '1'),
1764
   (11, 800, 'Moderator', 'a:89:{s:26:\"admin_advanced_user_search\";i:1;s:17:\"admin_clear_cache\";i:1;s:18:\"admin_create_users\";i:1;i:1;s:15:\"admin_donor_log\";i:1;s:17:\"admin_login_watch\";i:1;s:17:\"admin_manage_blog\";i:1;s:19:\"admin_manage_ipbans\";i:1;s:17:\"admin_manage_news\";i:1;s:18:\"admin_manage_polls\";i:1;s:17:\"admin_manage_wiki\";i:1;s:13:\"admin_reports\";i:1;s:23:\"artist_edit_vanityhouse\";i:1;s:13:\"edit_unknowns\";i:1;s:19:\"forums_polls_create\";i:1;s:21:\"forums_polls_moderate\";i:1;s:12:\"project_team\";i:1;s:17:\"site_admin_forums\";i:1;s:20:\"site_advanced_search\";i:1;s:19:\"site_advanced_top10\";i:1;s:16:\"site_album_votes\";i:1;s:22:\"site_can_invite_always\";i:1;s:20:\"site_collages_create\";i:1;s:20:\"site_collages_delete\";i:1;s:20:\"site_collages_manage\";i:1;s:22:\"site_collages_personal\";i:1;s:21:\"site_collages_recover\";i:1;s:28:\"site_collages_renamepersonal\";i:1;s:23:\"site_collages_subscribe\";i:1;s:18:\"site_delete_artist\";i:1;s:15:\"site_delete_tag\";i:1;s:23:\"site_disable_ip_history\";i:1;s:14:\"site_edit_wiki\";i:1;s:23:\"site_forums_double_post\";i:1;s:10:\"site_leech\";i:1;s:19:\"site_make_bookmarks\";i:1;s:27:\"site_manage_recommendations\";i:1;s:20:\"site_moderate_forums\";i:1;s:22:\"site_moderate_requests\";i:1;s:17:\"site_proxy_images\";i:1;s:18:\"site_recommend_own\";i:1;s:16:\"site_search_many\";i:1;s:27:\"site_send_unlimited_invites\";i:1;s:20:\"site_submit_requests\";i:1;s:21:\"site_tag_aliases_read\";i:1;s:10:\"site_top10\";i:1;s:20:\"site_torrents_notify\";i:1;s:11:\"site_upload\";i:1;s:14:\"site_view_flow\";i:1;s:18:\"site_view_full_log\";i:1;s:28:\"site_view_torrent_snatchlist\";i:1;s:9:\"site_vote\";i:1;s:19:\"torrents_add_artist\";i:1;s:15:\"torrents_delete\";i:1;s:20:\"torrents_delete_fast\";i:1;s:13:\"torrents_edit\";i:1;s:25:\"torrents_edit_vanityhouse\";i:1;s:19:\"torrents_fix_ghosts\";i:1;s:18:\"torrents_freeleech\";i:1;i:1;s:20:\"torrents_search_fast\";i:1;s:18:\"users_delete_users\";i:1;s:17:\"users_disable_any\";i:1;s:19:\"users_disable_posts\";i:1;s:19:\"users_disable_users\";i:1;s:18:\"users_edit_avatars\";i:1;s:18:\"users_edit_invites\";i:1;s:20:\"users_edit_own_ratio\";i:1;s:19:\"users_edit_password\";i:1;s:19:\"users_edit_profiles\";i:1;s:16:\"users_edit_ratio\";i:1;s:21:\"users_edit_reset_keys\";i:1;s:17:\"users_edit_titles\";i:1;s:16:\"users_give_donor\";i:1;s:12:\"users_logout\";i:1;s:20:\"users_make_invisible\";i:1;s:9:\"users_mod\";i:1;s:23:\"users_override_paranoia\";i:1;s:19:\"users_promote_below\";i:1;s:20:\"users_reset_own_keys\";i:1;s:10:\"users_warn\";i:1;s:16:\"users_view_email\";i:1;s:18:\"users_view_friends\";i:1;s:18:\"users_view_invites\";i:1;s:14:\"users_view_ips\";i:1;s:15:\"users_view_keys\";i:1;s:20:\"users_view_seedleech\";i:1;s:19:\"users_view_uploaded\";i:1;s:14:\"zip_downloader\";i:1;}', '1'),
1783
   (2, 100, 'User', 'a:7:{s:10:\"site_leech\";i:1;s:11:\"site_upload\";i:1;s:9:\"site_vote\";i:1;s:20:\"site_advanced_search\";i:1;s:10:\"site_top10\";i:1;s:14:\"site_edit_wiki\";i:1;s:19:\"torrents_add_artist\";i:1;}', '0'),
1765
   (2, 100, 'User', 'a:7:{s:10:\"site_leech\";i:1;s:11:\"site_upload\";i:1;s:9:\"site_vote\";i:1;s:20:\"site_advanced_search\";i:1;s:10:\"site_top10\";i:1;s:14:\"site_edit_wiki\";i:1;s:19:\"torrents_add_artist\";i:1;}', '0'),
1784
   (3, 150, 'Member', 'a:10:{s:10:\"site_leech\";i:1;s:11:\"site_upload\";i:1;s:9:\"site_vote\";i:1;s:20:\"site_submit_requests\";i:1;s:20:\"site_advanced_search\";i:1;s:10:\"site_top10\";i:1;s:20:\"site_collages_manage\";i:1;s:19:\"site_make_bookmarks\";i:1;s:14:\"site_edit_wiki\";i:1;s:19:\"torrents_add_artist\";i:1;}', '0'),
1766
   (3, 150, 'Member', 'a:10:{s:10:\"site_leech\";i:1;s:11:\"site_upload\";i:1;s:9:\"site_vote\";i:1;s:20:\"site_submit_requests\";i:1;s:20:\"site_advanced_search\";i:1;s:10:\"site_top10\";i:1;s:20:\"site_collages_manage\";i:1;s:19:\"site_make_bookmarks\";i:1;s:14:\"site_edit_wiki\";i:1;s:19:\"torrents_add_artist\";i:1;}', '0'),

+ 22
- 9
sections/login/index.php View File

46
         SELECT
46
         SELECT
47
           m.ID,
47
           m.ID,
48
           m.Email,
48
           m.Email,
49
-          m.ipcc,
50
           i.ResetExpires
49
           i.ResetExpires
51
         FROM users_main AS m
50
         FROM users_main AS m
52
           INNER JOIN users_info AS i ON i.UserID = m.ID
51
           INNER JOIN users_info AS i ON i.UserID = m.ID
283
                         # todo: Make sure the type is (int)
282
                         # todo: Make sure the type is (int)
284
                         if ($Enabled === '1') {
283
                         if ($Enabled === '1') {
285
 
284
 
286
-              // Check if the current login attempt is from a location previously logged in from
285
+                            // Check if the current login attempt is from a location previously logged in from
287
                             if (apcu_exists('DBKEY')) {
286
                             if (apcu_exists('DBKEY')) {
288
                                 $DB->query("
287
                                 $DB->query("
289
-                                SELECT IP
290
-                                FROM users_history_ips
291
-                                  WHERE UserID = ?", $UserID);
288
+                                SELECT
289
+                                  `IP`
290
+                                FROM
291
+                                  `users_history_ips`
292
+                                WHERE
293
+                                  `UserID` = '$UserID'
294
+                                ");
295
+
292
                                 $IPs = $DB->to_array(false, MYSQLI_NUM);
296
                                 $IPs = $DB->to_array(false, MYSQLI_NUM);
293
                                 $QueryParts = [];
297
                                 $QueryParts = [];
298
+
294
                                 foreach ($IPs as $i => $IP) {
299
                                 foreach ($IPs as $i => $IP) {
295
                                     $IPs[$i] = Crypto::decrypt($IP[0]);
300
                                     $IPs[$i] = Crypto::decrypt($IP[0]);
296
                                 }
301
                                 }
302
+
297
                                 $IPs = array_unique($IPs);
303
                                 $IPs = array_unique($IPs);
298
                                 if (count($IPs) > 0) { // Always allow first login
304
                                 if (count($IPs) > 0) { // Always allow first login
299
                                     foreach ($IPs as $IP) {
305
                                     foreach ($IPs as $IP) {
300
                                         $QueryParts[] = "(StartIP<=INET6_ATON('$IP') AND EndIP>=INET6_ATON('$IP'))";
306
                                         $QueryParts[] = "(StartIP<=INET6_ATON('$IP') AND EndIP>=INET6_ATON('$IP'))";
301
                                     }
307
                                     }
308
+
309
+                                    /*
302
                                     $DB->query('SELECT ASN FROM geoip_asn WHERE '.implode(' OR ', $QueryParts));
310
                                     $DB->query('SELECT ASN FROM geoip_asn WHERE '.implode(' OR ', $QueryParts));
303
                                     $PastASNs = array_column($DB->to_array(false, MYSQLI_NUM), 0);
311
                                     $PastASNs = array_column($DB->to_array(false, MYSQLI_NUM), 0);
304
                                     $DB->query("SELECT ASN FROM geoip_asn WHERE StartIP<=INET6_ATON('$_SERVER[REMOTE_ADDR]') AND EndIP>=INET6_ATON('$_SERVER[REMOTE_ADDR]')");
312
                                     $DB->query("SELECT ASN FROM geoip_asn WHERE StartIP<=INET6_ATON('$_SERVER[REMOTE_ADDR]') AND EndIP>=INET6_ATON('$_SERVER[REMOTE_ADDR]')");
305
                                     list($CurrentASN) = $DB->next_record();
313
                                     list($CurrentASN) = $DB->next_record();
314
+                                    */
306
 
315
 
307
                                     // If FEATURE_ENFORCE_LOCATIONS is enabled, require users to confirm new logins
316
                                     // If FEATURE_ENFORCE_LOCATIONS is enabled, require users to confirm new logins
308
                                     if (!in_array($CurrentASN, $PastASNs) && $ENV->FEATURE_ENFORCE_LOCATIONS) {
317
                                     if (!in_array($CurrentASN, $PastASNs) && $ENV->FEATURE_ENFORCE_LOCATIONS) {
310
                                         if ($Cache->get_value('new_location_'.$UserID.'_'.$CurrentASN) !== true) {
319
                                         if ($Cache->get_value('new_location_'.$UserID.'_'.$CurrentASN) !== true) {
311
                                             $DB->query("
320
                                             $DB->query("
312
                                             SELECT
321
                                             SELECT
313
-                                              UserName,
314
-                                              Email
315
-                                            FROM users_main
316
-                                              WHERE ID = ?", $UserID);
322
+                                              `UserName`,
323
+                                              `Email`
324
+                                            FROM
325
+                                              `users_main`
326
+                                            WHERE
327
+                                              `ID` = '$UserID'
328
+                                            ");
329
+                                            
317
                                             list($Username, $Email) = $DB->next_record();
330
                                             list($Username, $Email) = $DB->next_record();
318
                                             Users::auth_location($UserID, $Username, $CurrentASN, Crypto::decrypt($Email));
331
                                             Users::auth_location($UserID, $Username, $CurrentASN, Crypto::decrypt($Email));
319
                                             require('newlocation.php');
332
                                             require('newlocation.php');

+ 2
- 4
sections/register/index.php View File

105
                 $Enabled = '0';
105
                 $Enabled = '0';
106
             }
106
             }
107
 
107
 
108
-            $IPcc = Tools::geoip($_SERVER['REMOTE_ADDR']);
109
 
108
 
110
             $DB->query("
109
             $DB->query("
111
         INSERT INTO users_main
110
         INSERT INTO users_main
112
-          (Username, Email, PassHash, torrent_pass, IP, PermissionID, Enabled, Invites, FLTokens, Uploaded, ipcc)
111
+          (Username, Email, PassHash, torrent_pass, IP, PermissionID, Enabled, Invites, FLTokens, Uploaded)
113
         VALUES
112
         VALUES
114
           ('".db_string(trim($_POST['username']))."',
113
           ('".db_string(trim($_POST['username']))."',
115
           '".Crypto::encrypt($_POST['email'])."',
114
           '".Crypto::encrypt($_POST['email'])."',
120
           '$Enabled',
119
           '$Enabled',
121
           '".$ENV->STARTING_INVITES."',
120
           '".$ENV->STARTING_INVITES."',
122
           '".$ENV->STARTING_TOKENS."',
121
           '".$ENV->STARTING_TOKENS."',
123
-          '".$ENV->STARTING_UPLOAD."',
124
-          '$IPcc')
122
+          '".$ENV->STARTING_UPLOAD."')
125
           ");
123
           ");
126
 
124
 
127
             $UserID = $DB->inserted_id();
125
             $UserID = $DB->inserted_id();

+ 0
- 24
sections/schedule/manually/update_geodist.php View File

1
-<?php
2
-
3
-$IPs = [];
4
-$DB->query("SELECT IP FROM users_main WHERE Enabled = '1'");
5
-
6
-while (list($EncIP) = $DB->next_record()) {
7
-    $IPs[] = Crypto::decrypt($EncIP);
8
-}
9
-
10
-$DB->query("CREATE TEMPORARY TABLE users_ips_decrypted (IP VARCHAR(45) NOT NULL)");
11
-$DB->query("INSERT INTO users_ips_decrypted (IP) VALUES('".implode("'),('", $IPs)."')");
12
-$DB->query("TRUNCATE TABLE users_geodistribution");
13
-
14
-$DB->query("
15
-  INSERT INTO users_geodistribution
16
-    (Code, Users)
17
-  SELECT g.Code, COUNT(u.IP) AS Users
18
-  FROM geoip_country AS g
19
-    JOIN users_ips_decrypted AS u ON INET_ATON(u.IP) BETWEEN g.StartIP AND g.EndIP
20
-  GROUP BY g.Code
21
-  ORDER BY Users DESC");
22
-  
23
-$DB->query("DROP TABLE users_ips_decrypted");
24
-$Cache->delete_value('geodistribution');

+ 2
- 8
sections/tools/data/registration_log.php View File

1
 <?php
1
 <?php
2
+#declare(strict_types=1);
2
 
3
 
3
 if (!check_perms('users_view_ips') || !check_perms('users_view_email')) {
4
 if (!check_perms('users_view_ips') || !check_perms('users_view_email')) {
4
     error(403);
5
     error(403);
33
     SQL_CALC_FOUND_ROWS
34
     SQL_CALC_FOUND_ROWS
34
     m.ID,
35
     m.ID,
35
     m.IP,
36
     m.IP,
36
-    m.ipcc,
37
     m.Email,
37
     m.Email,
38
     m.Username,
38
     m.Username,
39
     m.PermissionID,
39
     m.PermissionID,
50
     ) AS Uses,
50
     ) AS Uses,
51
     im.ID,
51
     im.ID,
52
     im.IP,
52
     im.IP,
53
-    im.ipcc,
54
     im.Email,
53
     im.Email,
55
     im.Username,
54
     im.Username,
56
     im.PermissionID,
55
     im.PermissionID,
115
   </tr>
114
   </tr>
116
 
115
 
117
   <?php
116
   <?php
118
-  while (list($UserID, $IP, $IPCC, $Email, $Username, $PermissionID, $Uploaded, $Downloaded, $Enabled, $Donor, $Warned, $Joined, $Uses, $InviterID, $InviterIP, $InviterIPCC, $InviterEmail, $InviterUsername, $InviterPermissionID, $InviterUploaded, $InviterDownloaded, $InviterEnabled, $InviterDonor, $InviterWarned, $InviterJoined, $InviterUses) = $DB->next_record()) {
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()) {
119
       $RowClass = $IP === $InviterIP ? 'warning' : '';
118
       $RowClass = $IP === $InviterIP ? 'warning' : '';
120
       $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';
119
       $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';
121
       $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
120
       $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
186
       </span><br />
185
       </span><br />
187
     </td>
186
     </td>
188
 
187
 
189
-    <td>
190
-      <?=$IPCC?><br />
191
-      <?=$InviterIPCC?>
192
-    </td>
193
-
194
     <td>
188
     <td>
195
       <?=Tools::get_host_by_ajax($IP)?><br />
189
       <?=Tools::get_host_by_ajax($IP)?><br />
196
       <?=Tools::get_host_by_ajax($InviterIP)?>
190
       <?=Tools::get_host_by_ajax($InviterIP)?>

+ 0
- 110
sections/tools/development/update_geoip.php View File

1
-<?
2
-ini_set('memory_limit', '1G');
3
-set_time_limit(0);
4
-
5
-$LIMIT = 1000;
6
-
7
-if (!check_perms('site_debug')) {
8
-  error(403);
9
-}
10
-
11
-View::show_header();
12
-chdir('/tmp');
13
-// requires wget, unzip, gunzip commands to be installed
14
-
15
-// Country section
16
-shell_exec('wget http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip');
17
-shell_exec('wget http://geolite.maxmind.com/download/geoip/database/GeoIPv6.csv.gz');
18
-shell_exec('unzip GeoIPCountryCSV.zip');
19
-shell_exec('gunzip GeoIPv6.csv.gz');
20
-shell_exec('cut -d , -f 3-5 GeoIPCountryWhois.csv > GeoIPCountry.csv');
21
-shell_exec('cut -d , -f 3-5 GeoIPv6.csv | tr -d " " >> GeoIPCountry.csv');
22
-
23
-if (($fd = fopen('GeoIPCountry.csv', 'r')) !== false) {
24
-  $DB->query("TRUNCATE TABLE geoip_country");
25
-  $Values = [];
26
-  $Count = 0;
27
-  while (($Data = fgetcsv($fd)) !== false) {
28
-    list($StartIP, $EndIP, $CountryID) = $Data;
29
-    $Values[] = "($StartIP, $EndIP, '$CountryID')";
30
-    $Count++;
31
-    if ($Count % $LIMIT == 0) {
32
-      $DB->query("
33
-        INSERT INTO geoip_country (StartIP, EndIP, Code)
34
-        VALUES ".implode(', ', $Values));
35
-      $Values = [];
36
-    }
37
-  }
38
-  if (count($Values) > 0) {
39
-    $DB->query("
40
-      INSERT INTO geoip_country (StartIP, EndIP, Code)
41
-      VALUES ".implode(', ', $Values));
42
-  }
43
-  echo 'GeoIP_Country: There are '.($Count+count($Values)).' entries <br />';
44
-} else {
45
-  echo 'Country Error';
46
-}
47
-shell_exec('rm GeoIPCountryCSV.zip GeoIPv6.csv.gz GeoIPCountryWhois.csv GeoIPv6.csv GeoIPCountry.csv');
48
-
49
-// ASN (v4) section
50
-shell_exec('wget http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum2.zip');
51
-shell_exec('unzip GeoIPASNum2.zip');
52
-
53
-if (($fd = fopen('GeoIPASNum2.csv', 'r')) !== false) {
54
-  $DB->query("TRUNCATE TABLE geoip_asn");
55
-  $Values = [];
56
-  $Count = 0;
57
-  while (($Data = fgetcsv($fd)) !== false) {
58
-    list($StartIP, $EndIP, $ASN) = $Data;
59
-    $ASN = substr($ASN, 2, strpos($ASN, ' ') ? strpos($ASN, ' ')-2 : strlen($ASN)-2);
60
-    $Values[] = "(INET6_ATON(INET_NTOA($StartIP)), INET6_ATON(INET_NTOA($EndIP)), $ASN)";
61
-    $Count++;
62
-    if ($Count % $LIMIT == 0) {
63
-      $DB->query("
64
-        INSERT INTO geoip_asn (StartIP, EndIP, ASN)
65
-        VALUES ".implode(', ', $Values));
66
-      $Values = [];
67
-    }
68
-  }
69
-  if (count($Values) > 0) {
70
-    $DB->query("
71
-      INSERT INTO geoip_asn (StartIP, EndIP, ASN)
72
-      VALUES ".implode(', ', $Values));
73
-  }
74
-  echo 'GeoIP_ASN (v4): There are '.($Count+count($Values)).' entries <br />';
75
-} else {
76
-  echo 'ASNv4 Error';
77
-}
78
-shell_exec('rm GeoIPASNum2.zip GeoIPASNum2.csv');
79
-
80
-// ASN (v6) section
81
-shell_exec('wget http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum2v6.zip');
82
-shell_exec('unzip GeoIPASNum2v6.zip');
83
-
84
-if (($fd = fopen('GeoIPASNum2v6.csv', 'r')) !== false) {
85
-  $Values = [];
86
-  $Count = 0;
87
-  while (($Data = fgetcsv($fd)) !== false) {
88
-    list($ASN, $StartIP, $EndIP) = $Data;
89
-    $ASN = substr($ASN, 2, strpos($ASN, ' ') ? strpos($ASN, ' ')-2 : strlen($ASN)-2);
90
-    $Values[] = "(INET6_ATON('$StartIP'), INET6_ATON('$EndIP'), $ASN)";
91
-    $Count++;
92
-    if ($Count % $LIMIT == 0) {
93
-      $DB->query("
94
-        INSERT INTO geoip_asn (StartIP, EndIP, ASN)
95
-        VALUES ".implode(', ', $Values));
96
-      $Values = [];
97
-    }
98
-  }
99
-  if (count($Values) > 0) {
100
-    $DB->query("
101
-      INSERT INTO geoip_asn (StartIP, EndIP, ASN)
102
-      VALUES ".implode(', ', $Values));
103
-  }
104
-  echo 'GeoIP_ASN (v6): There are '.($Count+count($Values)).' entries <br />';
105
-} else {
106
-  echo 'ASNv6 Error';
107
-}
108
-shell_exec('rm GeoIPASNum2v6.zip GeoIPASNum2v6.tmp GeoIPASNum2v6.csv');
109
-
110
-View::show_footer();

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

25
     #error('Need to set an "action" parameter in sections/tools/tools.php.');
25
     #error('Need to set an "action" parameter in sections/tools/tools.php.');
26
 }
26
 }
27
 
27
 
28
-if (substr($_REQUEST['action'], 0, 12) === 'update_geoip' && !isset($argv[1])) {
29
-    if (!check_perms('site_debug')) {
30
-        error(403);
31
-    }
32
-}
33
-
34
 if (substr($_REQUEST['action'], 0, 16) === 'rerender_gallery' && !isset($argv[1])) {
28
 if (substr($_REQUEST['action'], 0, 16) === 'rerender_gallery' && !isset($argv[1])) {
35
     if (!check_perms('site_debug')) {
29
     if (!check_perms('site_debug')) {
36
         error(403);
30
         error(403);
419
   // END Data
413
   // END Data
420
 
414
 
421
   // Misc
415
   // Misc
422
-  case 'update_geoip':
423
-    include SERVER_ROOT.'/sections/tools/development/update_geoip.php';
424
-    break;
425
-
426
   case 'dupe_ips':
416
   case 'dupe_ips':
427
     include SERVER_ROOT.'/sections/tools/misc/dupe_ip.php';
417
     include SERVER_ROOT.'/sections/tools/misc/dupe_ip.php';
428
     break;
418
     break;

+ 0
- 19
sections/tools/services/get_cc.php View File

1
-<?php
2
-
3
-if (isset($_SERVER['http_if_modified_since'])) {
4
-    header('Status: 304 Not Modified');
5
-    error();
6
-}
7
-
8
-header('Expires: '.date('D, d-M-Y H:i:s \U\T\C', time() + 3600 * 24 * 120)); //120 days
9
-header('Last-Modified: '.date('D, d-M-Y H:i:s \U\T\C', time()));
10
-
11
-if (!check_perms('users_view_ips')) {
12
-    error('Access denied.');
13
-}
14
-
15
-if (empty($_GET['ip'])) {
16
-    error('Invalid IP address.');
17
-}
18
-
19
-die(Tools::geoip($_GET['ip']));

+ 2
- 2
sections/tools/tools.php View File

1
 <?php
1
 <?php
2
+#declare(strict_types=1);
2
 
3
 
3
 /***********************************************
4
 /***********************************************
4
  * This file displays the list of available tools in the staff toolbox.
5
  * This file displays the list of available tools in the staff toolbox.
167
   create_row("Service stats", "tools.php?action=service_stats", check_perms("site_debug"));
168
   create_row("Service stats", "tools.php?action=service_stats", check_perms("site_debug"));
168
   create_row("Miscellaneous values", "tools.php?action=misc_values", check_perms('users_mod'));
169
   create_row("Miscellaneous values", "tools.php?action=misc_values", check_perms('users_mod'));
169
   create_row("Tracker info", "tools.php?action=ocelot_info", check_perms("users_mod"));
170
   create_row("Tracker info", "tools.php?action=ocelot_info", check_perms("users_mod"));
170
-  create_row("Update GeoIP", "tools.php?action=update_geoip", check_perms("admin_update_geoip"));
171
 
171
 
172
   if ($ToolsHTML) {
172
   if ($ToolsHTML) {
173
       ?>
173
       ?>
229
         <tr class="colhead">
229
         <tr class="colhead">
230
           <td>Torrents</td>
230
           <td>Torrents</td>
231
         </tr>
231
         </tr>
232
-        <?=       $ToolsHTML ?>
232
+        <?= $ToolsHTML ?>
233
       </table>
233
       </table>
234
     </div>
234
     </div>
235
     <?php
235
     <?php

+ 3
- 10
sections/user/advancedsearch.php View File

308
             $Join['la'] .= ' JOIN locked_accounts AS la ON la.UserID = um1.ID ';
308
             $Join['la'] .= ' JOIN locked_accounts AS la ON la.UserID = um1.ID ';
309
         }
309
         }
310
 
310
 
311
-
312
-        if (!empty($_GET['cc'])) {
313
-            if ($_GET['cc_op'] == 'equal') {
314
-                $Where[] = "um1.ipcc = '".db_string($_GET['cc'])."'";
315
-            } else {
316
-                $Where[] = "um1.ipcc != '".db_string($_GET['cc'])."'";
317
-            }
318
-        }
319
-
320
         if (!empty($_GET['tracker_ip'])) {
311
         if (!empty($_GET['tracker_ip'])) {
321
             $Distinct = 'DISTINCT ';
312
             $Distinct = 'DISTINCT ';
322
             $Join['xfu'] = ' JOIN xbt_files_users AS xfu ON um1.ID = xfu.uid ';
313
             $Join['xfu'] = ' JOIN xbt_files_users AS xfu ON um1.ID = xfu.uid ';
1131
       <td><?=Format::get_ratio_html($Uploaded, $Downloaded)?>
1122
       <td><?=Format::get_ratio_html($Uploaded, $Downloaded)?>
1132
       </td>
1123
       </td>
1133
       <td style="word-break: break-all;"><?=display_str($IP)?>
1124
       <td style="word-break: break-all;"><?=display_str($IP)?>
1134
-        (<?=Tools::get_country_code_by_ajax($IP)?>)</td>
1125
+      </td>
1135
       <td><?=display_str($Email)?>
1126
       <td><?=display_str($Email)?>
1136
       </td>
1127
       </td>
1137
       <td><?=time_diff($JoinDate)?>
1128
       <td><?=time_diff($JoinDate)?>
1170
 ?>
1161
 ?>
1171
   </table>
1162
   </table>
1172
 </div>
1163
 </div>
1164
+
1173
 <div class="linkbox">
1165
 <div class="linkbox">
1174
   <?=$Pages?>
1166
   <?=$Pages?>
1175
 </div>
1167
 </div>
1168
+
1176
 <?php View::show_footer();
1169
 <?php View::show_footer();

+ 45
- 45
sections/userhistory/email_history.php View File

1
-<?
1
+<?php
2
+#declare(strict_types=1);
3
+
2
 /************************************************************************
4
 /************************************************************************
3
 ||------------|| User email history page ||---------------------------||
5
 ||------------|| User email history page ||---------------------------||
4
 
6
 
10
 
12
 
11
 ************************************************************************/
13
 ************************************************************************/
12
 
14
 
13
-
14
 $UserID = $_GET['userid'];
15
 $UserID = $_GET['userid'];
15
 if (!is_number($UserID)) {
16
 if (!is_number($UserID)) {
16
-  error(404);
17
+    error(404);
17
 }
18
 }
18
 
19
 
19
 $DB->query("
20
 $DB->query("
25
 list($Joined, $Class) = $DB->next_record();
26
 list($Joined, $Class) = $DB->next_record();
26
 
27
 
27
 if (!check_perms('users_view_email', $Class)) {
28
 if (!check_perms('users_view_email', $Class)) {
28
-  error(403);
29
+    error(403);
29
 }
30
 }
30
 
31
 
31
 $UsersOnly = $_GET['usersonly'];
32
 $UsersOnly = $_GET['usersonly'];
38
 View::show_header("Email history for $Username");
39
 View::show_header("Email history for $Username");
39
 
40
 
40
 if ($UsersOnly == 1) {
41
 if ($UsersOnly == 1) {
41
-  $DB->query("
42
+    $DB->query("
42
     SELECT
43
     SELECT
43
       u.Email,
44
       u.Email,
44
       NOW() AS Time,
45
       NOW() AS Time,
46
       c.Code
47
       c.Code
47
     FROM users_main AS u
48
     FROM users_main AS u
48
       LEFT JOIN users_main AS u2 ON u2.Email = u.Email AND u2.ID != '$UserID'
49
       LEFT JOIN users_main AS u2 ON u2.Email = u.Email AND u2.ID != '$UserID'
49
-      LEFT JOIN geoip_country AS c ON INET_ATON(u.IP) BETWEEN c.StartIP AND c.EndIP
50
     WHERE u.ID = '$UserID'
50
     WHERE u.ID = '$UserID'
51
       AND u2.ID > 0
51
       AND u2.ID > 0
52
     UNION
52
     UNION
57
       c.Code
57
       c.Code
58
     FROM users_history_emails AS h
58
     FROM users_history_emails AS h
59
       LEFT JOIN users_history_emails AS h2 ON h2.email = h.email and h2.UserID != '$UserID'
59
       LEFT JOIN users_history_emails AS h2 ON h2.email = h.email and h2.UserID != '$UserID'
60
-      LEFT JOIN geoip_country AS c ON INET_ATON(h.IP) BETWEEN c.StartIP AND c.EndIP
61
     WHERE h.UserID = '$UserID'
60
     WHERE h.UserID = '$UserID'
62
-      AND h2.UserID > 0"
63
-      /*AND Time IS NOT NULL*/."
61
+      AND h2.UserID > 0
64
     ORDER BY Time DESC");
62
     ORDER BY Time DESC");
65
 } else {
63
 } else {
66
-  $DB->query("
64
+    $DB->query("
67
     SELECT
65
     SELECT
68
       u.Email,
66
       u.Email,
69
       NOW() AS Time,
67
       NOW() AS Time,
70
       u.IP,
68
       u.IP,
71
       c.Code
69
       c.Code
72
     FROM users_main AS u
70
     FROM users_main AS u
73
-      LEFT JOIN geoip_country AS c ON INET_ATON(u.IP) BETWEEN c.StartIP AND c.EndIP
74
     WHERE u.ID = '$UserID'
71
     WHERE u.ID = '$UserID'
75
     UNION
72
     UNION
76
     SELECT
73
     SELECT
79
       h.IP,
76
       h.IP,
80
       c.Code
77
       c.Code
81
     FROM users_history_emails AS h
78
     FROM users_history_emails AS h
82
-      LEFT JOIN geoip_country AS c ON INET_ATON(h.IP) BETWEEN c.StartIP AND c.EndIP
83
-    WHERE UserID = '$UserID' "
84
-      /*AND Time IS NOT NULL*/."
79
+    WHERE UserID = '$UserID'
85
     ORDER BY Time DESC");
80
     ORDER BY Time DESC");
86
 }
81
 }
87
 $History = $DB->to_array();
82
 $History = $DB->to_array();
93
   <tr class="colhead">
88
   <tr class="colhead">
94
     <td>Email</td>
89
     <td>Email</td>
95
     <td>Set</td>
90
     <td>Set</td>
96
-    <td>IP <a href="userhistory.php?action=ips&amp;userid=<?=$UserID ?>" class="brackets">H</a></td>
97
-<? if ($UsersOnly == 1) {
98
-?>
99
-  <td>User</td>
100
-<?
91
+    <td>IP <a
92
+        href="userhistory.php?action=ips&amp;userid=<?=$UserID ?>"
93
+        class="brackets">H</a></td>
94
+    <?php if ($UsersOnly == 1) {
95
+    ?>
96
+    <td>User</td>
97
+    <?php
101
 }
98
 }
102
 ?>
99
 ?>
103
   </tr>
100
   </tr>
104
-<?
101
+  <?php
105
 foreach ($History as $Key => $Values) {
102
 foreach ($History as $Key => $Values) {
106
-  if (isset($History[$Key + 1])) {
107
-    $Values['Time'] = $History[$Key + 1]['Time'];
108
-  } else {
109
-    $Values['Time'] = $Joined;
110
-  }
103
+    if (isset($History[$Key + 1])) {
104
+        $Values['Time'] = $History[$Key + 1]['Time'];
105
+    } else {
106
+        $Values['Time'] = $Joined;
107
+    }
111
 
108
 
112
-  $ValuesIP = apcu_exists('DBKEY') ? Crypto::decrypt($Values['IP']) : '[Encrypted]';
113
-?>
109
+    $ValuesIP = apcu_exists('DBKEY') ? Crypto::decrypt($Values['IP']) : '[Encrypted]'; ?>
114
   <tr class="row">
110
   <tr class="row">
115
-    <td><?=display_str($Values['Email'])?></td>
116
-    <td><?=time_diff($Values['Time'])?></td>
117
-    <td><?=display_str($ValuesIP)?> (<?=display_str($Values['Code'])?>) <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($ValuesIP)?>" class="brackets tooltip" title="Search">S</a></td>
118
-<?
111
+    <td><?=display_str($Values['Email'])?>
112
+    </td>
113
+    <td><?=time_diff($Values['Time'])?>
114
+    </td>
115
+    <td><?=display_str($ValuesIP)?> (<?=display_str($Values['Code'])?>) <a
116
+        href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($ValuesIP)?>"
117
+        class="brackets tooltip" title="Search">S</a></td>
118
+    <?php
119
   if ($UsersOnly == 1) {
119
   if ($UsersOnly == 1) {
120
-    $ueQuery = $DB->query("
120
+      $ueQuery = $DB->query("
121
           SELECT
121
           SELECT
122
             ue.UserID,
122
             ue.UserID,
123
             um.Username,
123
             um.Username,
127
           WHERE ue.Email = '".db_string($Values['Email'])."'
127
           WHERE ue.Email = '".db_string($Values['Email'])."'
128
             AND ue.UserID != $UserID
128
             AND ue.UserID != $UserID
129
             AND um.ID = ue.UserID");
129
             AND um.ID = ue.UserID");
130
-    while (list($UserID2, $Time, $IP) = $DB->next_record()) {
131
-      $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
132
-?>
130
+      while (list($UserID2, $Time, $IP) = $DB->next_record()) {
131
+          $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]'; ?>
133
   </tr>
132
   </tr>
134
   <tr>
133
   <tr>
135
     <td></td>
134
     <td></td>
136
-    <td><?=time_diff($Time)?></td>
137
-    <td><?=display_str($IP)?></td>
138
-<?
135
+    <td><?=time_diff($Time)?>
136
+    </td>
137
+    <td><?=display_str($IP)?>
138
+    </td>
139
+    <?php
139
       $UserURL = site_url()."user.php?id=$UserID2";
140
       $UserURL = site_url()."user.php?id=$UserID2";
140
-      $DB->query("
141
+          $DB->query("
141
         SELECT Enabled
142
         SELECT Enabled
142
         FROM users_main
143
         FROM users_main
143
         WHERE ID = $UserID2");
144
         WHERE ID = $UserID2");
144
-      list($Enabled) = $DB->next_record();
145
-      $DB->set_query_id($ueQuery);
146
-?>
145
+          list($Enabled) = $DB->next_record();
146
+          $DB->set_query_id($ueQuery); ?>
147
     <td><a href="<?=display_str($UserURL)?>"><?=Users::format_username($UserID2, false, false, true)?></a></td>
147
     <td><a href="<?=display_str($UserURL)?>"><?=Users::format_username($UserID2, false, false, true)?></a></td>
148
   </tr>
148
   </tr>
149
-<?
150
-    }
149
+  <?php
150
+      }
151
   }
151
   }
152
 } ?>
152
 } ?>
153
 </table>
153
 </table>
154
-<? View::show_footer(); ?>
154
+<?php View::show_footer();

+ 183
- 158
sections/userhistory/email_history2.php View File

1
-<?
1
+<?php
2
+#declare(strict_types=1);
3
+
2
 /************************************************************************
4
 /************************************************************************
3
 ||------------|| User email history page ||---------------------------||
5
 ||------------|| User email history page ||---------------------------||
4
 
6
 
12
 
14
 
13
 $UserID = $_GET['userid'];
15
 $UserID = $_GET['userid'];
14
 if (!is_number($UserID)) {
16
 if (!is_number($UserID)) {
15
-  error(404);
17
+    error(404);
16
 }
18
 }
17
 
19
 
18
 $DB->query("
20
 $DB->query("
26
 list($Joined, $Class) = $DB->next_record();
28
 list($Joined, $Class) = $DB->next_record();
27
 
29
 
28
 if (!check_perms('users_view_email', $Class)) {
30
 if (!check_perms('users_view_email', $Class)) {
29
-  error(403);
31
+    error(403);
30
 }
32
 }
31
 
33
 
32
 // todo: Is this even used?
34
 // todo: Is this even used?
40
 View::show_header("Email history for $Username");
42
 View::show_header("Email history for $Username");
41
 
43
 
42
 // Get current email (and matches)
44
 // Get current email (and matches)
43
-$DB->query("
45
+$DB->query(
46
+    "
44
   SELECT
47
   SELECT
45
     m.Email,
48
     m.Email,
46
     NOW() AS Time,
49
     NOW() AS Time,
63
 $CurrentEmail = ($DB->to_array())[0]; // Only variables should be passed by reference
66
 $CurrentEmail = ($DB->to_array())[0]; // Only variables should be passed by reference
64
 
67
 
65
 // Get historic emails (and matches)
68
 // Get historic emails (and matches)
66
-$DB->query("
69
+$DB->query(
70
+    "
67
   SELECT
71
   SELECT
68
     h2.Email,
72
     h2.Email,
69
     h2.Time,
73
     h2.Time,
93
 
97
 
94
 // Matches for current email
98
 // Matches for current email
95
 if ($CurrentEmail['Usernames'] != '') {
99
 if ($CurrentEmail['Usernames'] != '') {
96
-  $UserIDs = explode('|', $CurrentEmail['UserIDs']);
97
-  $Usernames = explode('|', $CurrentEmail['Usernames']);
98
-  $UsersEnabled = explode('|', $CurrentEmail['UsersEnabled']);
99
-  $UsersDonor = explode('|', $CurrentEmail['UsersDonor']);
100
-  $UsersWarned = explode('|', $CurrentEmail['UsersWarned']);
101
-  $UserSetTimes = explode('|', $CurrentEmail['UserSetTimes']);
102
-  $UserIPs = explode('|', $CurrentEmail['UserIPs']);
100
+    $UserIDs = explode('|', $CurrentEmail['UserIDs']);
101
+    $Usernames = explode('|', $CurrentEmail['Usernames']);
102
+    $UsersEnabled = explode('|', $CurrentEmail['UsersEnabled']);
103
+    $UsersDonor = explode('|', $CurrentEmail['UsersDonor']);
104
+    $UsersWarned = explode('|', $CurrentEmail['UsersWarned']);
105
+    $UserSetTimes = explode('|', $CurrentEmail['UserSetTimes']);
106
+    $UserIPs = explode('|', $CurrentEmail['UserIPs']);
103
 
107
 
104
-  foreach ($UserIDs as $Key => $Val) {
105
-    $CurrentMatches[$Key]['Username'] = '&nbsp;&nbsp;&#187;&nbsp;'.Users::format_username($Val, true, true, true);
106
-    $CurrentMatches[$Key]['IP'] = $UserIPs[$Key];
107
-    $CurrentMatches[$Key]['EndTime'] = $UserSetTimes[$Key];
108
-  }
108
+    foreach ($UserIDs as $Key => $Val) {
109
+        $CurrentMatches[$Key]['Username'] = '&nbsp;&nbsp;&#187;&nbsp;'.Users::format_username($Val, true, true, true);
110
+        $CurrentMatches[$Key]['IP'] = $UserIPs[$Key];
111
+        $CurrentMatches[$Key]['EndTime'] = $UserSetTimes[$Key];
112
+    }
109
 }
113
 }
110
 
114
 
111
 // Email history records
115
 // Email history records
112
 if (count($History) === 1) {
116
 if (count($History) === 1) {
113
-  $Invite['Email'] = $History[0]['Email'];
114
-  $Invite['EndTime'] = $Joined;
115
-  $Invite['AccountAge'] = date(time() + time() - strtotime($Joined)); // Same as EndTime but without ' ago'
116
-  $Invite['IP'] = $History[0]['IP'];
117
-  if (!$Current['StartTime']) {
118
-    $Current['StartTime'] = $Joined;
119
-  }
120
-} else {
121
-  foreach ($History as $Key => $Val) {
122
-    if (isset($History[$Key + 1]) && !$History[$Key + 1]['Time'] && !$Val['Time']) {
123
-      // Invited email
124
-      $Invite['Email'] = $Val['Email'];
125
-      $Invite['EndTime'] = $Joined;
126
-      $Invite['AccountAge'] = date(time() + time() - strtotime($Joined)); // Same as EndTime but without ' ago'
127
-      $Invite['IP'] = $Val['IP'];
128
-
129
-    } elseif (isset($History[$Key - 1]) && $History[$Key - 1]['Email'] != $Val['Email'] && $Val['Time']) {
130
-      // Old email
131
-      $i = 1;
132
-      while ($Val['Email'] == $History[$Key + $i]['Email']) {
133
-        $i++;
134
-      }
135
-      $Old[$Key]['StartTime'] = (isset($History[$Key + $i]) && $History[$Key + $i]['Time']) ? $History[$Key + $i]['Time'] : $Joined;
136
-      $Old[$Key]['EndTime'] = $Val['Time'];
137
-      $Old[$Key]['IP'] = $Val['IP'];
138
-      $Old[$Key]['ElapsedTime'] = date(time() + strtotime($Old[$Key]['EndTime']) - strtotime($Old[$Key]['StartTime']));
139
-      $Old[$Key]['Email'] = $Val['Email'];
117
+    $Invite['Email'] = $History[0]['Email'];
118
+    $Invite['EndTime'] = $Joined;
119
+    $Invite['AccountAge'] = date(time() + time() - strtotime($Joined)); // Same as EndTime but without ' ago'
120
+    $Invite['IP'] = $History[0]['IP'];
121
+    if (!$Current['StartTime']) {
122
+        $Current['StartTime'] = $Joined;
140
     }
123
     }
124
+} else {
125
+    foreach ($History as $Key => $Val) {
126
+        if (isset($History[$Key + 1]) && !$History[$Key + 1]['Time'] && !$Val['Time']) {
127
+            // Invited email
128
+            $Invite['Email'] = $Val['Email'];
129
+            $Invite['EndTime'] = $Joined;
130
+            $Invite['AccountAge'] = date(time() + time() - strtotime($Joined)); // Same as EndTime but without ' ago'
131
+            $Invite['IP'] = $Val['IP'];
132
+        } elseif (isset($History[$Key - 1]) && $History[$Key - 1]['Email'] != $Val['Email'] && $Val['Time']) {
133
+            // Old email
134
+            $i = 1;
135
+            while ($Val['Email'] == $History[$Key + $i]['Email']) {
136
+                $i++;
137
+            }
138
+            $Old[$Key]['StartTime'] = (isset($History[$Key + $i]) && $History[$Key + $i]['Time']) ? $History[$Key + $i]['Time'] : $Joined;
139
+            $Old[$Key]['EndTime'] = $Val['Time'];
140
+            $Old[$Key]['IP'] = $Val['IP'];
141
+            $Old[$Key]['ElapsedTime'] = date(time() + strtotime($Old[$Key]['EndTime']) - strtotime($Old[$Key]['StartTime']));
142
+            $Old[$Key]['Email'] = $Val['Email'];
143
+        }
141
 
144
 
142
-    if ($Val['Usernames'] != '') {
143
-      // Match with old email
144
-      $OldMatches[$Key]['Email'] = $Val['Email'];
145
-      $OldMatches[$Key]['Username'] = '&nbsp;&nbsp;&#187;&nbsp;'.Users::format_username($Val['UserIDs'], true, true, true);
146
-      $OldMatches[$Key]['EndTime'] = $Val['UserSetTimes'];
147
-      $OldMatches[$Key]['IP'] = $Val['UserIPs'];
145
+        if ($Val['Usernames'] != '') {
146
+            // Match with old email
147
+            $OldMatches[$Key]['Email'] = $Val['Email'];
148
+            $OldMatches[$Key]['Username'] = '&nbsp;&nbsp;&#187;&nbsp;'.Users::format_username($Val['UserIDs'], true, true, true);
149
+            $OldMatches[$Key]['EndTime'] = $Val['UserSetTimes'];
150
+            $OldMatches[$Key]['IP'] = $Val['UserIPs'];
151
+        }
148
     }
152
     }
149
-  }
150
 }
153
 }
151
 
154
 
152
 // Clean up arrays
155
 // Clean up arrays
153
 if ($Old ?? false) {
156
 if ($Old ?? false) {
154
-  $Old = array_reverse(array_reverse($Old));
155
-  $LastOld = count($Old) - 1;
156
-  if ($Old[$LastOld]['StartTime'] != $Invite['EndTime']) {
157
-    // Make sure the timeline is intact (invite email was used as email for the account in the beginning)
158
-    $Old[$LastOld + 1]['Email'] = $Invite['Email'];
159
-    $Old[$LastOld + 1]['StartTime'] = $Invite['EndTime'];
160
-    $Old[$LastOld + 1]['EndTime'] = $Old[$LastOld]['StartTime'];
161
-    $Old[$LastOld + 1]['ElapsedTime'] = date(time() + strtotime($Old[$LastOld + 1]['EndTime'] ) - strtotime($Old[$LastOld + 1]['StartTime']));
162
-    $Old[$LastOld + 1]['IP'] = $Invite['IP'];
163
-  }
157
+    $Old = array_reverse(array_reverse($Old));
158
+    $LastOld = count($Old) - 1;
159
+    if ($Old[$LastOld]['StartTime'] != $Invite['EndTime']) {
160
+        // Make sure the timeline is intact (invite email was used as email for the account in the beginning)
161
+        $Old[$LastOld + 1]['Email'] = $Invite['Email'];
162
+        $Old[$LastOld + 1]['StartTime'] = $Invite['EndTime'];
163
+        $Old[$LastOld + 1]['EndTime'] = $Old[$LastOld]['StartTime'];
164
+        $Old[$LastOld + 1]['ElapsedTime'] = date(time() + strtotime($Old[$LastOld + 1]['EndTime']) - strtotime($Old[$LastOld + 1]['StartTime']));
165
+        $Old[$LastOld + 1]['IP'] = $Invite['IP'];
166
+    }
164
 }
167
 }
165
 
168
 
166
 // Start page with current email
169
 // Start page with current email
169
   <div class="header">
172
   <div class="header">
170
     <h2>Email history for <a href="user.php?id=<?=$UserID ?>"><?=$Username ?></a></h2>
173
     <h2>Email history for <a href="user.php?id=<?=$UserID ?>"><?=$Username ?></a></h2>
171
     <div class="linkbox center">
174
     <div class="linkbox center">
172
-      <a href="userhistory.php?action=email&amp;userid=<?=$UserID?>" class="brackets">Old email history</a>
175
+      <a href="userhistory.php?action=email&amp;userid=<?=$UserID?>"
176
+        class="brackets">Old email history</a>
173
     </div>
177
     </div>
174
   </div>
178
   </div>
175
   <br />
179
   <br />
178
       <td>Current email</td>
182
       <td>Current email</td>
179
       <td>Start</td>
183
       <td>Start</td>
180
       <td>End</td>
184
       <td>End</td>
181
-      <td>Current IP <a href="userhistory.php?action=ips&amp;userid=<?=$UserID ?>" class="brackets">H</a></td>
185
+      <td>Current IP <a
186
+          href="userhistory.php?action=ips&amp;userid=<?=$UserID ?>"
187
+          class="brackets">H</a></td>
182
       <td>Set from IP</td>
188
       <td>Set from IP</td>
183
     </tr>
189
     </tr>
184
-<?
190
+    <?php
185
 $Current['Email'] = apcu_exists('DBKEY') ? Crypto::decrypt($Current['Email']) : '[Encrypted]';
191
 $Current['Email'] = apcu_exists('DBKEY') ? Crypto::decrypt($Current['Email']) : '[Encrypted]';
186
 $Current['CurrentIP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Current['CurrentIP']) : '[Encrypted]';
192
 $Current['CurrentIP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Current['CurrentIP']) : '[Encrypted]';
187
 $Current['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Current['IP']) : '[Encrypted]';
193
 $Current['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Current['IP']) : '[Encrypted]';
188
 ?>
194
 ?>
189
     <tr class="row">
195
     <tr class="row">
190
-      <td><?=display_str($Current['Email'])?></td>
191
-      <td><?=time_diff($Current['StartTime'])?></td>
196
+      <td><?=display_str($Current['Email'])?>
197
+      </td>
198
+      <td><?=time_diff($Current['StartTime'])?>
199
+      </td>
192
       <td></td>
200
       <td></td>
193
       <td>
201
       <td>
194
         <?=display_str($Current['CurrentIP'])?>
202
         <?=display_str($Current['CurrentIP'])?>
195
-        (<?=Tools::get_country_code_by_ajax($Current['CurrentIP'])?>)
196
-        <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Current['CurrentIP'])?>" class="brackets tooltip" title="Search">S</a>
197
-        <a href="http://whatismyipaddress.com/ip/<?=display_str($Current['CurrentIP'])?>" class="brackets tooltip" title="Search WIMIA.com">WI</a>
203
+        <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Current['CurrentIP'])?>"
204
+          class="brackets tooltip" title="Search">S</a>
205
+        <a href="http://whatismyipaddress.com/ip/<?=display_str($Current['CurrentIP'])?>"
206
+          class="brackets tooltip" title="Search WIMIA.com">WI</a>
198
         <br />
207
         <br />
199
         <?=Tools::get_host_by_ajax($Current['CurrentIP'])?>
208
         <?=Tools::get_host_by_ajax($Current['CurrentIP'])?>
200
       </td>
209
       </td>
201
       <td>
210
       <td>
202
         <?=display_str($Current['IP'])?>
211
         <?=display_str($Current['IP'])?>
203
-        (<?=Tools::get_country_code_by_ajax($Current['IP'])?>)
204
-        <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Current['IP'])?>" class="brackets tooltip" title="Search">S</a>
205
-        <a href="http://whatismyipaddress.com/ip/<?=display_str($Current['IP'])?>" class="brackets tooltip" title="Search WIMIA.com">WI</a>
212
+        <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Current['IP'])?>"
213
+          class="brackets tooltip" title="Search">S</a>
214
+        <a href="http://whatismyipaddress.com/ip/<?=display_str($Current['IP'])?>"
215
+          class="brackets tooltip" title="Search WIMIA.com">WI</a>
206
         <br />
216
         <br />
207
         <?=Tools::get_host_by_ajax($Current['IP'])?>
217
         <?=Tools::get_host_by_ajax($Current['IP'])?>
208
       </td>
218
       </td>
209
     </tr>
219
     </tr>
210
-<?
220
+    <?php
211
 if ($CurrentMatches ?? false) {
221
 if ($CurrentMatches ?? false) {
212
-  // Match on the current email
213
-  foreach ($CurrentMatches as $Match) {
214
-    $Match['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Match['IP']) : '[Encrypted]';
215
-?>
222
+    // Match on the current email
223
+    foreach ($CurrentMatches as $Match) {
224
+        $Match['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Match['IP']) : '[Encrypted]'; ?>
216
     <tr class="row">
225
     <tr class="row">
217
-      <td><?=$Match['Username']?></td>
226
+      <td><?=$Match['Username']?>
227
+      </td>
218
       <td></td>
228
       <td></td>
219
-      <td><?=time_diff($Match['EndTime'])?></td>
229
+      <td><?=time_diff($Match['EndTime'])?>
230
+      </td>
220
       <td></td>
231
       <td></td>
221
       <td>
232
       <td>
222
         <?=display_str($Match['IP'])?>
233
         <?=display_str($Match['IP'])?>
223
-        (<?=Tools::get_country_code_by_ajax($Match['IP'])?>)
224
-        <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Match['IP'])?>" class="brackets tooltip" title="Search">S</a>
225
-        <a href="http://whatismyipaddress.com/ip/<?=display_str($Match['IP'])?>" class="brackets tooltip" title="Search WIMIA.com">WI</a>
234
+        <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Match['IP'])?>"
235
+          class="brackets tooltip" title="Search">S</a>
236
+        <a href="http://whatismyipaddress.com/ip/<?=display_str($Match['IP'])?>"
237
+          class="brackets tooltip" title="Search WIMIA.com">WI</a>
226
         <br />
238
         <br />
227
         <?=Tools::get_host_by_ajax($Match['IP'])?>
239
         <?=Tools::get_host_by_ajax($Match['IP'])?>
228
       </td>
240
       </td>
229
     </tr>
241
     </tr>
230
-<?
231
-  }
242
+    <?php
243
+    }
232
 }
244
 }
233
 // Old emails
245
 // Old emails
234
 if ($Old ?? false) {
246
 if ($Old ?? false) {
235
-?>
247
+    ?>
236
     <tr class="colhead">
248
     <tr class="colhead">
237
       <td>Old emails</td>
249
       <td>Old emails</td>
238
       <td>Start</td>
250
       <td>Start</td>
240
       <td>Elapsed</td>
252
       <td>Elapsed</td>
241
       <td>Set from IP</td>
253
       <td>Set from IP</td>
242
     </tr>
254
     </tr>
243
-<?
255
+    <?php
244
   $j = 0;
256
   $j = 0;
245
-  // Old email
246
-  foreach ($Old as $Record) {
247
-    ++$j;
257
+    // Old email
258
+    foreach ($Old as $Record) {
259
+        ++$j;
248
 
260
 
249
-    // Matches on old email
250
-    ob_start();
251
-    $i = 0;
252
-    if ($OldMatches ?? false) {
253
-      foreach ($OldMatches as $Match) {
254
-        if ($Match['Email'] == $Record['Email']) {
255
-          ++$i;
256
-          // Email matches
261
+        // Matches on old email
262
+        ob_start();
263
+        $i = 0;
264
+        if ($OldMatches ?? false) {
265
+            foreach ($OldMatches as $Match) {
266
+                if ($Match['Email'] == $Record['Email']) {
267
+                    ++$i;
268
+                    // Email matches
257
   ?>
269
   ?>
258
-      <tr class="row hidden" id="matches_<?=$j?>">
259
-        <td><?=$Match['Username']?></td>
260
-        <td></td>
261
-        <td><?=time_diff($Match['EndTime'])?></td>
262
-        <td></td>
263
-        <td>
264
-          <?=display_str($Match['IP'])?>
265
-          (<?=Tools::get_country_code_by_ajax($Match['IP'])?>)
266
-          <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Match['IP'])?>" class="brackets tooltip" title="Search">S</a>
267
-          <a href="http://whatismyipaddress.com/ip/<?=display_str($Match['IP'])?>" class="brackets tooltip" title="Search WIMIA.com">WI</a>
268
-          <br />
269
-          <?=Tools::get_host_by_ajax($Match['IP'])?>
270
-        </td>
271
-      </tr>
272
-  <?
270
+    <tr class="row hidden" id="matches_<?=$j?>">
271
+      <td><?=$Match['Username']?>
272
+      </td>
273
+      <td></td>
274
+      <td><?=time_diff($Match['EndTime'])?>
275
+      </td>
276
+      <td></td>
277
+      <td>
278
+        <?=display_str($Match['IP'])?>
279
+        <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Match['IP'])?>"
280
+          class="brackets tooltip" title="Search">S</a>
281
+        <a href="http://whatismyipaddress.com/ip/<?=display_str($Match['IP'])?>"
282
+          class="brackets tooltip" title="Search WIMIA.com">WI</a>
283
+        <br />
284
+        <?=Tools::get_host_by_ajax($Match['IP'])?>
285
+      </td>
286
+    </tr>
287
+    <?php
288
+                }
289
+            }
273
         }
290
         }
274
-      }
275
-    }
276
 
291
 
277
-    // Save matches to variable
278
-    $MatchCount = $i;
279
-    $Matches = ob_get_contents();
280
-    ob_end_clean();
292
+        // Save matches to variable
293
+        $MatchCount = $i;
294
+        $Matches = ob_get_contents();
295
+        ob_end_clean();
281
 
296
 
282
-    $Record['Email'] = apcu_exists('DBKEY') ? Crypto::decrypt($Record['Email']) : '[Encrypted]';
283
-    $Record['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Record['IP']) : '[Encrypted]';
284
-?>
297
+        $Record['Email'] = apcu_exists('DBKEY') ? Crypto::decrypt($Record['Email']) : '[Encrypted]';
298
+        $Record['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Record['IP']) : '[Encrypted]'; ?>
285
     <tr class="row">
299
     <tr class="row">
286
-      <td><?=display_str($Record['Email'])?><?=(($MatchCount > 0) ? ' <a data-toggle-target="#matches_'.$j.'">('.$MatchCount.')</a>' : '')?></td>
287
-      <td><?=time_diff($Record['StartTime'])?></td>
288
-      <td><?=time_diff($Record['EndTime'])?></td>
289
-      <td><?=time_diff($Record['ElapsedTime'])?></td>
300
+      <td><?=display_str($Record['Email'])?><?=(($MatchCount > 0) ? ' <a data-toggle-target="#matches_'.$j.'">('.$MatchCount.')</a>' : '')?>
301
+      </td>
302
+      <td><?=time_diff($Record['StartTime'])?>
303
+      </td>
304
+      <td><?=time_diff($Record['EndTime'])?>
305
+      </td>
306
+      <td><?=time_diff($Record['ElapsedTime'])?>
307
+      </td>
290
       <td>
308
       <td>
291
         <?=display_str($Record['IP'])?>
309
         <?=display_str($Record['IP'])?>
292
-        (<?=Tools::get_country_code_by_ajax($Record['IP'])?>)
293
-        <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Record['IP'])?>" class="brackets tooltip" title="Search">S</a>
294
-        <a href="http://whatismyipaddress.com/ip/<?=display_str($Record['IP'])?>" class="brackets tooltip" title="Search WIMIA.com">WI</a>
310
+        <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Record['IP'])?>"
311
+          class="brackets tooltip" title="Search">S</a>
312
+        <a href="http://whatismyipaddress.com/ip/<?=display_str($Record['IP'])?>"
313
+          class="brackets tooltip" title="Search WIMIA.com">WI</a>
295
         <br />
314
         <br />
296
         <?=Tools::get_host_by_ajax($Record['IP'])?>
315
         <?=Tools::get_host_by_ajax($Record['IP'])?>
297
       </td>
316
       </td>
298
     </tr>
317
     </tr>
299
-<?
318
+    <?php
300
     if ($MatchCount > 0) {
319
     if ($MatchCount > 0) {
301
-      if (isset($Matches)) {
302
-        echo $Matches;
303
-        unset($Matches);
304
-        unset($MatchCount);
305
-      }
320
+        if (isset($Matches)) {
321
+            echo $Matches;
322
+            unset($Matches);
323
+            unset($MatchCount);
324
+        }
325
+    }
306
     }
326
     }
307
-  }
308
 }
327
 }
309
 // Invite email (always there)
328
 // Invite email (always there)
310
 ?>
329
 ?>
315
       <td>Age of account</td>
334
       <td>Age of account</td>
316
       <td>Registration IP address</td>
335
       <td>Registration IP address</td>
317
     </tr>
336
     </tr>
318
-<?
337
+    <?php
319
 // Matches on invite email
338
 // Matches on invite email
320
 $i = 0;
339
 $i = 0;
321
 ob_start();
340
 ob_start();
322
 if ($OldMatches ?? false) {
341
 if ($OldMatches ?? false) {
323
-  foreach ($OldMatches as $Match) {
324
-    if ($Match['Email'] == $Invite['Email']) {
325
-      ++$i;
326
-      // Match email is the same as the invite email
342
+    foreach ($OldMatches as $Match) {
343
+        if ($Match['Email'] == $Invite['Email']) {
344
+            ++$i;
345
+            // Match email is the same as the invite email
327
 
346
 
328
-      $Match['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Match['IP']) : '[Encrypted]';
329
-?>
347
+            $Match['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Match['IP']) : '[Encrypted]'; ?>
330
     <tr class="row hidden" id="matches_invite">
348
     <tr class="row hidden" id="matches_invite">
331
-      <td><?=$Match['Username']?></td>
349
+      <td><?=$Match['Username']?>
350
+      </td>
332
       <td></td>
351
       <td></td>
333
-      <td><?=time_diff($Match['EndTime'])?></td>
352
+      <td><?=time_diff($Match['EndTime'])?>
353
+      </td>
334
       <td></td>
354
       <td></td>
335
       <td>
355
       <td>
336
         <?=display_str($Match['IP'])?>
356
         <?=display_str($Match['IP'])?>
337
-        (<?=Tools::get_country_code_by_ajax($Match['IP'])?>)
338
-        <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Match['IP'])?>" class="brackets tooltip" title="Search">S</a>
339
-        <a href="http://whatismyipaddress.com/ip/<?=display_str($Match['IP'])?>" class="brackets tooltip" title="Search WIMIA.com">WI</a>
357
+        <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Match['IP'])?>"
358
+          class="brackets tooltip" title="Search">S</a>
359
+        <a href="http://whatismyipaddress.com/ip/<?=display_str($Match['IP'])?>"
360
+          class="brackets tooltip" title="Search WIMIA.com">WI</a>
340
         <br />
361
         <br />
341
         <?=Tools::get_host_by_ajax($Match['IP'])?>
362
         <?=Tools::get_host_by_ajax($Match['IP'])?>
342
       </td>
363
       </td>
343
     </tr>
364
     </tr>
344
-<?
365
+    <?php
366
+        }
345
     }
367
     }
346
-  }
347
 }
368
 }
348
 $MatchCount = $i;
369
 $MatchCount = $i;
349
 $Matches = ob_get_contents();
370
 $Matches = ob_get_contents();
353
 $Invite['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Invite['IP']) : '[Encrypted]';
374
 $Invite['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Invite['IP']) : '[Encrypted]';
354
 ?>
375
 ?>
355
     <tr class="row">
376
     <tr class="row">
356
-      <td><?=display_str($Invite['Email'])?><?=(($MatchCount > 0) ? ' <a data-toggle-target="#matches_invite">('.$MatchCount.')</a>' : '')?></td>
377
+      <td><?=display_str($Invite['Email'])?><?=(($MatchCount > 0) ? ' <a data-toggle-target="#matches_invite">('.$MatchCount.')</a>' : '')?>
378
+      </td>
357
       <td>Never</td>
379
       <td>Never</td>
358
-      <td><?=time_diff($Invite['EndTime'])?></td>
359
-      <td><?=time_diff($Invite['AccountAge'])?></td>
380
+      <td><?=time_diff($Invite['EndTime'])?>
381
+      </td>
382
+      <td><?=time_diff($Invite['AccountAge'])?>
383
+      </td>
360
       <td>
384
       <td>
361
         <?=display_str($Invite['IP'])?>
385
         <?=display_str($Invite['IP'])?>
362
-        (<?=Tools::get_country_code_by_ajax($Invite['IP'])?>)
363
-        <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Invite['IP'])?>" class="brackets tooltip" title="Search">S</a>
364
-        <a href="http://whatismyipaddress.com/ip/<?=display_str($Invite['IP'])?>" class="brackets tooltip" title="Search WIMIA.com">WI</a>
386
+        <a href="user.php?action=search&amp;ip_history=on&amp;ip=<?=display_str($Invite['IP'])?>"
387
+          class="brackets tooltip" title="Search">S</a>
388
+        <a href="http://whatismyipaddress.com/ip/<?=display_str($Invite['IP'])?>"
389
+          class="brackets tooltip" title="Search WIMIA.com">WI</a>
365
         <br />
390
         <br />
366
         <?=Tools::get_host_by_ajax($Invite['IP'])?>
391
         <?=Tools::get_host_by_ajax($Invite['IP'])?>
367
       </td>
392
       </td>
368
     </tr>
393
     </tr>
369
-<?
394
+    <?php
370
 
395
 
371
 if ($Matches) {
396
 if ($Matches) {
372
-  echo $Matches;
397
+    echo $Matches;
373
 }
398
 }
374
 
399
 
375
 ?>
400
 ?>
376
   </table>
401
   </table>
377
 </div>
402
 </div>
378
-<? View::show_footer(); ?>
403
+<?php View::show_footer();

+ 150
- 123
sections/userhistory/ip_history.php View File

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

+ 34
- 30
sections/userhistory/ip_tracker_history.php View File

1
 <?php
1
 <?php
2
+#declare(strict_types=1);
3
+
2
 /************************************************************************
4
 /************************************************************************
3
 ||------------|| User IP history page ||---------------------------||
5
 ||------------|| User IP history page ||---------------------------||
4
 
6
 
13
 define('IPS_PER_PAGE', 25);
15
 define('IPS_PER_PAGE', 25);
14
 
16
 
15
 if (!check_perms('users_mod')) {
17
 if (!check_perms('users_mod')) {
16
-  error(403);
18
+    error(403);
17
 }
19
 }
18
 
20
 
19
 $UserID = $_GET['userid'];
21
 $UserID = $_GET['userid'];
20
 if (!is_number($UserID)) {
22
 if (!is_number($UserID)) {
21
-  error(404);
23
+    error(404);
22
 }
24
 }
23
 
25
 
24
 $DB->query("
26
 $DB->query("
30
 list($Username, $Class) = $DB->next_record();
32
 list($Username, $Class) = $DB->next_record();
31
 
33
 
32
 if (!check_perms('users_view_ips', $Class)) {
34
 if (!check_perms('users_view_ips', $Class)) {
33
-  error(403);
35
+    error(403);
34
 }
36
 }
35
 
37
 
36
 $UsersOnly = $_GET['usersonly'];
38
 $UsersOnly = $_GET['usersonly'];
38
 View::show_header("Tracker IP address history for $Username");
40
 View::show_header("Tracker IP address history for $Username");
39
 ?>
41
 ?>
40
 <script type="text/javascript">
42
 <script type="text/javascript">
41
-function ShowIPs(rowname) {
42
-  $('tr[name="'+rowname+'"]').gtoggle();
43
-}
43
+  function ShowIPs(rowname) {
44
+    $('tr[name="' + rowname + '"]').gtoggle();
45
+  }
44
 </script>
46
 </script>
45
-<?
47
+<?php
46
 list($Page, $Limit) = Format::page_limit(IPS_PER_PAGE);
48
 list($Page, $Limit) = Format::page_limit(IPS_PER_PAGE);
47
 
49
 
48
 $Perms = get_permissions_for_user($UserID);
50
 $Perms = get_permissions_for_user($UserID);
49
-if ($Perms['site_disable_ip_history']) $Limit = 0;
51
+if ($Perms['site_disable_ip_history']) {
52
+    $Limit = 0;
53
+}
50
 
54
 
51
 $TrackerIps = $DB->query("
55
 $TrackerIps = $DB->query("
52
   SELECT IP, fid, tstamp
56
   SELECT IP, fid, tstamp
65
 ?>
69
 ?>
66
 <div>
70
 <div>
67
   <div class="header">
71
   <div class="header">
68
-    <h2>Tracker IP address history for <a href="user.php?id=<?=$UserID?>"><?=$Username?></a></h2>
72
+    <h2>Tracker IP address history for <a
73
+        href="user.php?id=<?=$UserID?>"><?=$Username?></a></h2>
74
+  </div>
75
+  <div class="linkbox"><?=$Pages?>
69
   </div>
76
   </div>
70
-  <div class="linkbox"><?=$Pages?></div>
71
   <table>
77
   <table>
72
     <tr class="colhead">
78
     <tr class="colhead">
73
       <td>IP address</td>
79
       <td>IP address</td>
74
       <td>Torrent</td>
80
       <td>Torrent</td>
75
       <td>Time</td>
81
       <td>Time</td>
76
     </tr>
82
     </tr>
77
-<?
83
+    <?php
78
 $Results = $DB->to_array();
84
 $Results = $DB->to_array();
79
 foreach ($Results as $Index => $Result) {
85
 foreach ($Results as $Index => $Result) {
80
-  list($IP, $TorrentID, $Time) = $Result;
81
-
82
-?>
83
-  <tr class="row">
84
-    <td>
85
-      <?=$IP?> (<?=Tools::get_country_code_by_ajax($IP)?>)<br /><?=Tools::get_host_by_ajax($IP)?>
86
-      <a href="http://whatismyipaddress.com/ip/<?=display_str($IP)?>" class="brackets tooltip" title="Search WIMIA.com">WI</a>
87
-    </td>
88
-    <td><a href="torrents.php?torrentid=<?=$TorrentID?>"><?=$TorrentID?></a></td>
89
-    <td><?=date('Y-m-d g:i:s', $Time)?></td>
90
-  </tr>
91
-<?
86
+    list($IP, $TorrentID, $Time) = $Result; ?>
87
+    <tr class="row">
88
+      <td>
89
+        <?=$IP?><br /><?=Tools::get_host_by_ajax($IP)?>
90
+        <a href="http://whatismyipaddress.com/ip/<?=display_str($IP)?>"
91
+          class="brackets tooltip" title="Search WIMIA.com">WI</a>
92
+      </td>
93
+      <td><a href="torrents.php?torrentid=<?=$TorrentID?>"><?=$TorrentID?></a></td>
94
+      <td><?=date('Y-m-d g:i:s', $Time)?>
95
+      </td>
96
+    </tr>
97
+    <?php
92
 }
98
 }
93
 ?>
99
 ?>
94
-</table>
95
-<div class="linkbox">
96
-  <?=$Pages?>
97
-</div>
100
+  </table>
101
+  <div class="linkbox">
102
+    <?=$Pages?>
103
+  </div>
98
 </div>
104
 </div>
99
 
105
 
100
-<?
101
-View::show_footer();
102
-?>
106
+<?php View::show_footer();

Loading…
Cancel
Save