Browse Source

Rename DBCrypt class to Crypto

spaghetti 7 years ago
parent
commit
53e3dca294
35 changed files with 95 additions and 95 deletions
  1. 3
    3
      classes/autoenable.class.php
  2. 2
    2
      classes/crypto.class.php
  3. 1
    1
      classes/misc.class.php
  4. 7
    7
      classes/script_start.php
  5. 1
    1
      design/privatefooter.php
  6. 1
    1
      sections/ajax/inbox/viewconv.php
  7. 1
    1
      sections/delete/delete_email.php
  8. 1
    1
      sections/delete/delete_ip.php
  9. 2
    2
      sections/delete/take_delete_email.php
  10. 2
    2
      sections/delete/take_delete_ip.php
  11. 1
    1
      sections/inbox/conversation.php
  12. 1
    1
      sections/inbox/get_post.php
  13. 8
    8
      sections/login/index.php
  14. 5
    5
      sections/register/index.php
  15. 1
    1
      sections/schedule/daily/disable_inactive_users.php
  16. 1
    1
      sections/schedule/manually/update_geodist.php
  17. 2
    2
      sections/tools/data/invite_pool.php
  18. 4
    4
      sections/tools/data/registration_log.php
  19. 2
    2
      sections/tools/managers/enable_requests.php
  20. 2
    2
      sections/tools/managers/expunge_requests.php
  21. 1
    1
      sections/tools/misc/create_user.php
  22. 4
    4
      sections/user/advancedsearch.php
  23. 1
    1
      sections/user/edit.php
  24. 2
    2
      sections/user/invite.php
  25. 1
    1
      sections/user/sessions.php
  26. 5
    5
      sections/user/take_edit.php
  27. 2
    2
      sections/user/take_invite.php
  28. 6
    6
      sections/user/takemoderate.php
  29. 4
    4
      sections/user/user.php
  30. 2
    2
      sections/userhistory/email_history.php
  31. 9
    9
      sections/userhistory/email_history2.php
  32. 4
    4
      sections/userhistory/email_history_userview.php
  33. 1
    1
      sections/userhistory/ip_history.php
  34. 4
    4
      sections/userhistory/ip_history_userview.php
  35. 1
    1
      sections/userhistory/password_history.php

+ 3
- 3
classes/autoenable.class.php View File

74
                 INSERT INTO users_enable_requests
74
                 INSERT INTO users_enable_requests
75
                 (UserID, Email, IP, UserAgent, Timestamp)
75
                 (UserID, Email, IP, UserAgent, Timestamp)
76
                 VALUES (?, ?, ?, ?, NOW())",
76
                 VALUES (?, ?, ?, ?, NOW())",
77
-                $UserID, DBCrypt::encrypt($Email), DBCrypt::encrypt($IP), $UserAgent);
77
+                $UserID, Crypto::encrypt($Email), Crypto::encrypt($IP), $UserAgent);
78
 
78
 
79
             // Cache the number of requests for the modbar
79
             // Cache the number of requests for the modbar
80
             G::$Cache->increment_value(self::CACHE_KEY_NAME);
80
             G::$Cache->increment_value(self::CACHE_KEY_NAME);
132
 
132
 
133
             foreach ($Results as $Result) {
133
             foreach ($Results as $Result) {
134
                 list($Email, $ID, $UserID) = $Result;
134
                 list($Email, $ID, $UserID) = $Result;
135
-                $Email = DBCrypt::decrypt($Email);
135
+                $Email = Crypto::decrypt($Email);
136
                 $UserInfo[] = array($ID, $UserID);
136
                 $UserInfo[] = array($ID, $UserID);
137
 
137
 
138
                 if ($Status == self::APPROVED) {
138
                 if ($Status == self::APPROVED) {
264
             } else {
264
             } else {
265
                 // Good request, decrement cache value and enable account
265
                 // Good request, decrement cache value and enable account
266
                 G::$Cache->decrement_value(AutoEnable::CACHE_KEY_NAME);
266
                 G::$Cache->decrement_value(AutoEnable::CACHE_KEY_NAME);
267
-                $VisibleTrIP = ($Visible && DBCrypt::decrypt($IP) != '127.0.0.1') ? '1' : '0';
267
+                $VisibleTrIP = ($Visible && Crypto::decrypt($IP) != '127.0.0.1') ? '1' : '0';
268
                 Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $TorrentPass, 'visible' => $VisibleTrIP));
268
                 Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $TorrentPass, 'visible' => $VisibleTrIP));
269
                 G::$DB->query("UPDATE users_main SET Enabled = '1', can_leech = '1' WHERE ID = '$UserID'");
269
                 G::$DB->query("UPDATE users_main SET Enabled = '1', can_leech = '1' WHERE ID = '$UserID'");
270
                 G::$DB->query("UPDATE users_info SET BanReason = '0' WHERE UserID = '$UserID'");
270
                 G::$DB->query("UPDATE users_info SET BanReason = '0' WHERE UserID = '$UserID'");

classes/dbcrypt.class.php → classes/crypto.class.php View File

1
 <?
1
 <?
2
-class DBCrypt {
2
+class Crypto {
3
   /**
3
   /**
4
    * Encrypts input text for use in database
4
    * Encrypts input text for use in database
5
    *
5
    *
10
     if (apcu_exists('DBKEY')) {
10
     if (apcu_exists('DBKEY')) {
11
       $iv_size = openssl_cipher_iv_length('AES-128-CBC');
11
       $iv_size = openssl_cipher_iv_length('AES-128-CBC');
12
       $iv = openssl_random_pseudo_bytes($iv_size);
12
       $iv = openssl_random_pseudo_bytes($iv_size);
13
-      $ret =  base64_encode($iv.openssl_encrypt($plaintext, 'AES-128-CBC', apcu_fetch('DBKEY'), OPENSSL_RAW_DATA, $iv));
13
+      $ret = base64_encode($iv.openssl_encrypt($plaintext, 'AES-128-CBC', apcu_fetch('DBKEY'), OPENSSL_RAW_DATA, $iv));
14
       return $ret;
14
       return $ret;
15
     } else {
15
     } else {
16
       return false;
16
       return false;

+ 1
- 1
classes/misc.class.php View File

50
     $UnescapedSubject = $Subject;
50
     $UnescapedSubject = $Subject;
51
     $UnescapedBody = $Body;
51
     $UnescapedBody = $Body;
52
     $Subject = db_string($Subject);
52
     $Subject = db_string($Subject);
53
-    $Body = DBCrypt::encrypt(substr($Body, 0, 49135)); // 49135 -> encryption -> 65536 (max length in mysql)
53
+    $Body = Crypto::encrypt(substr($Body, 0, 49135)); // 49135 -> encryption -> 65536 (max length in mysql)
54
     if ($ToID == 0) {
54
     if ($ToID == 0) {
55
       // Don't allow users to send messages to the system
55
       // Don't allow users to send messages to the system
56
       return;
56
       return;

+ 7
- 7
classes/script_start.php View File

191
       SET ";
191
       SET ";
192
     // Only update IP if we have an encryption key in memory
192
     // Only update IP if we have an encryption key in memory
193
     if (apcu_exists('DBKEY')) {
193
     if (apcu_exists('DBKEY')) {
194
-      $SessionQuery .= "IP = '".DBCrypt::encrypt($_SERVER['REMOTE_ADDR'])."', ";
194
+      $SessionQuery .= "IP = '".Crypto::encrypt($_SERVER['REMOTE_ADDR'])."', ";
195
     }
195
     }
196
     $SessionQuery .=
196
     $SessionQuery .=
197
        "Browser = '$Browser',
197
        "Browser = '$Browser',
206
         'SessionID' => $SessionID,
206
         'SessionID' => $SessionID,
207
         'Browser' => $Browser,
207
         'Browser' => $Browser,
208
         'OperatingSystem' => $OperatingSystem,
208
         'OperatingSystem' => $OperatingSystem,
209
-        'IP' => (apcu_exists('DBKEY') ? DBCrypt::encrypt($_SERVER['REMOTE_ADDR']) : $UserSessions[$SessionID]['IP']),
209
+        'IP' => (apcu_exists('DBKEY') ? Crypto::encrypt($_SERVER['REMOTE_ADDR']) : $UserSessions[$SessionID]['IP']),
210
         'LastUpdate' => sqltime() );
210
         'LastUpdate' => sqltime() );
211
     $Cache->insert_front($SessionID, $UsersSessionCache);
211
     $Cache->insert_front($SessionID, $UsersSessionCache);
212
     $Cache->commit_transaction(0);
212
     $Cache->commit_transaction(0);
232
 
232
 
233
   // IP changed
233
   // IP changed
234
 
234
 
235
-  if (apcu_exists('DBKEY') && DBCrypt::decrypt($LoggedUser['IP']) != $_SERVER['REMOTE_ADDR'] && !check_perms('site_disable_ip_history')) {
235
+  if (apcu_exists('DBKEY') && Crypto::decrypt($LoggedUser['IP']) != $_SERVER['REMOTE_ADDR'] && !check_perms('site_disable_ip_history')) {
236
 
236
 
237
     if (Tools::site_ban_ip($_SERVER['REMOTE_ADDR'])) {
237
     if (Tools::site_ban_ip($_SERVER['REMOTE_ADDR'])) {
238
       error('Your IP address has been banned.');
238
       error('Your IP address has been banned.');
246
       WHERE EndTime IS NULL
246
       WHERE EndTime IS NULL
247
         AND UserID = '$LoggedUser[ID]'");
247
         AND UserID = '$LoggedUser[ID]'");
248
     while (list($EncIP) = $DB->next_record()) {
248
     while (list($EncIP) = $DB->next_record()) {
249
-      if (DBCrypt::decrypt($EncIP) == $CurIP) {
249
+      if (Crypto::decrypt($EncIP) == $CurIP) {
250
         $CurIP = $EncIP;
250
         $CurIP = $EncIP;
251
         // CurIP is now the encrypted IP that was already in the database (for matching)
251
         // CurIP is now the encrypted IP that was already in the database (for matching)
252
         break;
252
         break;
262
       INSERT IGNORE INTO users_history_ips
262
       INSERT IGNORE INTO users_history_ips
263
         (UserID, IP, StartTime)
263
         (UserID, IP, StartTime)
264
       VALUES
264
       VALUES
265
-        ('$LoggedUser[ID]', '".DBCrypt::encrypt($NewIP)."', NOW())");
265
+        ('$LoggedUser[ID]', '".Crypto::encrypt($NewIP)."', NOW())");
266
 
266
 
267
     $ipcc = Tools::geoip($NewIP);
267
     $ipcc = Tools::geoip($NewIP);
268
     $DB->query("
268
     $DB->query("
269
       UPDATE users_main
269
       UPDATE users_main
270
-      SET IP = '".DBCrypt::encrypt($NewIP)."', ipcc = '$ipcc'
270
+      SET IP = '".Crypto::encrypt($NewIP)."', ipcc = '$ipcc'
271
       WHERE ID = '$LoggedUser[ID]'");
271
       WHERE ID = '$LoggedUser[ID]'");
272
     $Cache->begin_transaction('user_info_heavy_'.$LoggedUser['ID']);
272
     $Cache->begin_transaction('user_info_heavy_'.$LoggedUser['ID']);
273
-    $Cache->update_row(false, array('IP' => DBCrypt::encrypt($_SERVER['REMOTE_ADDR'])));
273
+    $Cache->update_row(false, array('IP' => Crypto::encrypt($_SERVER['REMOTE_ADDR'])));
274
     $Cache->commit_transaction(0);
274
     $Cache->commit_transaction(0);
275
 
275
 
276
 
276
 

+ 1
- 1
design/privatefooter.php View File

24
 <?  if (!empty($LastActive)) { ?>
24
 <?  if (!empty($LastActive)) { ?>
25
   <p>
25
   <p>
26
     <a href="user.php?action=sessions">
26
     <a href="user.php?action=sessions">
27
-      <span class="tooltip" title="Manage sessions">Last activity: </span><?=time_diff($LastActive['LastUpdate'])?><span class="tooltip" title="Manage sessions"> from <?=(apcu_exists('DBKEY')?(DBCrypt::decrypt($LastActive['IP'])):'[Encrypted]') ?></span>
27
+      <span class="tooltip" title="Manage sessions">Last activity: </span><?=time_diff($LastActive['LastUpdate'])?><span class="tooltip" title="Manage sessions"> from <?=(apcu_exists('DBKEY')?(Crypto::decrypt($LastActive['IP'])):'[Encrypted]') ?></span>
28
     </a>
28
     </a>
29
   </p>
29
   </p>
30
 <?  } ?>
30
 <?  } ?>

+ 1
- 1
sections/ajax/inbox/viewconv.php View File

78
 
78
 
79
 $JsonMessages = [];
79
 $JsonMessages = [];
80
 while (list($SentDate, $SenderID, $Body, $MessageID) = $DB->next_record()) {
80
 while (list($SentDate, $SenderID, $Body, $MessageID) = $DB->next_record()) {
81
-  $Body = apcu_exists('DBKEY') ? DBCrypt::decrypt($Body) : '[Encrypted]';
81
+  $Body = apcu_exists('DBKEY') ? Crypto::decrypt($Body) : '[Encrypted]';
82
   $JsonMessage = array(
82
   $JsonMessage = array(
83
     'messageId' => (int)$MessageID,
83
     'messageId' => (int)$MessageID,
84
     'senderId' => (int)$SenderID,
84
     'senderId' => (int)$SenderID,

+ 1
- 1
sections/delete/delete_email.php View File

24
   <table cellspacing="1" cellpadding="3" border="0" class="layout" width="100%">
24
   <table cellspacing="1" cellpadding="3" border="0" class="layout" width="100%">
25
     <tr>
25
     <tr>
26
       <td class="label">Email:</td>
26
       <td class="label">Email:</td>
27
-      <td><input type="text" size="30" value="<?=DBCrypt::decrypt($_GET['emails'][0])?>" disabled /></td>
27
+      <td><input type="text" size="30" value="<?=Crypto::decrypt($_GET['emails'][0])?>" disabled /></td>
28
     </tr>
28
     </tr>
29
     <tr>
29
     <tr>
30
       <td class="label">Reason (Optional):</td>
30
       <td class="label">Reason (Optional):</td>

+ 1
- 1
sections/delete/delete_ip.php View File

24
   <table cellspacing="1" cellpadding="3" border="0" class="layout" width="100%">
24
   <table cellspacing="1" cellpadding="3" border="0" class="layout" width="100%">
25
     <tr>
25
     <tr>
26
       <td class="label">IP:</td>
26
       <td class="label">IP:</td>
27
-      <td><input type="text" size="30" value="<?=DBCrypt::decrypt($_GET['ips'][0])?>" disabled /></td>
27
+      <td><input type="text" size="30" value="<?=Crypto::decrypt($_GET['ips'][0])?>" disabled /></td>
28
     </tr>
28
     </tr>
29
     <tr>
29
     <tr>
30
       <td class="label">Reason (Optional):</td>
30
       <td class="label">Reason (Optional):</td>

+ 2
- 2
sections/delete/take_delete_email.php View File

41
   }
41
   }
42
 
42
 
43
   list($Curr) = $DB->next_record();
43
   list($Curr) = $DB->next_record();
44
-  $Curr = DBCrypt::decrypt($Curr);
44
+  $Curr = Crypto::decrypt($Curr);
45
 
45
 
46
-  if ($Curr == DBCrypt::decrypt($EncEmail)) {
46
+  if ($Curr == Crypto::decrypt($EncEmail)) {
47
     error("You can't delete your current email.");
47
     error("You can't delete your current email.");
48
   }
48
   }
49
 }
49
 }

+ 2
- 2
sections/delete/take_delete_ip.php View File

41
   }
41
   }
42
 
42
 
43
   list($Curr) = $DB->next_record();
43
   list($Curr) = $DB->next_record();
44
-  $Curr = DBCrypt::decrypt($Curr);
44
+  $Curr = Crypto::decrypt($Curr);
45
 
45
 
46
-  if ($Curr == DBCrypt::decrypt($EncIP)) {
46
+  if ($Curr == Crypto::decrypt($EncIP)) {
47
     error("You can't delete your current IP.");
47
     error("You can't delete your current IP.");
48
   }
48
   }
49
 }
49
 }

+ 1
- 1
sections/inbox/conversation.php View File

83
 <?
83
 <?
84
 
84
 
85
 while (list($SentDate, $SenderID, $Body, $MessageID) = $DB->next_record()) {
85
 while (list($SentDate, $SenderID, $Body, $MessageID) = $DB->next_record()) {
86
-  $Body = apcu_exists('DBKEY') ? DBCrypt::decrypt($Body) : '[Encrypted]';
86
+  $Body = apcu_exists('DBKEY') ? Crypto::decrypt($Body) : '[Encrypted]';
87
 ?>
87
 ?>
88
   <div class="box vertical_space">
88
   <div class="box vertical_space">
89
     <div class="head" style="overflow: hidden;">
89
     <div class="head" style="overflow: hidden;">

+ 1
- 1
sections/inbox/get_post.php View File

27
   WHERE m.ID = '$PostID'
27
   WHERE m.ID = '$PostID'
28
     AND u.UserID = ".$LoggedUser['ID']);
28
     AND u.UserID = ".$LoggedUser['ID']);
29
 list($Body) = $DB->next_record(MYSQLI_NUM);
29
 list($Body) = $DB->next_record(MYSQLI_NUM);
30
-$Body = apcu_exists('DBKEY') ? DBCrypt::decrypt($Body) : '[Encrypted]';
30
+$Body = apcu_exists('DBKEY') ? Crypto::decrypt($Body) : '[Encrypted]';
31
 
31
 
32
 // This gets sent to the browser, which echoes it wherever
32
 // This gets sent to the browser, which echoes it wherever
33
 
33
 

+ 8
- 8
sections/login/index.php View File

52
       error('Database not fully decrypted. Please wait for staff to fix this and try again later');
52
       error('Database not fully decrypted. Please wait for staff to fix this and try again later');
53
     }
53
     }
54
 
54
 
55
-    $Email = DBCrypt::decrypt($Email);
55
+    $Email = Crypto::decrypt($Email);
56
 
56
 
57
     if ($UserID && strtotime($Expires) > time()) {
57
     if ($UserID && strtotime($Expires) > time()) {
58
       // If the user has requested a password change, and his key has not expired
58
       // If the user has requested a password change, and his key has not expired
80
             INSERT INTO users_history_passwords
80
             INSERT INTO users_history_passwords
81
               (UserID, ChangerIP, ChangeTime)
81
               (UserID, ChangerIP, ChangeTime)
82
             VALUES
82
             VALUES
83
-              (?, ?, NOW())", $UserID, DBCrypt::encrypt($_SERVER['REMOTE_ADDR']));
83
+              (?, ?, NOW())", $UserID, Crypto::encrypt($_SERVER['REMOTE_ADDR']));
84
           $PassWasReset = true;
84
           $PassWasReset = true;
85
           $LoggedUser['ID'] = $UserID; // Set $LoggedUser['ID'] for logout_all_sessions() to work
85
           $LoggedUser['ID'] = $UserID; // Set $LoggedUser['ID'] for logout_all_sessions() to work
86
           logout_all_sessions();
86
           logout_all_sessions();
127
             Email
127
             Email
128
           FROM users_main");
128
           FROM users_main");
129
         while(list($EncEmail) = $DB->next_record()) {
129
         while(list($EncEmail) = $DB->next_record()) {
130
-          if (strtolower($_REQUEST['email']) == strtolower(DBCrypt::decrypt($EncEmail))) {
130
+          if (strtolower($_REQUEST['email']) == strtolower(Crypto::decrypt($EncEmail))) {
131
             break; // $EncEmail is now the encrypted form of the given email from the database
131
             break; // $EncEmail is now the encrypted form of the given email from the database
132
           }
132
           }
133
         }
133
         }
140
           FROM users_main
140
           FROM users_main
141
           WHERE Email = ?", $EncEmail);
141
           WHERE Email = ?", $EncEmail);
142
         list($UserID, $Username, $Email) = $DB->next_record();
142
         list($UserID, $Username, $Email) = $DB->next_record();
143
-        $Email = DBCrypt::decrypt($Email);
143
+        $Email = Crypto::decrypt($Email);
144
 
144
 
145
         if ($UserID) {
145
         if ($UserID) {
146
           // Email exists in the database
146
           // Email exists in the database
264
                 $IPs = $DB->to_array(false, MYSQLI_NUM);
264
                 $IPs = $DB->to_array(false, MYSQLI_NUM);
265
                 $QueryParts = [];
265
                 $QueryParts = [];
266
                 foreach ($IPs as $i => $IP) {
266
                 foreach ($IPs as $i => $IP) {
267
-                  $IPs[$i] = DBCrypt::decrypt($IP[0]);
267
+                  $IPs[$i] = Crypto::decrypt($IP[0]);
268
                 }
268
                 }
269
                 $IPs = array_unique($IPs);
269
                 $IPs = array_unique($IPs);
270
                 if (count($IPs) > 0) { // Always allow first login
270
                 if (count($IPs) > 0) { // Always allow first login
287
                         FROM users_main
287
                         FROM users_main
288
                         WHERE ID = ?", $UserID);
288
                         WHERE ID = ?", $UserID);
289
                       list($Username, $Email) = $DB->next_record();
289
                       list($Username, $Email) = $DB->next_record();
290
-                      Users::auth_location($UserID, $Username, $CurrentASN, DBCrypt::decrypt($Email));
290
+                      Users::auth_location($UserID, $Username, $CurrentASN, Crypto::decrypt($Email));
291
                       require('newlocation.php');
291
                       require('newlocation.php');
292
                       die();
292
                       die();
293
                     }
293
                     }
356
                   INSERT INTO users_sessions
356
                   INSERT INTO users_sessions
357
                     (UserID, SessionID, KeepLogged, Browser, OperatingSystem, IP, LastUpdate, FullUA)
357
                     (UserID, SessionID, KeepLogged, Browser, OperatingSystem, IP, LastUpdate, FullUA)
358
                   VALUES
358
                   VALUES
359
-                    ('$UserID', '".db_string($SessionID)."', '1', '$Browser', '$OperatingSystem', '".db_string(apcu_exists('DBKEY')?DBCrypt::encrypt($_SERVER['REMOTE_ADDR']):'0.0.0.0')."', NOW(), '".db_string($_SERVER['HTTP_USER_AGENT'])."')");
359
+                    ('$UserID', '".db_string($SessionID)."', '1', '$Browser', '$OperatingSystem', '".db_string(apcu_exists('DBKEY')?Crypto::encrypt($_SERVER['REMOTE_ADDR']):'0.0.0.0')."', NOW(), '".db_string($_SERVER['HTTP_USER_AGENT'])."')");
360
 
360
 
361
                 $Cache->begin_transaction("users_sessions_$UserID");
361
                 $Cache->begin_transaction("users_sessions_$UserID");
362
                 $Cache->insert_front($SessionID, [
362
                 $Cache->insert_front($SessionID, [
363
                   'SessionID' => $SessionID,
363
                   'SessionID' => $SessionID,
364
                   'Browser' => $Browser,
364
                   'Browser' => $Browser,
365
                   'OperatingSystem' => $OperatingSystem,
365
                   'OperatingSystem' => $OperatingSystem,
366
-                  'IP' => (apcu_exists('DBKEY')?DBCrypt::encrypt($_SERVER['REMOTE_ADDR']):'0.0.0.0'),
366
+                  'IP' => (apcu_exists('DBKEY')?Crypto::encrypt($_SERVER['REMOTE_ADDR']):'0.0.0.0'),
367
                   'LastUpdate' => sqltime()
367
                   'LastUpdate' => sqltime()
368
                 ]);
368
                 ]);
369
                 $Cache->commit_transaction(0);
369
                 $Cache->commit_transaction(0);

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

80
           $InviterID = 0;
80
           $InviterID = 0;
81
         } else {
81
         } else {
82
           list($InviterID, $InviteEmail, $InviteReason) = $DB->next_record(MYSQLI_NUM, false);
82
           list($InviterID, $InviteEmail, $InviteReason) = $DB->next_record(MYSQLI_NUM, false);
83
-          $InviteEmail = DBCrypt::decrypt($InviteEmail);
83
+          $InviteEmail = Crypto::decrypt($InviteEmail);
84
         }
84
         }
85
       } else {
85
       } else {
86
         $InviterID = 0;
86
         $InviterID = 0;
114
         INSERT INTO users_main
114
         INSERT INTO users_main
115
           (Username, Email, PassHash, torrent_pass, IP, PermissionID, Enabled, Invites, Uploaded, ipcc)
115
           (Username, Email, PassHash, torrent_pass, IP, PermissionID, Enabled, Invites, Uploaded, ipcc)
116
         VALUES
116
         VALUES
117
-          ('".db_string(trim($_POST['username']))."', '".DBCrypt::encrypt($_POST['email'])."', '".db_string(Users::make_sec_hash($_POST['password']))."', '".db_string($torrent_pass)."', '".DBCrypt::encrypt($_SERVER['REMOTE_ADDR'])."', '$Class', '$Enabled', '".STARTING_INVITES."', '1073741824', '$IPcc')");
117
+          ('".db_string(trim($_POST['username']))."', '".Crypto::encrypt($_POST['email'])."', '".db_string(Users::make_sec_hash($_POST['password']))."', '".db_string($torrent_pass)."', '".Crypto::encrypt($_SERVER['REMOTE_ADDR'])."', '$Class', '$Enabled', '".STARTING_INVITES."', '1073741824', '$IPcc')");
118
 
118
 
119
       $UserID = $DB->inserted_id();
119
       $UserID = $DB->inserted_id();
120
 
120
 
150
         INSERT INTO users_history_ips
150
         INSERT INTO users_history_ips
151
           (UserID, IP, StartTime)
151
           (UserID, IP, StartTime)
152
         VALUES
152
         VALUES
153
-          ('$UserID', '".DBCrypt::encrypt($_SERVER['REMOTE_ADDR'])."', NOW())");
153
+          ('$UserID', '".Crypto::encrypt($_SERVER['REMOTE_ADDR'])."', NOW())");
154
       $DB->query("
154
       $DB->query("
155
         INSERT INTO users_notifications_settings
155
         INSERT INTO users_notifications_settings
156
           (UserID)
156
           (UserID)
162
         INSERT INTO users_history_emails
162
         INSERT INTO users_history_emails
163
           (UserID, Email, Time, IP)
163
           (UserID, Email, Time, IP)
164
         VALUES
164
         VALUES
165
-          ('$UserID', '".DBCrypt::encrypt($_REQUEST['email'])."', NULL, '".DBCrypt::encrypt($_SERVER['REMOTE_ADDR'])."')");
165
+          ('$UserID', '".Crypto::encrypt($_REQUEST['email'])."', NULL, '".Crypto::encrypt($_SERVER['REMOTE_ADDR'])."')");
166
 
166
 
167
       if ($_REQUEST['email'] != $InviteEmail) {
167
       if ($_REQUEST['email'] != $InviteEmail) {
168
         $DB->query("
168
         $DB->query("
169
           INSERT INTO users_history_emails
169
           INSERT INTO users_history_emails
170
             (UserID, Email, Time, IP)
170
             (UserID, Email, Time, IP)
171
           VALUES
171
           VALUES
172
-            ('$UserID', '".DBCrypt::encrypt($InviteEmail)."', NOW(), '".DBCrypt::encrypt($_SERVER['REMOTE_ADDR'])."')");
172
+            ('$UserID', '".Crypto::encrypt($InviteEmail)."', NOW(), '".Crypto::encrypt($_SERVER['REMOTE_ADDR'])."')");
173
       }
173
       }
174
 
174
 
175
 
175
 

+ 1
- 1
sections/schedule/daily/disable_inactive_users.php View File

17
       AND ul.UserID IS NULL
17
       AND ul.UserID IS NULL
18
     GROUP BY um.ID");
18
     GROUP BY um.ID");
19
   while (list($Username, $Email) = $DB->next_record()) {
19
   while (list($Username, $Email) = $DB->next_record()) {
20
-    $Email = DBCrypt::decrypt($Email);
20
+    $Email = Crypto::decrypt($Email);
21
     $Body = "Hi $Username,\n\nIt has been almost 4 months since you used your account at ".site_url().". This is an automated email to inform you that your account will be disabled in 10 days if you do not sign in.";
21
     $Body = "Hi $Username,\n\nIt has been almost 4 months since you used your account at ".site_url().". This is an automated email to inform you that your account will be disabled in 10 days if you do not sign in.";
22
     Misc::send_email($Email, 'Your '.SITE_NAME.' account is about to be disabled', $Body);
22
     Misc::send_email($Email, 'Your '.SITE_NAME.' account is about to be disabled', $Body);
23
   }
23
   }

+ 1
- 1
sections/schedule/manually/update_geodist.php View File

2
 $IPs = [];
2
 $IPs = [];
3
 $DB->query("SELECT IP FROM users_main WHERE Enabled = '1'");
3
 $DB->query("SELECT IP FROM users_main WHERE Enabled = '1'");
4
 while(list($EncIP) = $DB->next_record()) {
4
 while(list($EncIP) = $DB->next_record()) {
5
-  $IPs[] = DBCrypt::decrypt($EncIP);
5
+  $IPs[] = Crypto::decrypt($EncIP);
6
 }
6
 }
7
 $DB->query("CREATE TEMPORARY TABLE users_ips_decrypted (IP VARCHAR(45) NOT NULL)");
7
 $DB->query("CREATE TEMPORARY TABLE users_ips_decrypted (IP VARCHAR(45) NOT NULL)");
8
 $DB->query("INSERT INTO users_ips_decrypted (IP) VALUES('".implode("'),('", $IPs)."')");
8
 $DB->query("INSERT INTO users_ips_decrypted (IP) VALUES('".implode("'),('", $IPs)."')");

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

86
     </tr>
86
     </tr>
87
 <?
87
 <?
88
   while (list($UserID, $IP, $InviteKey, $Expires, $Email) = $DB->next_record()) {
88
   while (list($UserID, $IP, $InviteKey, $Expires, $Email) = $DB->next_record()) {
89
-    $IP = apcu_exists('DBKEY') ? DBCrypt::decrypt($IP) : '[Encrypted]';
90
-    $Email = apcu_exists('DBKEY') ? DBCrypt::decrypt($Email) : '[Encrypted]';
89
+    $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
90
+    $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';
91
 ?>
91
 ?>
92
     <tr class="row">
92
     <tr class="row">
93
       <td><?=Users::format_username($UserID, true, true, true, true)?></td>
93
       <td><?=Users::format_username($UserID, true, true, true, true)?></td>

+ 4
- 4
sections/tools/data/registration_log.php View File

109
 <?
109
 <?
110
   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()) {
110
   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()) {
111
   $RowClass = $IP === $InviterIP ? 'warning' : '';
111
   $RowClass = $IP === $InviterIP ? 'warning' : '';
112
-  $Email = apcu_exists('DBKEY') ? DBCrypt::decrypt($Email) : '[Encrypted]';
113
-  $IP = apcu_exists('DBKEY') ? DBCrypt::decrypt($IP) : '[Encrypted]';
114
-  $InviterEmail = apcu_exists('DBKEY') ? DBCrypt::decrypt($InviterEmail) : '[Encrypted]';
115
-  $InviterIP = apcu_exists('DBKEY') ? DBCrypt::decrypt($InviterIP) : '[Encrypted]';
112
+  $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';
113
+  $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
114
+  $InviterEmail = apcu_exists('DBKEY') ? Crypto::decrypt($InviterEmail) : '[Encrypted]';
115
+  $InviterIP = apcu_exists('DBKEY') ? Crypto::decrypt($InviterIP) : '[Encrypted]';
116
 ?>
116
 ?>
117
     <tr class="<?=$RowClass?>">
117
     <tr class="<?=$RowClass?>">
118
       <td><?=Users::format_username($UserID, true, true, true, true)?><br /><?=Users::format_username($InviterID, true, true, true, true)?></td>
118
       <td><?=Users::format_username($UserID, true, true, true, true)?><br /><?=Users::format_username($InviterID, true, true, true, true)?></td>

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

274
 <?          } ?>
274
 <?          } ?>
275
             </td>
275
             </td>
276
             <td><?=Users::format_username($UserID)?></td>
276
             <td><?=Users::format_username($UserID)?></td>
277
-            <td><?=display_str(DBCrypt::decrypt($Email))?></td>
277
+            <td><?=display_str(Crypto::decrypt($Email))?></td>
278
 
278
 
279
-            <td><?=display_str(DBCrypt::decrypt($IP))?></td>
279
+            <td><?=display_str(Crypto::decrypt($IP))?></td>
280
 
280
 
281
             <td><?=display_str($UserAgent)?></td>
281
             <td><?=display_str($UserAgent)?></td>
282
             <td><?=time_diff($Timestamp)?></td>
282
             <td><?=time_diff($Timestamp)?></td>

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

46
         WHERE UserID = '$UserID'");
46
         WHERE UserID = '$UserID'");
47
       $ToDelete = [];
47
       $ToDelete = [];
48
       while (list($EncValue) = $DB->next_record()) {
48
       while (list($EncValue) = $DB->next_record()) {
49
-        if (DBCrypt::decrypt($Value) == DBCrypt::decrypt($EncValue)) {
49
+        if (Crypto::decrypt($Value) == Crypto::decrypt($EncValue)) {
50
           $ToDelete[] = $EncValue;
50
           $ToDelete[] = $EncValue;
51
         }
51
         }
52
       }
52
       }
95
     <tr>
95
     <tr>
96
       <td><?=Users::format_username($Request['UserID'])?></td>
96
       <td><?=Users::format_username($Request['UserID'])?></td>
97
       <td><?=$Request['Type']?></td>
97
       <td><?=$Request['Type']?></td>
98
-      <td><?=DBCrypt::decrypt($Request['Value'])?></td>
98
+      <td><?=Crypto::decrypt($Request['Value'])?></td>
99
       <td><?=display_str($Request['Reason'])?></td>
99
       <td><?=display_str($Request['Reason'])?></td>
100
       <td><a href="tools.php?action=expunge_requests&auth=<?=$LoggedUser['AuthKey']?>&type=<?=strtolower($Request['Type'])?>&value=<?=urlencode($Request['Value'])?>&userid=<?=$Request['UserID']?>&deny=false" class="brackets">Accept</a></td>
100
       <td><a href="tools.php?action=expunge_requests&auth=<?=$LoggedUser['AuthKey']?>&type=<?=strtolower($Request['Type'])?>&value=<?=urlencode($Request['Value'])?>&userid=<?=$Request['UserID']?>&deny=false" class="brackets">Accept</a></td>
101
       <td><a href="tools.php?action=expunge_requests&auth=<?=$LoggedUser['AuthKey']?>&type=<?=strtolower($Request['Type'])?>&value=<?=urlencode($Request['Value'])?>&userid=<?=$Request['UserID']?>&deny=true" class="brackets">Deny</a></td>
101
       <td><a href="tools.php?action=expunge_requests&auth=<?=$LoggedUser['AuthKey']?>&type=<?=strtolower($Request['Type'])?>&value=<?=urlencode($Request['Value'])?>&userid=<?=$Request['UserID']?>&deny=true" class="brackets">Deny</a></td>

+ 1
- 1
sections/tools/misc/create_user.php View File

28
       INSERT INTO users_main
28
       INSERT INTO users_main
29
         (Username, Email, PassHash, torrent_pass, Enabled, PermissionID)
29
         (Username, Email, PassHash, torrent_pass, Enabled, PermissionID)
30
       VALUES
30
       VALUES
31
-        ('".db_string($Username)."', '".DBCrypt::encrypt($Email)."', '".db_string(Users::make_sec_hash($Password))."', '".db_string($torrent_pass)."', '1', '".USER."')");
31
+        ('".db_string($Username)."', '".Crypto::encrypt($Email)."', '".db_string(Users::make_sec_hash($Password))."', '".db_string($torrent_pass)."', '1', '".USER."')");
32
 
32
 
33
     //Increment site user count
33
     //Increment site user count
34
     $Cache->increment('stats_user_count');
34
     $Cache->increment('stats_user_count');

+ 4
- 4
sections/user/advancedsearch.php View File

804
       $DB->query("SELECT ID, IP FROM users_main");
804
       $DB->query("SELECT ID, IP FROM users_main");
805
     }
805
     }
806
     while(list($ID, $EncIP) = $DB->next_record()) {
806
     while(list($ID, $EncIP) = $DB->next_record()) {
807
-      $IPs[] = $ID.", '".DBCrypt::decrypt($EncIP)."'";
807
+      $IPs[] = $ID.", '".Crypto::decrypt($EncIP)."'";
808
     }
808
     }
809
     $DB->query("CREATE TEMPORARY TABLE users_ips_decrypted (ID INT(10) UNSIGNED NOT NULL, IP VARCHAR(45) NOT NULL, PRIMARY KEY (ID,IP)) ENGINE=MEMORY");
809
     $DB->query("CREATE TEMPORARY TABLE users_ips_decrypted (ID INT(10) UNSIGNED NOT NULL, IP VARCHAR(45) NOT NULL, PRIMARY KEY (ID,IP)) ENGINE=MEMORY");
810
     $DB->query("INSERT IGNORE INTO users_ips_decrypted (ID, IP) VALUES(".implode("),(", $IPs).")");
810
     $DB->query("INSERT IGNORE INTO users_ips_decrypted (ID, IP) VALUES(".implode("),(", $IPs).")");
819
       $DB->query("SELECT ID, Email FROM users_main");
819
       $DB->query("SELECT ID, Email FROM users_main");
820
     }
820
     }
821
     while(list($ID, $EncEmail) = $DB->next_record()) {
821
     while(list($ID, $EncEmail) = $DB->next_record()) {
822
-      $Emails[] = $ID.", '".DBCrypt::decrypt($EncEmail)."'";
822
+      $Emails[] = $ID.", '".Crypto::decrypt($EncEmail)."'";
823
     }
823
     }
824
     $DB->query("CREATE TEMPORARY TABLE users_emails_decrypted (ID INT(10) UNSIGNED NOT NULL, Email VARCHAR(255) NOT NULL, PRIMARY KEY (ID,Email)) ENGINE=MEMORY");
824
     $DB->query("CREATE TEMPORARY TABLE users_emails_decrypted (ID INT(10) UNSIGNED NOT NULL, Email VARCHAR(255) NOT NULL, PRIMARY KEY (ID,Email)) ENGINE=MEMORY");
825
     $DB->query("INSERT IGNORE INTO users_emails_decrypted (ID, Email) VALUES(".implode("),(", $Emails).")");
825
     $DB->query("INSERT IGNORE INTO users_emails_decrypted (ID, Email) VALUES(".implode("),(", $Emails).")");
866
     </tr>
866
     </tr>
867
 <?
867
 <?
868
 while (list($UserID, $Username, $Uploaded, $Downloaded, $Snatched, $Invitees, $Class, $Email, $Enabled, $IP, $Invites, $DisableInvites, $Warned, $Donor, $JoinDate, $LastAccess) = $DB->next_record()) {
868
 while (list($UserID, $Username, $Uploaded, $Downloaded, $Snatched, $Invitees, $Class, $Email, $Enabled, $IP, $Invites, $DisableInvites, $Warned, $Donor, $JoinDate, $LastAccess) = $DB->next_record()) {
869
-  $IP = apcu_exists('DBKEY') ? DBCrypt::decrypt($IP) : '[Encrypted]';
870
-  $Email = apcu_exists('DBKEY') ? DBCrypt::decrypt($Email) : '[Encrypted]';
869
+  $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
870
+  $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';
871
 ?>
871
 ?>
872
     <tr>
872
     <tr>
873
       <td><?=Users::format_username($UserID, true, true, true, true)?></td>
873
       <td><?=Users::format_username($UserID, true, true, true, true)?></td>

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

29
 
29
 
30
 $TwoFA = new TwoFactorAuth();
30
 $TwoFA = new TwoFactorAuth();
31
 
31
 
32
-$Email = apcu_exists('DBKEY') ? DBCrypt::decrypt($Email) : '[Encrypted]';
32
+$Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';
33
 
33
 
34
 if ($UserID != $LoggedUser['ID'] && !check_perms('users_edit_profiles', $Class)) {
34
 if ($UserID != $LoggedUser['ID'] && !check_perms('users_edit_profiles', $Class)) {
35
   error(403);
35
   error(403);

+ 2
- 2
sections/user/invite.php View File

190
 <?
190
 <?
191
   foreach ($Pending as $Invite) {
191
   foreach ($Pending as $Invite) {
192
     list($InviteKey, $Email, $Expires) = $Invite;
192
     list($InviteKey, $Email, $Expires) = $Invite;
193
-    $Email = apcu_exists('DBKEY') ? DBCrypt::decrypt($Email) : '[Encrypted]';
193
+    $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';
194
 ?>
194
 ?>
195
       <tr class="row">
195
       <tr class="row">
196
         <td><?=display_str($Email)?></td>
196
         <td><?=display_str($Email)?></td>
219
 <?
219
 <?
220
   foreach ($Invited as $User) {
220
   foreach ($Invited as $User) {
221
     list($ID, $Email, $Uploaded, $Downloaded, $JoinDate, $LastAccess) = $User;
221
     list($ID, $Email, $Uploaded, $Downloaded, $JoinDate, $LastAccess) = $User;
222
-    $Email = apcu_exists('DBKEY') ? DBCrypt::decrypt($Email) : '[Encrypted]'
222
+    $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]'
223
 ?>
223
 ?>
224
       <tr class="row">
224
       <tr class="row">
225
         <td><?=Users::format_username($ID, true, true, true, true)?></td>
225
         <td><?=Users::format_username($ID, true, true, true, true)?></td>

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

73
 <?
73
 <?
74
   foreach ($UserSessions as $Session) {
74
   foreach ($UserSessions as $Session) {
75
     list($ThisSessionID, $Browser, $OperatingSystem, $IP, $LastUpdate) = array_values($Session);
75
     list($ThisSessionID, $Browser, $OperatingSystem, $IP, $LastUpdate) = array_values($Session);
76
-    $IP = apcu_exists('DBKEY') ? DBCrypt::decrypt($IP) : '[Encrypted]';
76
+    $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
77
 ?>
77
 ?>
78
       <tr class="row">
78
       <tr class="row">
79
         <td class="nobr"><?=$IP?></td>
79
         <td class="nobr"><?=$IP?></td>

+ 5
- 5
sections/user/take_edit.php View File

149
 }
149
 }
150
 
150
 
151
 // Email change
151
 // Email change
152
-$CurEmail = DBCrypt::decrypt($CurEmail);
152
+$CurEmail = Crypto::decrypt($CurEmail);
153
 if ($CurEmail != $_POST['email']) {
153
 if ($CurEmail != $_POST['email']) {
154
 
154
 
155
   // Non-admins have to authenticate to change email
155
   // Non-admins have to authenticate to change email
167
     INSERT INTO users_history_emails
167
     INSERT INTO users_history_emails
168
       (UserID, Email, Time, IP)
168
       (UserID, Email, Time, IP)
169
     VALUES
169
     VALUES
170
-      (?, ?, NULL, ?)", $UserID, DBCrypt::encrypt($_POST['email']), DBCrypt::encrypt($_SERVER['REMOTE_ADDR']));
170
+      (?, ?, NULL, ?)", $UserID, Crypto::encrypt($_POST['email']), Crypto::encrypt($_SERVER['REMOTE_ADDR']));
171
 
171
 
172
 }
172
 }
173
 
173
 
300
     i.Info = '".db_string($_POST['info'])."',
300
     i.Info = '".db_string($_POST['info'])."',
301
     i.InfoTitle = '".db_string($_POST['profile_title'])."',
301
     i.InfoTitle = '".db_string($_POST['profile_title'])."',
302
     i.UnseededAlerts = '$UnseededAlerts',
302
     i.UnseededAlerts = '$UnseededAlerts',
303
-    m.Email = '".DBCrypt::encrypt($_POST['email'])."',
303
+    m.Email = '".Crypto::encrypt($_POST['email'])."',
304
     m.IRCKey = '".db_string($_POST['irckey'])."',
304
     m.IRCKey = '".db_string($_POST['irckey'])."',
305
     m.Paranoia = '".db_string(json_encode($Paranoia))."'";
305
     m.Paranoia = '".db_string(json_encode($Paranoia))."'";
306
 
306
 
307
 if ($ResetPassword) {
307
 if ($ResetPassword) {
308
-  $ChangerIP = DBCrypt::encrypt($LoggedUser['IP']);
308
+  $ChangerIP = Crypto::encrypt($LoggedUser['IP']);
309
   $PassHash = Users::make_sec_hash($_POST['new_pass_1']);
309
   $PassHash = Users::make_sec_hash($_POST['new_pass_1']);
310
   $SQL.= ",m.PassHash = '".db_string($PassHash)."'";
310
   $SQL.= ",m.PassHash = '".db_string($PassHash)."'";
311
   $DB->query("
311
   $DB->query("
320
   $UserInfo = Users::user_heavy_info($UserID);
320
   $UserInfo = Users::user_heavy_info($UserID);
321
   $OldPassKey = $UserInfo['torrent_pass'];
321
   $OldPassKey = $UserInfo['torrent_pass'];
322
   $NewPassKey = Users::make_secret();
322
   $NewPassKey = Users::make_secret();
323
-  $ChangerIP = DBCrypt::encrypt($LoggedUser['IP']);
323
+  $ChangerIP = Crypto::encrypt($LoggedUser['IP']);
324
   $SQL .= ",m.torrent_pass = '$NewPassKey'";
324
   $SQL .= ",m.torrent_pass = '$NewPassKey'";
325
   $DB->query("
325
   $DB->query("
326
     INSERT INTO users_history_passkeys
326
     INSERT INTO users_history_passkeys

+ 2
- 2
sections/user/take_invite.php View File

70
     WHERE InviterID = ".$LoggedUser['ID']);
70
     WHERE InviterID = ".$LoggedUser['ID']);
71
   if ($DB->has_results()) {
71
   if ($DB->has_results()) {
72
     while (list($MaybeEmail) = $DB->next_record()) {
72
     while (list($MaybeEmail) = $DB->next_record()) {
73
-      if (DBCrypt::decrypt($MaybeEmail) == $CurEmail) {
73
+      if (Crypto::decrypt($MaybeEmail) == $CurEmail) {
74
         error('You already have a pending invite to that address!');
74
         error('You already have a pending invite to that address!');
75
         header('Location: user.php?action=invite');
75
         header('Location: user.php?action=invite');
76
         die();
76
         die();
103
     INSERT INTO invites
103
     INSERT INTO invites
104
       (InviterID, InviteKey, Email, Expires, Reason)
104
       (InviterID, InviteKey, Email, Expires, Reason)
105
     VALUES
105
     VALUES
106
-      ('$LoggedUser[ID]', '$InviteKey', '".DBCrypt::encrypt($CurEmail)."', '$InviteExpires', '$InviteReason')");
106
+      ('$LoggedUser[ID]', '$InviteKey', '".Crypto::encrypt($CurEmail)."', '$InviteExpires', '$InviteReason')");
107
 
107
 
108
   if (!check_perms('site_send_unlimited_invites')) {
108
   if (!check_perms('site_send_unlimited_invites')) {
109
     $DB->query("
109
     $DB->query("

+ 6
- 6
sections/user/takemoderate.php View File

233
 
233
 
234
 if ($_POST['ResetIPHistory'] && check_perms('users_edit_reset_keys')) {
234
 if ($_POST['ResetIPHistory'] && check_perms('users_edit_reset_keys')) {
235
 
235
 
236
-  $GenericIP = DBCrypt::encrypt('127.0.0.1');
236
+  $GenericIP = Crypto::encrypt('127.0.0.1');
237
   $DB->query("
237
   $DB->query("
238
     DELETE FROM users_history_ips
238
     DELETE FROM users_history_ips
239
     WHERE UserID = '$UserID'");
239
     WHERE UserID = '$UserID'");
268
       INSERT INTO users_history_emails
268
       INSERT INTO users_history_emails
269
         (UserID, Email, Time, IP)
269
         (UserID, Email, Time, IP)
270
       VALUES
270
       VALUES
271
-        ('$UserID', '".DBCrypt::encrypt($Username.'@'.SITE_DOMAIN)."', NULL, '".DBCrypt::encrypt('127.0.0.1')."')");
271
+        ('$UserID', '".Crypto::encrypt($Username.'@'.SITE_DOMAIN)."', NULL, '".Crypto::encrypt('127.0.0.1')."')");
272
   } else {
272
   } else {
273
     $DB->query("
273
     $DB->query("
274
       INSERT INTO users_history_emails
274
       INSERT INTO users_history_emails
275
         (UserID, Email, Time, IP)
275
         (UserID, Email, Time, IP)
276
       VALUES
276
       VALUES
277
-        ('$UserID', '".DBCrypt::encrypt($Username.'@'.SITE_DOMAIN)."', NULL, '".$Cur['IP']."')");
277
+        ('$UserID', '".Crypto::encrypt($Username.'@'.SITE_DOMAIN)."', NULL, '".$Cur['IP']."')");
278
   }
278
   }
279
   $DB->query("
279
   $DB->query("
280
     UPDATE users_main
280
     UPDATE users_main
281
-    SET Email = '".DBCrypt::encrypt($Username.'@'.SITE_DOMAIN)."'
281
+    SET Email = '".Crypto::encrypt($Username.'@'.SITE_DOMAIN)."'
282
     WHERE ID = '$UserID'");
282
     WHERE ID = '$UserID'");
283
   $EditSummary[] = 'Email history cleared';
283
   $EditSummary[] = 'Email history cleared';
284
 }
284
 }
696
     $TrackerUserUpdates = [];
696
     $TrackerUserUpdates = [];
697
   } elseif ($EnableUser == '1') {
697
   } elseif ($EnableUser == '1') {
698
     $Cache->increment('stats_user_count');
698
     $Cache->increment('stats_user_count');
699
-    $VisibleTrIP = ($Visible && DBCrypt::decrypt($Cur['IP']) != '127.0.0.1') ? '1' : '0';
699
+    $VisibleTrIP = ($Visible && Crypto::decrypt($Cur['IP']) != '127.0.0.1') ? '1' : '0';
700
     Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $Cur['torrent_pass'], 'visible' => $VisibleTrIP));
700
     Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $Cur['torrent_pass'], 'visible' => $VisibleTrIP));
701
 
701
 
702
     if (($Cur['Downloaded'] == 0) || ($Cur['Uploaded'] / $Cur['Downloaded'] >= $Cur['RequiredRatio'])) {
702
     if (($Cur['Downloaded'] == 0) || ($Cur['Uploaded'] / $Cur['Downloaded'] >= $Cur['RequiredRatio'])) {
734
     INSERT INTO users_history_passkeys
734
     INSERT INTO users_history_passkeys
735
       (UserID, OldPassKey, NewPassKey, ChangerIP, ChangeTime)
735
       (UserID, OldPassKey, NewPassKey, ChangerIP, ChangeTime)
736
     VALUES
736
     VALUES
737
-      ('$UserID', '".$Cur['torrent_pass']."', '$Passkey', '".DBCrypt::encrypt('0.0.0.0')."', NOW())");
737
+      ('$UserID', '".$Cur['torrent_pass']."', '$Passkey', '".Crypto::encrypt('0.0.0.0')."', NOW())");
738
   Tracker::update_tracker('change_passkey', array('oldpasskey' => $Cur['torrent_pass'], 'newpasskey' => $Passkey));
738
   Tracker::update_tracker('change_passkey', array('oldpasskey' => $Cur['torrent_pass'], 'newpasskey' => $Passkey));
739
 }
739
 }
740
 
740
 

+ 4
- 4
sections/user/user.php View File

133
 $DisableLeech, $JoinDate, $Info, $Avatar, $FLTokens, $BonusPoints, $IRCLines, $Donor, $Warned,
133
 $DisableLeech, $JoinDate, $Info, $Avatar, $FLTokens, $BonusPoints, $IRCLines, $Donor, $Warned,
134
 $ForumPosts, $InviterID, $DisableInvites, $InviterName, $InfoTitle) = $DB->next_record(MYSQLI_NUM, array(9, 11));
134
 $ForumPosts, $InviterID, $DisableInvites, $InviterName, $InfoTitle) = $DB->next_record(MYSQLI_NUM, array(9, 11));
135
 }
135
 }
136
-$Email = apcu_exists('DBKEY') ? DBCrypt::decrypt($Email) : '[Encrypted]';
136
+$Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';
137
 
137
 
138
 $DB->query("
138
 $DB->query("
139
   SELECT SUM(t.Size)
139
   SELECT SUM(t.Size)
589
 <?  }
589
 <?  }
590
 
590
 
591
 if (check_perms('users_view_ips', $Class)) {
591
 if (check_perms('users_view_ips', $Class)) {
592
-  $IP = apcu_exists('DBKEY') ? DBCrypt::decrypt($IP) : '[Encrypted]';
592
+  $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
593
 ?>
593
 ?>
594
         <li>IP: <?=Tools::display_ip($IP)?></li>
594
         <li>IP: <?=Tools::display_ip($IP)?></li>
595
         <li>Host: <?=Tools::get_host_by_ajax($IP)?></li>
595
         <li>Host: <?=Tools::get_host_by_ajax($IP)?></li>
1426
 <?
1426
 <?
1427
       foreach ($Emails as $Email) {
1427
       foreach ($Emails as $Email) {
1428
         list($Address, $IP) = $Email;
1428
         list($Address, $IP) = $Email;
1429
-        $IP = apcu_exists('DBKEY') ? DBCrypt::decrypt($IP) : '[Encrypted]';
1430
-        $Address = apcu_exists('DBKEY') ? DBCrypt::decrypt($Address) : '[Encrypted]';
1429
+        $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
1430
+        $Address = apcu_exists('DBKEY') ? Crypto::decrypt($Address) : '[Encrypted]';
1431
 ?>
1431
 ?>
1432
             <option value="<?=display_str($Address)?>"><?=display_str($Address)?> - <?=display_str($IP)?></option>
1432
             <option value="<?=display_str($Address)?>"><?=display_str($Address)?> - <?=display_str($IP)?></option>
1433
 <?    } ?>
1433
 <?    } ?>

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

109
     $Values['Time'] = $Joined;
109
     $Values['Time'] = $Joined;
110
   }
110
   }
111
 
111
 
112
-  $ValuesIP = apcu_exists('DBKEY') ? DBCrypt::decrypt($Values['IP']) : '[Encrypted]';
112
+  $ValuesIP = apcu_exists('DBKEY') ? Crypto::decrypt($Values['IP']) : '[Encrypted]';
113
 ?>
113
 ?>
114
   <tr class="row">
114
   <tr class="row">
115
     <td><?=display_str($Values['Email'])?></td>
115
     <td><?=display_str($Values['Email'])?></td>
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()) {
130
     while (list($UserID2, $Time, $IP) = $DB->next_record()) {
131
-      $IP = apcu_exists('DBKEY') ? DBCrypt::decrypt($IP) : '[Encrypted]';
131
+      $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
132
 ?>
132
 ?>
133
   </tr>
133
   </tr>
134
   <tr>
134
   <tr>

+ 9
- 9
sections/userhistory/email_history2.php View File

182
       <td>Set from IP</td>
182
       <td>Set from IP</td>
183
     </tr>
183
     </tr>
184
 <?
184
 <?
185
-$Current['Email'] = apcu_exists('DBKEY') ? DBCrypt::decrypt($Current['Email']) : '[Encrypted]';
186
-$Current['CurrentIP'] = apcu_exists('DBKEY') ? DBCrypt::decrypt($Current['CurrentIP']) : '[Encrypted]';
187
-$Current['IP'] = apcu_exists('DBKEY') ? DBCrypt::decrypt($Current['IP']) : '[Encrypted]';
185
+$Current['Email'] = apcu_exists('DBKEY') ? Crypto::decrypt($Current['Email']) : '[Encrypted]';
186
+$Current['CurrentIP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Current['CurrentIP']) : '[Encrypted]';
187
+$Current['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Current['IP']) : '[Encrypted]';
188
 ?>
188
 ?>
189
     <tr class="row">
189
     <tr class="row">
190
       <td><?=display_str($Current['Email'])?></td>
190
       <td><?=display_str($Current['Email'])?></td>
211
 if ($CurrentMatches ?? false) {
211
 if ($CurrentMatches ?? false) {
212
   // Match on the current email
212
   // Match on the current email
213
   foreach ($CurrentMatches as $Match) {
213
   foreach ($CurrentMatches as $Match) {
214
-    $Match['IP'] = apcu_exists('DBKEY') ? DBCrypt::decrypt($Match['IP']) : '[Encrypted]';
214
+    $Match['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Match['IP']) : '[Encrypted]';
215
 ?>
215
 ?>
216
     <tr class="row">
216
     <tr class="row">
217
       <td><?=$Match['Username']?></td>
217
       <td><?=$Match['Username']?></td>
279
     $Matches = ob_get_contents();
279
     $Matches = ob_get_contents();
280
     ob_end_clean();
280
     ob_end_clean();
281
 
281
 
282
-    $Record['Email'] = apcu_exists('DBKEY') ? DBCrypt::decrypt($Record['Email']) : '[Encrypted]';
283
-    $Record['IP'] = apcu_exists('DBKEY') ? DBCrypt::decrypt($Record['IP']) : '[Encrypted]';
282
+    $Record['Email'] = apcu_exists('DBKEY') ? Crypto::decrypt($Record['Email']) : '[Encrypted]';
283
+    $Record['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Record['IP']) : '[Encrypted]';
284
 ?>
284
 ?>
285
     <tr class="row">
285
     <tr class="row">
286
       <td><?=display_str($Record['Email'])?><?=(($MatchCount > 0) ? ' <a data-toggle-target="#matches_'.$j.'">('.$MatchCount.')</a>' : '')?></td>
286
       <td><?=display_str($Record['Email'])?><?=(($MatchCount > 0) ? ' <a data-toggle-target="#matches_'.$j.'">('.$MatchCount.')</a>' : '')?></td>
325
       ++$i;
325
       ++$i;
326
       // Match email is the same as the invite email
326
       // Match email is the same as the invite email
327
 
327
 
328
-      $Match['IP'] = apcu_exists('DBKEY') ? DBCrypt::decrypt($Match['IP']) : '[Encrypted]';
328
+      $Match['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Match['IP']) : '[Encrypted]';
329
 ?>
329
 ?>
330
     <tr class="row hidden" id="matches_invite">
330
     <tr class="row hidden" id="matches_invite">
331
       <td><?=$Match['Username']?></td>
331
       <td><?=$Match['Username']?></td>
349
 $Matches = ob_get_contents();
349
 $Matches = ob_get_contents();
350
 ob_end_clean();
350
 ob_end_clean();
351
 
351
 
352
-$Invite['Email'] = apcu_exists('DBKEY') ? DBCrypt::decrypt($Invite['Email']) : '[Encrypted]';
353
-$Invite['IP'] = apcu_exists('DBKEY') ? DBCrypt::decrypt($Invite['IP']) : '[Encrypted]';
352
+$Invite['Email'] = apcu_exists('DBKEY') ? Crypto::decrypt($Invite['Email']) : '[Encrypted]';
353
+$Invite['IP'] = apcu_exists('DBKEY') ? Crypto::decrypt($Invite['IP']) : '[Encrypted]';
354
 ?>
354
 ?>
355
     <tr class="row">
355
     <tr class="row">
356
       <td><?=display_str($Invite['Email'])?><?=(($MatchCount > 0) ? ' <a data-toggle-target="#matches_invite">('.$MatchCount.')</a>' : '')?></td>
356
       <td><?=display_str($Invite['Email'])?><?=(($MatchCount > 0) ? ' <a data-toggle-target="#matches_invite">('.$MatchCount.')</a>' : '')?></td>

+ 4
- 4
sections/userhistory/email_history_userview.php View File

23
 $Emails = [];
23
 $Emails = [];
24
 
24
 
25
 foreach ($EncEmails as $Enc) {
25
 foreach ($EncEmails as $Enc) {
26
-  if (!isset($Emails[DBCrypt::decrypt($Enc)])) {
27
-    $Emails[DBCrypt::decrypt($Enc)] = [];
26
+  if (!isset($Emails[Crypto::decrypt($Enc)])) {
27
+    $Emails[Crypto::decrypt($Enc)] = [];
28
   }
28
   }
29
-  $Emails[DBCrypt::decrypt($Enc)][] = $Enc;
29
+  $Emails[Crypto::decrypt($Enc)][] = $Enc;
30
 }
30
 }
31
 
31
 
32
 $DB->query("
32
 $DB->query("
35
   WHERE ID = '$UserID'");
35
   WHERE ID = '$UserID'");
36
 
36
 
37
 list($Curr) = $DB->next_record();
37
 list($Curr) = $DB->next_record();
38
-$Curr = DBCrypt::decrypt($Curr);
38
+$Curr = Crypto::decrypt($Curr);
39
 
39
 
40
 if (!$Self) {
40
 if (!$Self) {
41
   $DB->query("SELECT Username FROM users_main WHERE ID = '$UserID'");
41
   $DB->query("SELECT Username FROM users_main WHERE ID = '$UserID'");

+ 1
- 1
sections/userhistory/ip_history.php View File

187
 foreach ($Results as $Index => $Result) {
187
 foreach ($Results as $Index => $Result) {
188
   list($IP, $StartTime, $EndTime, $UserIDs, $UserStartTimes, $UserEndTimes, $Usernames, $UsersEnabled, $UsersDonor, $UsersWarned) = $Result;
188
   list($IP, $StartTime, $EndTime, $UserIDs, $UserStartTimes, $UserEndTimes, $Usernames, $UsersEnabled, $UsersDonor, $UsersWarned) = $Result;
189
 
189
 
190
-  $IP = apcu_exists('DBKEY') ? DBCrypt::decrypt($IP) : '[Encrypted]';
190
+  $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
191
 
191
 
192
   $HasDupe = false;
192
   $HasDupe = false;
193
   $UserIDs = explode('|', $UserIDs);
193
   $UserIDs = explode('|', $UserIDs);

+ 4
- 4
sections/userhistory/ip_history_userview.php View File

23
 $IPs = [];
23
 $IPs = [];
24
 
24
 
25
 foreach ($EncIPs as $Enc) {
25
 foreach ($EncIPs as $Enc) {
26
-  if (!isset($IPs[DBCrypt::decrypt($Enc)])) {
27
-    $IPs[DBCrypt::decrypt($Enc)] = [];
26
+  if (!isset($IPs[Crypto::decrypt($Enc)])) {
27
+    $IPs[Crypto::decrypt($Enc)] = [];
28
   }
28
   }
29
-  $IPs[DBCrypt::decrypt($Enc)][] = $Enc;
29
+  $IPs[Crypto::decrypt($Enc)][] = $Enc;
30
 }
30
 }
31
 
31
 
32
 $DB->query("
32
 $DB->query("
35
   WHERE ID = '$UserID'");
35
   WHERE ID = '$UserID'");
36
 
36
 
37
 list($Curr) = $DB->next_record();
37
 list($Curr) = $DB->next_record();
38
-$Curr = DBCrypt::decrypt($Curr);
38
+$Curr = Crypto::decrypt($Curr);
39
 
39
 
40
 if (!$Self) {
40
 if (!$Self) {
41
   $DB->query("SELECT Username FROM users_main WHERE ID = '$UserID'");
41
   $DB->query("SELECT Username FROM users_main WHERE ID = '$UserID'");

+ 1
- 1
sections/userhistory/password_history.php View File

49
   </tr>
49
   </tr>
50
 <?
50
 <?
51
 while (list($ChangeTime, $ChangerIP) = $DB->next_record()) {
51
 while (list($ChangeTime, $ChangerIP) = $DB->next_record()) {
52
-  $ChangerIP = (apcu_exists('DBKEY')) ? DBCrypt::decrypt($ChangerIP) : '[Encrypted]';
52
+  $ChangerIP = (apcu_exists('DBKEY')) ? Crypto::decrypt($ChangerIP) : '[Encrypted]';
53
 ?>
53
 ?>
54
   <tr class="row">
54
   <tr class="row">
55
     <td><?=time_diff($ChangeTime)?></td>
55
     <td><?=time_diff($ChangeTime)?></td>

Loading…
Cancel
Save