Browse code

Created repository.

DoubleBastionAdmin authored on 26/01/2022 20:32:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,45 @@
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'])) {
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 superadmin for which we want to remove the extension for external access
22
+    $selectid = $mysqli->query("SELECT id, userrole, username, enabled FROM app_users WHERE userrole = 'superadmin' AND BINARY username = '$username' AND enabled = 1");
23
+    $queryres = $selectid->fetch_array();
24
+    $userID = $queryres[0];
25
+
26
+    // Remove the row corresponding to the specified superadmin and extension from the 'external_users' table
27
+    $removequery = $mysqli->prepare("DELETE FROM external_users WHERE userid=? AND exten_for_external=?");
28
+    $removequery->bind_param("is", $userID, $extenForExternal);
29
+
30
+    if ($removequery->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'failure'; }
31
+    $removequery->close();
32
+
33
+    // Remove the password file for the extension whose data has been removed from the 'external_users' table
34
+    if (file_exists("restr/".$username."/externalext/".$extenForExternal)) {
35
+        $removefile = exec("rm restr/".$username."/externalext/".$extenForExternal);
36
+    }
37
+
38
+    $response = array('result' => $messagetosend);
39
+    echo json_encode($response);
40
+
41
+} else {
42
+    header("Location: roundpin-login.php");
43
+}
44
+
45
+?>