1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,46 @@ |
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 |
+if (isset($_POST['s_ajax_call']) && ($_POST['s_ajax_call'] == $_SESSION['validate_s_access']) && isset($_POST['currentextension']) && $_POST['currentextension'] != '' && |
|
13 |
+ isset($_POST['currentchatpubkey']) && $_POST['currentchatpubkey'] != '') { |
|
14 |
+ |
|
15 |
+ $sipusersendrec = $_POST['currentextension']; |
|
16 |
+ $chatPubKey = $_POST['currentchatpubkey']; |
|
17 |
+ |
|
18 |
+ // Create the directories if they don't exist |
|
19 |
+ if (!is_dir('textchat')) { |
|
20 |
+ mkdir('textchat', 0700); |
|
21 |
+ } |
|
22 |
+ |
|
23 |
+ if (!is_dir('textchat/' . $sipusersendrec)) { |
|
24 |
+ mkdir('textchat/' . $sipusersendrec, 0700); |
|
25 |
+ } |
|
26 |
+ |
|
27 |
+ // Save the RSA public key |
|
28 |
+ if ($sipusersendrec != '') { |
|
29 |
+ |
|
30 |
+ $savePubKey = file_put_contents('textchat/' . $sipusersendrec . '/rsa_1024_pub.pem', $chatPubKey); |
|
31 |
+ chmod('textchat/' . $sipusersendrec . '/rsa_1024_pub.pem', 0600); |
|
32 |
+ $messageres = 'success'; |
|
33 |
+ |
|
34 |
+ } else { |
|
35 |
+ $messageres = 'failure'; |
|
36 |
+ } |
|
37 |
+ |
|
38 |
+ $generateresp = ['messageres' => $messageres]; |
|
39 |
+ |
|
40 |
+ echo json_encode($generateresp); |
|
41 |
+ |
|
42 |
+} else { |
|
43 |
+ header("Location: roundpin-login.php"); |
|
44 |
+} |
|
45 |
+ |
|
46 |
+?> |