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,74 @@
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
+if ($_SESSION['loggedtorspanel'] == true) {
28
+
29
+define('ACCESSCONST', TRUE);
30
+
31
+require('db-connect.php');
32
+
33
+  if (isset($_POST['newdir'])) {
34
+
35
+     $newdirpath = $_POST['newdir'];
36
+
37
+     if ($newdirpath != '') {
38
+
39
+        if (is_dir($newdirpath)) {
40
+
41
+           try {
42
+
43
+             $query0 = $mysqli->prepare("UPDATE detectionsdir SET detdir=? WHERE id=1");
44
+             $query0->bind_param("s", $newdirpath);
45
+             $query0->execute();
46
+             $query0->close();
47
+
48
+             $result = 'success';
49
+             $messagetosend = "The new directory has been saved !";
50
+
51
+           } catch (mysqli_sql_exception $e) {
52
+                $result = 'failure';
53
+                $messagetosend = "An error occurred while processing your request. You can try again after a few moments !";
54
+           }
55
+
56
+        } else {
57
+                $result = 'failure';
58
+                $messagetosend = "The directory that you entered doesn't exist on the server. Please enter the full path of an existing directory !";
59
+        }
60
+
61
+     } else {
62
+                $result = 'failure';
63
+                $messagetosend = "Please enter the full path of an existing directory !";
64
+     }
65
+
66
+     $resp = array('result' => $result, 'messagetosend' => $messagetosend);
67
+     echo json_encode($resp);
68
+  }
69
+
70
+} else {
71
+     header("Location: panel-login.php");
72
+}
73
+
74
+?>