| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,108 @@ |
| 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 |
+if (($_SESSION['loggedtorspanel'] == true) && ($_SESSION['userrole'] == 'superadmin')) {
|
|
| 30 |
+ |
|
| 31 |
+ require('db-connect.php');
|
|
| 32 |
+ |
|
| 33 |
+ // Insert new component data into the database |
|
| 34 |
+ if (isset($_POST['userrole']) && isset($_POST['username']) && isset($_POST['componentname']) && isset($_POST['componentrole']) && isset($_POST['componentplace'])) {
|
|
| 35 |
+ |
|
| 36 |
+ $ordno = $_POST['ordno']; |
|
| 37 |
+ $dbid = $_POST['dbid']; |
|
| 38 |
+ $userrole = $_POST['userrole']; |
|
| 39 |
+ $username = $_POST['username']; |
|
| 40 |
+ $componentname = $_POST['componentname']; |
|
| 41 |
+ $componentrole = $_POST['componentrole']; |
|
| 42 |
+ $componentplace = $_POST['componentplace']; |
|
| 43 |
+ $imagename = $_POST['imagename']; |
|
| 44 |
+ $versionscript = $_POST['versionscript']; |
|
| 45 |
+ $popupinfo = $_POST['infopopup']; |
|
| 46 |
+ |
|
| 47 |
+ if (($userrole != '') && ($username != '') && ($componentname != '')) {
|
|
| 48 |
+ |
|
| 49 |
+ if ($dbid == '') {
|
|
| 50 |
+ |
|
| 51 |
+ try {
|
|
| 52 |
+ $query1 = $mysqli->prepare("INSERT INTO components (orderno, userrole, username, component, componentrole, componentplace, imagename, versionscript,
|
|
| 53 |
+ info) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"); |
|
| 54 |
+ $query1->bind_param("issssssss", $ordno, $userrole, $username, $componentname, $componentrole, $componentplace, $imagename, $versionscript, $popupinfo);
|
|
| 55 |
+ $query1->execute(); |
|
| 56 |
+ $query1->close(); |
|
| 57 |
+ $responsave = "The component has been added successfully !"; |
|
| 58 |
+ |
|
| 59 |
+ } catch(mysqli_sql_exception $e) {
|
|
| 60 |
+ |
|
| 61 |
+ $responsave = "An error occurred when adding the component. Please check your input data !"; |
|
| 62 |
+ } |
|
| 63 |
+ |
|
| 64 |
+ } else {
|
|
| 65 |
+ |
|
| 66 |
+ try {
|
|
| 67 |
+ |
|
| 68 |
+ if ($imagename != '') {
|
|
| 69 |
+ $query2 = $mysqli->prepare("UPDATE components SET orderno=?, component=?, componentrole=?, componentplace=?, imagename=?, versionscript=?,
|
|
| 70 |
+ info=? WHERE id=?"); |
|
| 71 |
+ $query2->bind_param("issssssi", $ordno, $componentname, $componentrole, $componentplace, $imagename, $versionscript, $popupinfo, $dbid);
|
|
| 72 |
+ $query2->execute(); |
|
| 73 |
+ $query2->close(); |
|
| 74 |
+ |
|
| 75 |
+ } else {
|
|
| 76 |
+ $query3 = $mysqli->prepare("UPDATE components SET orderno=?, component=?, componentrole=?, componentplace=?, versionscript=?,
|
|
| 77 |
+ info=? WHERE id=?"); |
|
| 78 |
+ $query3->bind_param("isssssi", $ordno, $componentname, $componentrole, $componentplace, $versionscript, $popupinfo, $dbid);
|
|
| 79 |
+ $query3->execute(); |
|
| 80 |
+ $query3->close(); |
|
| 81 |
+ } |
|
| 82 |
+ $responsave = "The component has been updated successfully !"; |
|
| 83 |
+ |
|
| 84 |
+ } catch(mysqli_sql_exception $e) {
|
|
| 85 |
+ |
|
| 86 |
+ $responsave = "An error occurred when updating the component. Please check your input data !"; |
|
| 87 |
+ } |
|
| 88 |
+ } |
|
| 89 |
+ |
|
| 90 |
+ } else { $responsave = "Error. Please check your input data !"; }
|
|
| 91 |
+ } |
|
| 92 |
+ |
|
| 93 |
+ $result = array( |
|
| 94 |
+ 'responsave' => $responsave |
|
| 95 |
+ ); |
|
| 96 |
+ |
|
| 97 |
+ echo json_encode($result); |
|
| 98 |
+ |
|
| 99 |
+} elseif (empty($_SESSION['loggedtorspanel'])) {
|
|
| 100 |
+ |
|
| 101 |
+ header("Location: panel-login.php");
|
|
| 102 |
+ |
|
| 103 |
+} elseif (($_SESSION['loggedtorspanel'] == true) && ($_SESSION['userrole'] != 'superadmin')) {
|
|
| 104 |
+ |
|
| 105 |
+ header("Location: index.php");
|
|
| 106 |
+} |
|
| 107 |
+ |
|
| 108 |
+?> |