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,55 @@
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
+ // header('Set-Cookie: PHPSESSID= ' . session_id() . '; SameSite=strict; Secure=true; HttpOnly=true;');
13
+
14
+if (isset($_POST['s_ajax_call']) && ($_POST['s_ajax_call'] == $_SESSION['validate_s_access'])) {
15
+
16
+ define('ACCESSCONST', TRUE);
17
+
18
+ require('db-connect.php');
19
+
20
+    $username = $_POST['username'];
21
+
22
+    // Get the id of the superadmin for which we want to remove the data
23
+    $enabled = 1;
24
+    $selectid = $mysqli->prepare("SELECT id, userrole, username, enabled FROM app_users WHERE userrole = ? AND BINARY username = ? AND enabled = ?");
25
+    $selectid->bind_param("ssi", 'superadmin', $username, $enabled);
26
+    $selectid->execute();
27
+    $queryres = $selectid->get_result()->fetch_assoc();
28
+    $userID = $queryres['id'];
29
+
30
+    // Remove the row(s) corresponding to the specified superadmin from the 'external_users' table
31
+    $removequery = $mysqli->prepare("DELETE FROM external_users WHERE userid = ?");
32
+    $removequery->bind_param("i", $userID);
33
+
34
+    if ($removequery->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'failure'; }
35
+    $removequery->close();
36
+
37
+    // Reindex the 'external_users' table
38
+    $reindexset = $mysqli->prepare("SET @resetrec = 0");
39
+    $reindexup = $mysqli->prepare("UPDATE external_users SET id = @resetrec := @resetrec + 1");
40
+    $reindexalt = $mysqli->prepare("ALTER TABLE external_users auto_increment = 1");
41
+    if ($reindexset->execute() && $reindexup->execute() && $reindexalt->execute()) {} else { $messagetosend = 'failure'; }
42
+
43
+    // Remove the password files directory
44
+    if (is_dir("../restr/".$username."/externalext")) {
45
+        $removedir = exec("rm -rf ../restr/".$username."/externalext");
46
+    }
47
+
48
+    $response = array('result' => $messagetosend);
49
+    echo json_encode($response);
50
+
51
+} else {
52
+    header("Location: ../login.php");
53
+}
54
+
55
+?>