| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,46 @@ |
| 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']) && $_POST['username'] == $_SESSION['loginname']) {
|
|
| 15 |
+ |
|
| 16 |
+ define('ACCESSCONST', TRUE);
|
|
| 17 |
+ require('db-connect.php');
|
|
| 18 |
+ |
|
| 19 |
+ $username = $_POST['username']; |
|
| 20 |
+ $usergroup = $_POST['newgroup']; |
|
| 21 |
+ |
|
| 22 |
+ // Get the role and id of the user who creates the group, from the 'app_users' table |
|
| 23 |
+ $queryprm = $mysqli->prepare("SELECT id, userrole, username FROM app_users WHERE username = ?");
|
|
| 24 |
+ $queryprm->bind_param("s", $username);
|
|
| 25 |
+ $queryprm->execute(); |
|
| 26 |
+ $queryprmres = $queryprm->get_result()->fetch_assoc(); |
|
| 27 |
+ $cruserrole = $queryprmres["userrole"]; |
|
| 28 |
+ $cruserid = $queryprmres["id"]; |
|
| 29 |
+ |
|
| 30 |
+ if ($cruserrole == 'admin' || $cruserrole == 'superadmin') {
|
|
| 31 |
+ |
|
| 32 |
+ $queryingr = $mysqli->prepare("INSERT INTO groups (userid, group_name) VALUES (?, ?)");
|
|
| 33 |
+ $queryingr->bind_param("is", $cruserid, $usergroup);
|
|
| 34 |
+ |
|
| 35 |
+ if ($queryingr->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'An error occurred while attempting to save the group to the database!'; }
|
|
| 36 |
+ |
|
| 37 |
+ } else { $messagetosend = 'Only Admins and Superadmins can create new groups.'; }
|
|
| 38 |
+ |
|
| 39 |
+ $response = array('result' => $messagetosend);
|
|
| 40 |
+ echo json_encode($response); |
|
| 41 |
+ |
|
| 42 |
+} else {
|
|
| 43 |
+ header("Location: ../login.php");
|
|
| 44 |
+} |
|
| 45 |
+ |
|
| 46 |
+?> |