| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,89 @@ |
| 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 |
+ $vconfsipuser = $_POST['vconfsipuser']; |
|
| 22 |
+ $vconfExtension = $_POST['vconfextension']; |
|
| 23 |
+ |
|
| 24 |
+ // Get the user role and the list of groups to which the current user belongs, from the 'app_users' table |
|
| 25 |
+ $querygr = $mysqli->prepare("SELECT id, userrole, username, user_groups FROM app_users WHERE BINARY username = ?");
|
|
| 26 |
+ $querygr->bind_param("s", $username);
|
|
| 27 |
+ $querygr->execute(); |
|
| 28 |
+ $querygrres = $querygr->get_result()->fetch_assoc(); |
|
| 29 |
+ $userrole = $querygrres['userrole']; |
|
| 30 |
+ |
|
| 31 |
+ if ($userrole != 'superadmin') {
|
|
| 32 |
+ |
|
| 33 |
+ $usergroupsall = $querygrres['user_groups']; |
|
| 34 |
+ $usergroupsarr = explode("|", $usergroupsall);
|
|
| 35 |
+ array_shift($usergroupsarr); |
|
| 36 |
+ array_pop($usergroupsarr); |
|
| 37 |
+ |
|
| 38 |
+ // Get the list of groups whose users have access to the current video conference |
|
| 39 |
+ $querycont = $mysqli->prepare("SELECT id, video_conf_extension, limit_to_groups FROM conferences_video WHERE video_conf_extension = ?");
|
|
| 40 |
+ $querycont->bind_param("s", $vconfExtension);
|
|
| 41 |
+ $querycont->execute(); |
|
| 42 |
+ $querytcagr = $querycont->get_result()->fetch_assoc(); |
|
| 43 |
+ $querytcagrlst = $querytcagr['limit_to_groups']; |
|
| 44 |
+ $querytcagrarr = explode("|", $querytcagrlst);
|
|
| 45 |
+ array_shift($querytcagrarr); |
|
| 46 |
+ array_pop($querytcagrarr); |
|
| 47 |
+ |
|
| 48 |
+ $chck = 0; |
|
| 49 |
+ foreach ($usergroupsarr as $key => $arrval) {
|
|
| 50 |
+ if (in_array($arrval, $querytcagrarr)) { $chck++; }
|
|
| 51 |
+ } |
|
| 52 |
+ |
|
| 53 |
+ if ($chck > 0) { $restrictmessage = 'success'; } else { $restrictmessage = 'failure'; }
|
|
| 54 |
+ |
|
| 55 |
+ } else { $restrictmessage = 'success'; }
|
|
| 56 |
+ |
|
| 57 |
+ // Check if the current user has been banned from accessing this conference |
|
| 58 |
+ $queryselck = $mysqli->prepare("SELECT banned_sipusername, conf_extension, banned_until FROM banned_users WHERE banned_sipusername = ? AND conf_extension = ?");
|
|
| 59 |
+ $queryselck->bind_param("ss", $vconfsipuser, $vconfExtension);
|
|
| 60 |
+ $queryselck->execute(); |
|
| 61 |
+ $userdatafromdbck = $queryselck->get_result()->fetch_assoc(); |
|
| 62 |
+ |
|
| 63 |
+ if ($userdatafromdbck) {
|
|
| 64 |
+ |
|
| 65 |
+ $currentDate = new DateTime(date("Y-m-d H:i:s"));
|
|
| 66 |
+ $banDate = new DateTime($userdatafromdbck['banned_until']); |
|
| 67 |
+ |
|
| 68 |
+ if ($currentDate <= $banDate) {
|
|
| 69 |
+ $banmessage = 'failure'; |
|
| 70 |
+ } else {
|
|
| 71 |
+ $banmessage = 'success'; |
|
| 72 |
+ |
|
| 73 |
+ // Remove the database record, since the ban time has expired |
|
| 74 |
+ $querydel = $mysqli->prepare("DELETE FROM banned_users WHERE banned_sipusername = ? AND conf_extension = ?");
|
|
| 75 |
+ $querydel->bind_param("ss", $vconfsipuser, $vconfExtension);
|
|
| 76 |
+ $querydel->execute(); |
|
| 77 |
+ } |
|
| 78 |
+ |
|
| 79 |
+ } else { $banmessage = 'success'; }
|
|
| 80 |
+ |
|
| 81 |
+ $response = array('restrict' => $restrictmessage, 'notbanned' => $banmessage);
|
|
| 82 |
+ |
|
| 83 |
+ echo json_encode($response); |
|
| 84 |
+ |
|
| 85 |
+} else {
|
|
| 86 |
+ header("Location: ../login.php");
|
|
| 87 |
+} |
|
| 88 |
+ |
|
| 89 |
+?> |