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,48 @@
1
+<?php
2
+/**
3
+ *  Copyright (C) 2022, 2024  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'])) {
13
+
14
+ define('ACCESSCONST', TRUE);
15
+
16
+ require('db-connect.php');
17
+
18
+    $username = $_POST['username'];
19
+    $extenForExternal = $_POST['exten_for_external'];
20
+
21
+    // Get the id of the user for which we want to remove the extension for external access
22
+    $enabled = 1;
23
+    $selectid = $mysqli->prepare("SELECT id, userrole, username, enabled FROM app_users WHERE (userrole = 'admin' OR userrole = 'superadmin') AND BINARY username = ? AND enabled = ?");
24
+    $selectid->bind_param("si", $username, $enabled);
25
+    $selectid->execute();
26
+    $queryres = $selectid->get_result()->fetch_assoc();
27
+    $userID = $queryres['id'];
28
+
29
+    // Remove the row corresponding to the specified user and extension from the 'external_users' table
30
+    $removequery = $mysqli->prepare("DELETE FROM external_users WHERE userid = ? AND exten_for_external = ?");
31
+    $removequery->bind_param("is", $userID, $extenForExternal);
32
+
33
+    if ($removequery->execute()) { $messagetosend = 'The data has been successfully removed from the database !'; } else { $messagetosend = 'Error while removing the data from the database !'; }
34
+    $removequery->close();
35
+
36
+    // Remove the password file for the extension whose data has been removed from the 'external_users' table
37
+    if (file_exists("../restr/".$username."/externalext/".$extenForExternal)) {
38
+        $removefile = exec("rm ../restr/".$username."/externalext/".$extenForExternal);
39
+    }
40
+
41
+    $response = array('result' => $messagetosend);
42
+    echo json_encode($response);
43
+
44
+} else {
45
+    header("Location: ../login.php");
46
+}
47
+
48
+?>