Browse code

Created repository.

DoubleBastionAdmin authored on 29/11/2024 03:10:08
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,67 @@
1
+<?php
2
+
3
+/**
4
+ * @copyright 2024 Double Bastion LLC <www.doublebastion.com>
5
+ *
6
+ * @author Double Bastion LLC
7
+ *
8
+ * @license GNU AGPL version 3 or any later version
9
+ *
10
+ * This program is free software; you can redistribute it and/or
11
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
12
+ * License as published by the Free Software Foundation; either
13
+ * version 3 of the License, or any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
19
+ *
20
+ * You should have received a copy of the GNU Affero General Public
21
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
+ *
23
+ */
24
+
25
+session_start();
26
+
27
+define('ACCESSCONST', TRUE);
28
+
29
+
30
+if (($_SESSION['loggedtorspanel'] == true) && ($_SESSION['userrole'] == 'superadmin')) {
31
+
32
+     require('db-connect.php');
33
+
34
+     // Delete component data from the database
35
+     if (isset($_POST['database_id'])) {
36
+
37
+         $database_ID = $_POST['database_id'];
38
+
39
+         try {
40
+              $query = $mysqli->prepare("DELETE FROM components WHERE id=?");
41
+              $query->bind_param("i", $database_ID);
42
+              $query->execute();
43
+              $query->close();
44
+              $messagedelcom = "The component has been removed successfully !";
45
+
46
+         } catch(mysqli_sql_exception $e) {
47
+                 $messagedelcom = "An error occurred when removing the component !";
48
+           }
49
+     }
50
+
51
+     $compresponse = array(
52
+        'messagedelcom' => $messagedelcom
53
+     );
54
+
55
+     echo json_encode($compresponse);
56
+
57
+
58
+} elseif (empty($_SESSION['loggedtorspanel'])) {
59
+
60
+      header("Location: panel-login.php");
61
+
62
+} elseif (($_SESSION['loggedtorspanel'] == true) && ($_SESSION['userrole'] != 'superadmin'))  {
63
+
64
+      header("Location: index.php");
65
+}
66
+
67
+?>