prepare("SELECT userrole, username FROM app_users WHERE BINARY username = ?"); $querysel->bind_param("s", $username); $querysel->execute(); $confdatafromdb = $querysel->get_result()->fetch_assoc(); $cruserrole = $confdatafromdb['userrole']; // Check if the banned user has been already introduced in the 'banned_users' table $queryselck = $mysqli->prepare("SELECT banned_sipusername, conf_extension FROM banned_users WHERE banned_sipusername = ? AND conf_extension = ?"); $queryselck->bind_param("ss", $bannedSipUserName, $confExtension); $queryselck->execute(); $userdatafromdbck = $queryselck->get_result()->fetch_assoc(); if ($cruserrole == 'superadmin' || $cruserrole == 'admin') { if ($bannedDays != 0) { if ($userdatafromdbck) { $updatequerysp = $mysqli->prepare("UPDATE banned_users SET ban_creator = ?, banned_profilename = ?, conf_label = ?, banned_until = ? WHERE banned_sipusername = ? AND conf_extension = ?"); $updatequerysp->bind_param("ssssss", $username, $bannedProfileName, $conflabel, $bannedUntil, $bannedSipUserName, $confExtension); if ($updatequerysp->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'Error while updating the data !'; } } else { $insertquerysp = $mysqli->prepare("INSERT INTO banned_users (ban_creator, banned_profilename, banned_sipusername, conf_extension, conf_label, banned_until) VALUES(?, ?, ?, ?, ?, ?)"); $insertquerysp->bind_param("ssssss", $username, $bannedProfileName, $bannedSipUserName, $confExtension, $conflabel, $bannedUntil); if ($insertquerysp->execute()) { $messagetosend = 'success'; } else { $messagetosend = 'Error while inserting the data !'; } } } else { $messagetosend = 'success'; } } else { $messagetosend = 'Only Admins and Superadmins can ban other participants to video conferences and establish a ban duration.'; } $response = array('result' => $messagetosend); echo json_encode($response); } else { header("Location: ../login.php"); } ?>