| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,43 @@ |
| 1 |
+<?php |
|
| 2 |
+/** |
|
| 3 |
+ * Copyright (C) 2021, 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 |
+ $contactName = $_POST['contact_name']; |
|
| 20 |
+ |
|
| 21 |
+ // Get the id of the current user from the 'app_users' table |
|
| 22 |
+ $enabled = 1; |
|
| 23 |
+ $queryid = $mysqli->prepare("SELECT id, username, enabled FROM app_users WHERE BINARY username = ? AND enabled = ?");
|
|
| 24 |
+ $queryid->bind_param("si", $username, $enabled);
|
|
| 25 |
+ $queryid->execute(); |
|
| 26 |
+ $queryres = $queryid->get_result()->fetch_assoc(); |
|
| 27 |
+ $userID = $queryres['id']; |
|
| 28 |
+ |
|
| 29 |
+ // Remove the contact from the 'contacts' table |
|
| 30 |
+ $querycont = $mysqli->prepare("DELETE FROM contacts WHERE user_id = ? AND contact_name = ?");
|
|
| 31 |
+ $querycont->bind_param("ss", $userID, $contactName);
|
|
| 32 |
+ $querycont->execute(); |
|
| 33 |
+ |
|
| 34 |
+ if ($querycont) { $message = 'success'; } else { $message = 'failure'; }
|
|
| 35 |
+ |
|
| 36 |
+ $delresult = ['removeresult' => $message]; |
|
| 37 |
+ echo json_encode($delresult); |
|
| 38 |
+ |
|
| 39 |
+} else {
|
|
| 40 |
+ header("Location: ../login.php");
|
|
| 41 |
+} |
|
| 42 |
+ |
|
| 43 |
+?> |