Browse code

Changed majority of files.

DoubleBastionAdmin authored on 30/11/2024 06:56:40
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,76 @@
1
+<?php
2
+/**
3
+ *  Copyright (C) 2021  Double Bastion LLC
4
+ *
5
+ *  This file is part of Roundpin, which is licensed under the
6
+ *  GNU Affero General Public License Version 3.0. The license terms
7
+ *  are detailed in the "LICENSE.txt" file located in the root directory.
8
+ */
9
+
10
+session_start();
11
+
12
+ // header('Set-Cookie: PHPSESSID= ' . session_id() . '; SameSite=strict; Secure=true; HttpOnly=true;');
13
+
14
+if (isset($_POST['s_ajax_call']) && ($_POST['s_ajax_call'] == $_SESSION['validate_s_access'])) {
15
+
16
+    define('ACCESSCONST', TRUE);
17
+
18
+    require('db-connect.php');
19
+
20
+    $username = $_POST['username'];
21
+
22
+    // Get the id of the current user from the 'app_users' table
23
+    $queryselid = $mysqli->prepare("SELECT id, username FROM app_users WHERE BINARY username = ?");
24
+    $queryselid->bind_param("s", $username);
25
+    $queryselid->execute(); 
26
+    $queryselid = $queryselid->get_result()->fetch_assoc();
27
+    $userid = $queryselid['id'];
28
+
29
+    // Get the Roundcube password and Roundcube basic auth password for the current user from the 'email_conf' table
30
+    $querysel = $mysqli->prepare("SELECT userid, rcdomain, rcuser, rcpassword, rcbasicauthuser, rcbasicauthpass FROM email_conf WHERE userid = ?");
31
+    $querysel->bind_param("i", $userid);
32
+    $querysel->execute();
33
+    $confdatafromdb = $querysel->get_result()->fetch_assoc();
34
+
35
+
36
+    // Decrypt the Roundcube password (if any) and Roundcube basic auth password (if any), fetched from the database
37
+
38
+    if ($confdatafromdb['rcpassword'] != '' && $confdatafromdb['rcpassword'] != null && $confdatafromdb['rcpassword'] != 'undefined') {
39
+
40
+        $psswdaddedkeyrc = file_get_contents('../restr/'.$username.'/pwdkeyrc');
41
+        $rcpasswdinit = $confdatafromdb['rcpassword'];
42
+        $componentrcpass = explode(':', $rcpasswdinit);
43
+
44
+        $encpwdin = $componentrcpass[0];
45
+        $ivkey = $componentrcpass[1];
46
+
47
+        $rcpassworddec = openssl_decrypt($encpwdin, 'AES-256-CBC', $psswdaddedkeyrc, false, $ivkey);
48
+
49
+        $confdatafromdb['rcpassword'] = $rcpassworddec;
50
+
51
+    } else { $confdatafromdb['rcpassword'] = ''; }
52
+
53
+    if ($confdatafromdb['rcbasicauthpass'] != '' && $confdatafromdb['rcbasicauthpass'] != null && $confdatafromdb['rcbasicauthpass'] != 'undefined') {
54
+
55
+        $psswdaddedkeyrcba = file_get_contents('../restr/'.$username.'/pwdkeyrcba');
56
+        $rcbapasswdinit = $confdatafromdb['rcbasicauthpass'];
57
+        $componentrcbapass = explode(':', $rcbapasswdinit);
58
+
59
+        $baencpwdin = $componentrcbapass[0];
60
+        $baivkey = $componentrcbapass[1];
61
+
62
+        $rcbapassworddec = openssl_decrypt($baencpwdin, 'AES-256-CBC', $psswdaddedkeyrcba, false, $baivkey);
63
+
64
+        $confdatafromdb['rcbasicauthpass'] = $rcbapassworddec;
65
+
66
+    } else { $confdatafromdb['rcbasicauthpass'] = ''; }
67
+
68
+    $datafromdb = $confdatafromdb;
69
+
70
+    echo json_encode($datafromdb);
71
+
72
+} else {
73
+     header("Location: ../login.php");
74
+}
75
+
76
+?>