-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig-edit.php
More file actions
314 lines (263 loc) · 11.3 KB
/
config-edit.php
File metadata and controls
314 lines (263 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<?php
session_start();
include('sessionCheck.php');
if(isset($_GET['exit'])){}
// Check if $_SESSION['selected_session'] is set
if (isset($_SESSION['selected_session'])) {
// Unset (remove) $_SESSION['selected_session']
unset($_SESSION['selected_session']);
}
$username = $_SESSION['username'];
$userDataFile = "users/" . $username . ".php";
// Function to get user data from file
function getUserData($userDataFile) {
$userData = array();
if (file_exists($userDataFile)) {
$lines = file($userDataFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
list($key, $value) = explode(':', $line, 2);
$userData[trim($key)] = trim($value);
}
}
return $userData;
}
$userData = getUserData($userDataFile);
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css">
<link rel="icon" type="image/png" href="favicon.png">
<link rel="manifest" href="manifest.json">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
<style>
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
#options-container {
max-width: 800px;
margin: 50px auto;
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h2 {
color: #333;
}
ul {
list-style: none;
padding: 0;
}
li {
margin-bottom: 10px;
}
p {
margin: 0;
}
input[type="text"], textarea {
padding: 8px;
width: 100%;
box-sizing: border-box;
margin-bottom: 10px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
}
th,
td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
a {
text-decoration: none;
color: #3498db;
}
form {
display: flex;
flex-direction: column;
}
label {
margin-bottom: 5px;
font-weight: bold;
}
input[type="submit"] {
width: 100px;
align-self: flex-end;
padding: 10px;
background-color: #3498db;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #2980b9;
}
</style>
<script>
function confirmDeletion() {
if (confirm('Are you sure you want to delete all files and folders in this directory? This action cannot be undone.')) {
document.getElementById('delete-form').submit();
}
}
</script>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js')
.then(registration => {
console.log('Service Worker registered with scope:', registration.scope);
})
.catch(error => {
console.error('Service Worker registration failed:', error);
});
}
</script>
<title>CAS - Database</title>
</head>
<body>
<?php
include('lib/nav.php');
include('lib/sus_re_dir.php');
?>
<div id="options-container">
<h2>Edit Configuration</h2>
<?php
$configFile = 'config.php';
include($configFile);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
//Values changeable by admin
$accountLevel = $_POST['accountLevel'];
$logo = $_POST['logo'];
$icon = $_POST['icon'];
$ImgSize = $_POST['ImgSize'];
$imgQuality = $_POST['imgQuality'];
$messageUpdate = $_POST['messageUpdate'];
$opacity = $_POST['opacity'];
$pdfIcon = $_POST['pdfIcon'];
$dateFont = $_POST['dateFont'];
$messageFont = $_POST['messageFont'];
$imgSizePercentage = $_POST['imgSizePercentage'];
$error = $_POST['error'];
//Values not changeable by admin
$secretkey = $secretkey;
$iv = $iv;
$usernameCookieName = $usernameCookieName;
$updatesUrl =$updatesUrl;
$configData = "<?php\n";
$configData .= "///////////////////Default account status after registration//////////////\n";
$configData .= "\$accountLevel='$accountLevel'; //suspended, limited, standard, advanced or admin\n\n";
$configData .= "///////////////////////////////////////////////////////////\n";
$configData .= "////////////////Images upload /////////////////////////////\n";
$configData .= "\$icon='$icon'; //icon link\n";
$configData .= "\$logo='$logo'; //logo link\n";
$configData .= "\$ImgSize='$ImgSize'; //Megabytes\n";
$configData .= "\$imgQuality='$imgQuality'; //% of the original quality 70% = 70\n\n";
$configData .= "////////////////Messages///////////////////////////////////\n";
$configData .= "\$messageUpdate='$messageUpdate'; //chat refresh interval in miliseconds\n";
$configData .= "\$opacity = '$opacity'; //Color opacity\n\n";
$configData .= "////////////////////////////////////////////////////////////\n";
$configData .= "\$pdfIcon='$pdfIcon'; ////pdf icon size////\n\n";
$configData .= "////////////////////////////message font////////////////////////////////\n";
$configData .= "\$dateFont='
size=\"2\"
style=\"
padding: 0px;
\"';\n\n";
$configData .= "\$messageFont='
size=\"3\"
style=\"
padding: 8px;
\"';\n\n";
$configData .= "\$imgSize='$imgSizePercentage'; \n\n";
$configData .= "///////////////////Repository//////////////////////////////\n";
$configData .= "\$updatesUrl = '$updatesUrl';\n\n";
$configData .= "///////////////////////// encryption keys /////////////////////\n";
$configData .= "\$secretkey='$secretkey';\n";
$configData .= "\$iv='$iv';\n\n";
$configData .= "\$usernameCookieName='$usernameCookieName';\n\n";
$configData .= "/////////////////Error Reporting///////////////////////////\n\n";
$configData .= "\$error='$error';\n\n";
$configData .= "//hide errors\n";
$configData .= "if(\$error==0){\n";
$configData .= " error_reporting(0);\n";
$configData .= " ini_set('display_errors', 0);\n";
$configData .= "}\n\n";
$configData .= "//show errors\n";
$configData .= "if(\$error==1){\n";
$configData .= " error_reporting(E_ALL);\n";
$configData .= " ini_set('display_errors', 1);\n";
$configData .= "}\n";
file_put_contents($configFile, $configData);
echo "Configuration updated successfully.";
}
// Load existing values from the config file
include $configFile;
?>
<form method="post" action="config-edit.php">
<label for="accountLevel">Default Account Access Level:</label>
<select id="accountLevel" name="accountLevel">
<option value="suspended" <?php if ($accountLevel == 'suspended') echo 'selected'; ?>>Suspended</option>
<option value="limited" <?php if ($accountLevel == 'limited') echo 'selected'; ?>>Limited</option>
<option value="standard" <?php if ($accountLevel == 'standard') echo 'selected'; ?>>Standard</option>
<option value="advanced" <?php if ($accountLevel == 'advanced') echo 'selected'; ?>>Advanced</option>
<option value="admin" <?php if ($accountLevel == 'admin') echo 'selected'; ?>>Admin</option>
</select>
<label for="logo">Logo link:</label>
<input type="text" id="logo" name="logo" value="<?php echo $logo; ?>">
<label for="icon">Icon link:</label>
<input type="text" id="icon" name="icon" value="<?php echo $icon; ?>"> <a href="icon_generator.php" target="blank"> install icons</a><br>
<label for="ImgSize">Image Size (MB):</label>
<input type="text" id="ImgSize" name="ImgSize" value="<?php echo $ImgSize; ?>">
<label for="imgQuality">Image Quality (%):</label>
<input type="text" id="imgQuality" name="imgQuality" value="<?php echo $imgQuality; ?>">
<label for="messageUpdate">Message Update Interval (ms):</label>
<input type="text" id="messageUpdate" name="messageUpdate" value="<?php echo $messageUpdate; ?>">
<label for="opacity">Opacity:</label>
<input type="text" id="opacity" name="opacity" value="<?php echo $opacity; ?>">
<label for="pdfIcon">PDF Icon Size:</label>
<input type="text" id="pdfIcon" name="pdfIcon" value="<?php echo $pdfIcon; ?>">
<label for="dateFont">Date Font:</label>
<textarea id="dateFont" name="dateFont"><?php echo $dateFont; ?></textarea>
<label for="messageFont">Message Font:</label>
<textarea id="messageFont" name="messageFont"><?php echo $messageFont; ?></textarea>
<label for="imgSizePercentage">Image Preview Size (%):</label>
<input type="text" id="imgSizePercentage" name="imgSizePercentage" value="<?php echo $imgSize; ?>">
<label for="error">Error Reporting (0 or 1):</label>
<input type="text" id="error" name="error" value="<?php echo $error; ?>">
<label for="updatesUrl">Updates repository:</label>
<input type="text" id="updatesUrl" disabled value="<?php echo $updatesUrl; ?>">
<input type="submit" value="Save">
</form>
</div>
<form action="uninstall.php" method="get" onsubmit="return validateForm();">
<p> This action cannot be undone.</p>
<div class="confirmation">
<input type="checkbox" id="confirmCheckbox" name="confirm" value="yes">
<label for="confirmCheckbox">I confirm that I want to delete all files and folders.</label>
</div>
<input type="hidden" name="action" value="delete">
<button type="submit">Delete Everything</button>
</form>
<script>
function validateForm() {
var checkbox = document.getElementById('confirmCheckbox');
if (!checkbox.checked) {
alert('You must confirm the deletion by ticking the checkbox.');
return false;
}
return true;
}
</script>
</body>
</html>