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,75 @@
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
+ // header('Set-Cookie: PHPSESSID= ' . session_id() . '; SameSite=strict; Secure=true; HttpOnly=true;');
12
+
13
+if (isset($_POST['vconfextension']) && $_POST['vconfextension'] != '' && isset($_POST['encextenpass']) && $_POST['encextenpass'] != '' && isset($_POST['currentvconfext']) && 
14
+    $_POST['currentvconfext'] != '' && isset($_POST['currentvconfpubkey']) && $_POST['currentvconfpubkey'] != '' && isset($_POST['currentvconfprivkey']) && 
15
+    $_POST['currentvconfprivkey'] != '') {
16
+
17
+       define('ACCESSCONST', TRUE);
18
+
19
+       require('db-connect.php');
20
+
21
+       $extForExternal = $_POST['vconfextension'];
22
+       $extenPassEnc = $_POST['encextenpass'];
23
+
24
+       $vconfExtension = $_POST['currentvconfext'];
25
+       $chatPubKey = $_POST['currentvconfpubkey'];
26
+       $chatPrivKey = $_POST['currentvconfprivkey'];
27
+
28
+       // Check if the received external user extension, the corresponding encrypted password and the extension of the conference, match the data in the 'external_users' table
29
+       $query = $mysqli->prepare("SELECT id, exten_for_external, exten_for_ext_pass, conf_extension FROM external_users WHERE exten_for_external = ? AND exten_for_ext_pass = ? AND conf_extension = ?");
30
+       $query->bind_param("sss", $extForExternal, $extenPassEnc, $vconfExtension);
31
+       $query->execute();
32
+       $extqueryres = $query->get_result()->fetch_array();
33
+
34
+       if (!$extqueryres) {
35
+
36
+           http_response_code(400);
37
+           exit();
38
+
39
+       } else {
40
+
41
+	       // Create the necessary directory if it doesn't exist
42
+	       if (!is_dir('../textchat/' . $vconfExtension)) {
43
+		    mkdir('../textchat/' . $vconfExtension, 0700);
44
+	       }
45
+
46
+	       // Save the RSA keys
47
+	       if ($vconfExtension != '') {
48
+
49
+		   if (!file_exists('../textchat/' . $vconfExtension . '/rsa_1024_pub.pem') || !file_exists('../textchat/' . $vconfExtension . '/rsa_1024_priv.pem')) {
50
+
51
+			$savePubKey = file_put_contents('../textchat/' . $vconfExtension . '/rsa_1024_pub.pem', $chatPubKey);
52
+			chmod('../textchat/' . $vconfExtension . '/rsa_1024_pub.pem', 0600);
53
+
54
+			$savePrivKey = file_put_contents('../textchat/' . $vconfExtension . '/rsa_1024_priv.pem', $chatPrivKey);
55
+			chmod('../textchat/' . $vconfExtension . '/rsa_1024_priv.pem', 0400);
56
+
57
+			$messageres = 'success';
58
+
59
+		   } else { $messageres = 'success'; }
60
+
61
+	       } else { 
62
+		     $messageres = 'failure';
63
+	       }
64
+
65
+       }
66
+
67
+       $generateresp = ['messageres' => $messageres];
68
+
69
+       echo json_encode($generateresp);
70
+
71
+} else {
72
+    header("Location: ../login.php");
73
+}
74
+
75
+?>