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,54 @@
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 SIP password for the current user from the 'app_users' table
23
+    $enabled = 1;
24
+    $querysel = $mysqli->prepare("SELECT username, sip_password, enabled FROM app_users WHERE BINARY username = ? AND enabled = ?");
25
+    $querysel->bind_param("si", $username, $enabled);
26
+    $querysel->execute();
27
+    $confdatafromdbinit = $querysel->get_result();
28
+    $confdatafromdb = $confdatafromdbinit->fetch_assoc();
29
+
30
+
31
+    // Decrypt the SIP password fetched from the database
32
+//    if ($confdatafromdb['sip_password'] != '' && $confdatafromdb['sip_password'] != null && $confdatafromdb['sip_password'] != 'undefined') {
33
+    if ($confdatafromdb['sip_password']) {
34
+
35
+        $psswdaddedkey = file_get_contents('../restr/'.$username.'/pwdkey');
36
+
37
+        $componentsippsswd = explode(':', $confdatafromdb['sip_password']);
38
+
39
+	$encpwdin = $componentsippsswd[0];
40
+	$ivkey = $componentsippsswd[1];
41
+
42
+	$sippassworddec = openssl_decrypt($encpwdin, 'AES-256-CBC', $psswdaddedkey, false, $ivkey);
43
+
44
+        $sipdatafromdb = $sippassworddec;
45
+
46
+    } else { $sipdatafromdb = ''; }
47
+
48
+    echo json_encode($sipdatafromdb);
49
+
50
+} else {
51
+    header("Location: ../login.php");
52
+}
53
+
54
+?>