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,71 @@
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
+    $bannedProfileName = $_POST['bannedprofilename'];
20
+    $bannedSipUserName = $_POST['bannedsipusername'];
21
+    $confExtension = $_POST['confextension'];
22
+    $conflabel = $_POST['conflabel'];
23
+    $bannedDays = $_POST['banneddays'];
24
+
25
+    $bannedUntil = date('Y-m-d', strtotime("+". $bannedDays ." days"));
26
+
27
+    // Get the role of the current user from the 'app_users' table
28
+    $querysel = $mysqli->prepare("SELECT userrole, username FROM app_users WHERE BINARY username = ?");
29
+    $querysel->bind_param("s", $username);
30
+    $querysel->execute();
31
+    $confdatafromdb = $querysel->get_result()->fetch_assoc();
32
+    $cruserrole = $confdatafromdb['userrole'];
33
+
34
+    // Check if the banned user has been already introduced in the 'banned_users' table
35
+    $queryselck = $mysqli->prepare("SELECT banned_sipusername, conf_extension FROM banned_users WHERE banned_sipusername = ? AND conf_extension = ?");
36
+    $queryselck->bind_param("ss", $bannedSipUserName, $confExtension);
37
+    $queryselck->execute();
38
+    $userdatafromdbck = $queryselck->get_result()->fetch_assoc();
39
+
40
+    if ($cruserrole == 'superadmin' || $cruserrole == 'admin') {
41
+
42
+        if ($bannedDays != 0) {
43
+
44
+            if ($userdatafromdbck) {
45
+
46
+                $updatequerysp = $mysqli->prepare("UPDATE banned_users SET ban_creator = ?, banned_profilename = ?, conf_label = ?, banned_until = ? WHERE banned_sipusername = ? AND 
47
+                                               conf_extension = ?");
48
+                $updatequerysp->bind_param("ssssss", $username, $bannedProfileName, $conflabel, $bannedUntil, $bannedSipUserName, $confExtension);
49
+                if ($updatequerysp->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'Error while updating the data !'; }
50
+
51
+            } else {
52
+
53
+                $insertquerysp = $mysqli->prepare("INSERT INTO banned_users (ban_creator, banned_profilename, banned_sipusername, conf_extension, conf_label, banned_until) 
54
+                                               VALUES(?, ?, ?, ?, ?, ?)");
55
+                $insertquerysp->bind_param("ssssss", $username, $bannedProfileName, $bannedSipUserName, $confExtension, $conflabel, $bannedUntil);
56
+                if ($insertquerysp->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'Error while inserting the data !'; }
57
+            }
58
+
59
+        } else { $messagetosend = 'success'; }
60
+
61
+    } else { $messagetosend = 'Only Admins and Superadmins can ban other participants to video conferences and establish a ban duration.'; }
62
+
63
+    $response = array('result' => $messagetosend);
64
+
65
+    echo json_encode($response);
66
+
67
+} else {
68
+    header("Location: ../login.php");
69
+}
70
+
71
+?>