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
+    $videoConfExtension = $_POST['video_conf_extension'];
22
+
23
+    // Get the id of the current user from the 'app_users' table
24
+    $querysel = $mysqli->prepare("SELECT id, userrole, username FROM app_users WHERE BINARY username = ?");
25
+    $querysel->bind_param("s", $username);
26
+    $querysel->execute();
27
+    $confdatafromdb = $querysel->get_result()->fetch_assoc();
28
+    $cruserid = $confdatafromdb['id'];
29
+    $cruserrole = $confdatafromdb['userrole'];
30
+
31
+    if ($cruserrole == 'superadmin') {
32
+
33
+        // Remove the video conference data from the 'conferences_video' table
34
+        $querydel = $mysqli->prepare("DELETE FROM conferences_video WHERE video_conf_extension = ?");
35
+        $querydel->bind_param("s", $videoConfExtension);
36
+
37
+        if ($querydel->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'Error while removing the data !'; }
38
+
39
+    } elseif ($cruserrole == 'admin') {
40
+
41
+        // Get the id of the user who saved this conference data
42
+        $queryfd = $mysqli->prepare("SELECT id, userid, video_conf_extension FROM conferences_video WHERE video_conf_extension = ?");
43
+        $queryfd->bind_param("s", $videoConfExtension);
44
+        $queryfd->execute();
45
+        $confdatadb = $queryfd->get_result()->fetch_assoc();
46
+        $useridfdb = $confdatadb['userid'];
47
+
48
+        if ($useridfdb == $cruserid) {
49
+
50
+            // Remove the video conference data from the 'conferences_video' table
51
+            $querydelad = $mysqli->prepare("DELETE FROM conferences_video WHERE userid = ? AND video_conf_extension = ?");
52
+            $querydelad->bind_param("is", $cruserid, $videoConfExtension);
53
+
54
+            if ($querydelad->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'Error while removing the data !'; }
55
+
56
+        } else { $messagetosend = "You are not allowed to remove this conference data!"; }
57
+
58
+    } elseif ($cruserrole == 'regular_user') { $messagetosend = 'Only Admins and Superadmins can remove conference data!'; }
59
+
60
+    $response = array('result' => $messagetosend);
61
+    echo json_encode($response);
62
+
63
+} else {
64
+    header("Location: ../login.php");
65
+}
66
+
67
+?>