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,68 @@
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
+    $bannedExtension = $_POST['bannedsipusername'];
22
+    $vconfExtension = $_POST['confextension'];
23
+    $newBanDate = $_POST['nwbandate'] . " 00:00:00";
24
+
25
+    // Get the role of the user who saves the ban date, from the 'app_users' table
26
+    $queryprm = $mysqli->prepare("SELECT userrole, username FROM app_users WHERE username = ?");
27
+    $queryprm->bind_param("s", $username);
28
+    $queryprm->execute();
29
+    $queryprmres = $queryprm->get_result()->fetch_assoc();
30
+    $cruserrole = $queryprmres["userrole"];
31
+
32
+    if ($cruserrole == 'superadmin') {
33
+
34
+        $queryrm = $mysqli->prepare("DELETE FROM `banned_users` WHERE `banned_sipusername`=? AND `conf_extension`=?");
35
+        $queryrm->bind_param("ss", $bannedExtension, $vconfExtension);
36
+
37
+        if ($queryrm->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'An error occurred while attempting to remove ban data from the database!'; }
38
+
39
+    } elseif ($cruserrole == 'admin') {
40
+
41
+        // Check if the banned user has been banned by the current admin
42
+        $querychck = $mysqli->prepare("SELECT ban_creator, banned_sipusername, conf_extension FROM banned_users WHERE banned_sipusername = ? AND conf_extension = ?");
43
+        $querychck->bind_param("ss", $bannedExtension, $vconfExtension);
44
+        $querychck->execute();
45
+        $querychckres = $querychck->get_result()->fetch_assoc();
46
+        $banCreator = $querychckres['ban_creator'];
47
+
48
+        if ($banCreator == $username) {
49
+
50
+            $queryadmrm = $mysqli->prepare("DELETE FROM `banned_users` WHERE `banned_sipusername`=? AND `conf_extension`=?");
51
+            $queryadmrm->bind_param("ss", $bannedExtension, $vconfExtension);
52
+
53
+            if ($queryadmrm->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'An error occurred while attempting to remove ban data from the database!'; }
54
+
55
+        } else { $messagetosend = 'You can unban only the users that were banned by you.'; }
56
+
57
+    } elseif ($cruserrole == 'regular_user') {
58
+              $messagetosend = 'Only Admins and Superadmins can change the ban time of a user.';
59
+    }
60
+
61
+    $response = array('result' => $messagetosend);
62
+    echo json_encode($response);
63
+
64
+} else {
65
+    header("Location: ../login.php");
66
+}
67
+
68
+?>