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