| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,66 @@ |
| 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['conferenceext']) && |
|
| 14 |
+ $_POST['conferenceext'] != '' && isset($_POST['currentextension']) && $_POST['currentextension'] != '' && isset($_POST['currentchatpubkey']) && $_POST['currentchatpubkey'] != '') {
|
|
| 15 |
+ |
|
| 16 |
+ define('ACCESSCONST', TRUE);
|
|
| 17 |
+ |
|
| 18 |
+ require('db-connect.php');
|
|
| 19 |
+ |
|
| 20 |
+ $vconfExtension = $_POST['vconfextension']; |
|
| 21 |
+ $extenPassEnc = $_POST['encextenpass']; |
|
| 22 |
+ $conferenceExt = $_POST['conferenceext']; |
|
| 23 |
+ |
|
| 24 |
+ $sipusersendrec = $_POST['currentextension']; |
|
| 25 |
+ $chatPubKey = $_POST['currentchatpubkey']; |
|
| 26 |
+ |
|
| 27 |
+ // 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 |
|
| 28 |
+ $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 = ?");
|
|
| 29 |
+ $query->bind_param("sss", $vconfExtension, $extenPassEnc, $conferenceExt);
|
|
| 30 |
+ $query->execute(); |
|
| 31 |
+ $extqueryres = $query->get_result()->fetch_array(); |
|
| 32 |
+ |
|
| 33 |
+ if (!$extqueryres) {
|
|
| 34 |
+ |
|
| 35 |
+ http_response_code(400); |
|
| 36 |
+ exit(); |
|
| 37 |
+ |
|
| 38 |
+ } else {
|
|
| 39 |
+ |
|
| 40 |
+ // Create the necessary directory if it doesn't exist |
|
| 41 |
+ if (!is_dir('../textchat/' . $sipusersendrec)) {
|
|
| 42 |
+ mkdir('../textchat/' . $sipusersendrec, 0700);
|
|
| 43 |
+ } |
|
| 44 |
+ |
|
| 45 |
+ // Save the RSA public key |
|
| 46 |
+ if ($sipusersendrec != '') {
|
|
| 47 |
+ |
|
| 48 |
+ $savePubKey = file_put_contents('../textchat/' . $sipusersendrec . '/rsa_1024_pub.pem', $chatPubKey);
|
|
| 49 |
+ chmod('../textchat/' . $sipusersendrec . '/rsa_1024_pub.pem', 0600);
|
|
| 50 |
+ $messageres = 'success'; |
|
| 51 |
+ |
|
| 52 |
+ } else {
|
|
| 53 |
+ $messageres = 'failure'; |
|
| 54 |
+ } |
|
| 55 |
+ |
|
| 56 |
+ } |
|
| 57 |
+ |
|
| 58 |
+ $generateresp = ['messageres' => $messageres]; |
|
| 59 |
+ |
|
| 60 |
+ echo json_encode($generateresp); |
|
| 61 |
+ |
|
| 62 |
+} else {
|
|
| 63 |
+ header("Location: ../login.php");
|
|
| 64 |
+} |
|
| 65 |
+ |
|
| 66 |
+?> |