-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
525 lines (459 loc) · 26 KB
/
profile.php
File metadata and controls
525 lines (459 loc) · 26 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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
<?php
/**
* file: profile.php
*
* User profile and data management page.
* Allows users to view their profile, export their data (backup), delete all their data (purge),
* and manage Two-Factor Authentication (2FA).
*/
require_once 'auth.php';
require_once 'config.php';
require_once 'language_loader.php';
require_once 'src/SecurityService.php';
if (!defined('STORAGE_PATH')) {
define('STORAGE_PATH', __DIR__ . '/storage');
}
$sec = new SecurityService($pdo, ENCRYPTION_KEY);
$user_id = $_SESSION['user_id'];
$message = '';
$messageType = '';
// Get user info (decrypt name/dob)
$stmt = $pdo->prepare("SELECT username, full_name, date_of_birth, totp_secret, totp_enabled FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch();
$user_full_name = $sec->decrypt($user['full_name']);
$user_dob = $sec->decrypt($user['date_of_birth']);
$username = $user['username'];
$totpEnabled = (bool)$user['totp_enabled'];
$currentSecret = $user['totp_secret'];
// Handle 2FA Setup
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['enable_totp']) || isset($_POST['verify_totp']) || isset($_POST['disable_totp'])) {
if (!$sec->validateCsrfToken($_POST['csrf_token'] ?? '')) {
$message = "Security check failed (CSRF). Please try again.";
$messageType = 'error';
} else {
if (isset($_POST['enable_totp'])) {
if (empty($currentSecret)) {
$newSecret = $sec->generateTotpSecret();
$pdo->prepare("UPDATE users SET totp_secret = ? WHERE id = ?")->execute([$newSecret, $user_id]);
$currentSecret = $newSecret;
$message = "Scan the code and verify below.";
$messageType = 'info';
}
} elseif (isset($_POST['verify_totp'])) {
$code = $_POST['totp_code'];
if ($sec->verifyTotp($currentSecret, $code)) {
$pdo->prepare("UPDATE users SET totp_enabled = 1 WHERE id = ?")->execute([$user_id]);
$totpEnabled = true;
$message = "Two-Factor Authentication Enabled!";
$messageType = 'success';
$sec->logAudit($user_id, '2FA_ENABLED', 'user', $user_id, 'Enabled 2FA');
} else {
$message = "Invalid Code.";
$messageType = 'error';
}
} elseif (isset($_POST['disable_totp'])) {
$pdo->prepare("UPDATE users SET totp_enabled = 0, totp_secret = NULL WHERE id = ?")->execute([$user_id]);
$totpEnabled = false;
$currentSecret = null;
$message = "2FA Disabled.";
$messageType = 'success';
$sec->logAudit($user_id, '2FA_DISABLED', 'user', $user_id, 'Disabled 2FA');
}
}
}
}
// Handle Purge Request
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['purge_data'])) {
if (!$sec->validateCsrfToken($_POST['csrf_token'] ?? '')) {
$message = "Security check failed (CSRF).";
$messageType = 'error';
} else {
try {
$pdo->beginTransaction();
// 1. Secure Delete: Remove physical files from Secure Media storage
$stmt_files = $pdo->prepare("SELECT storage_filename FROM user_files WHERE user_id = ?");
$stmt_files->execute([$user_id]);
$files = $stmt_files->fetchAll(PDO::FETCH_COLUMN);
foreach ($files as $filename) {
$path = STORAGE_PATH . '/' . $filename;
if (file_exists($path)) {
unlink($path);
}
}
// 2. Delete Public Files (Images, Docs, Audio)
// 2a. Images
$stmt_imgs = $pdo->prepare("SELECT bestandsnaam FROM BeeldGebeurtenissen WHERE user_id = ?");
$stmt_imgs->execute([$user_id]);
$imgs = $stmt_imgs->fetchAll(PDO::FETCH_COLUMN);
foreach ($imgs as $img) {
$path = 'uploads/' . $img;
if (file_exists($path)) unlink($path);
}
// 2b. Audio
$stmt_audio = $pdo->prepare("SELECT bestand_pad FROM audio_files WHERE user_id = ?");
$stmt_audio->execute([$user_id]);
$audios = $stmt_audio->fetchAll(PDO::FETCH_COLUMN);
foreach ($audios as $audio) {
if (file_exists($audio)) unlink($audio);
}
// 2c. Documents
$stmt_docs = $pdo->prepare("
SELECT d.bestand_pad
FROM documenten d
JOIN gebeurtenissen g ON g.document_id = d.id
WHERE g.user_id = ?
");
$stmt_docs->execute([$user_id]);
$docs = $stmt_docs->fetchAll(PDO::FETCH_COLUMN);
foreach ($docs as $doc) {
if (file_exists($doc)) unlink($doc);
}
// 3. Delete DB records
$pdo->prepare("DELETE FROM BeeldGebeurtenissen WHERE user_id = ?")->execute([$user_id]);
$pdo->prepare("DELETE FROM audio_files WHERE user_id = ?")->execute([$user_id]);
$pdo->prepare("
DELETE d FROM documenten d
JOIN gebeurtenissen g ON g.document_id = d.id
WHERE g.user_id = ?
")->execute([$user_id]);
$pdo->prepare("DELETE FROM verbanden WHERE user_id = ?")->execute([$user_id]);
$pdo->prepare("DELETE FROM gebeurtenissen WHERE user_id = ?")->execute([$user_id]);
$pdo->prepare("DELETE FROM urls WHERE user_id = ?")->execute([$user_id]);
$pdo->commit();
$message = $lang['profile_purge_success'];
$messageType = 'success';
$sec->logAudit($user_id, 'PURGE_DATA', 'user', $user_id, 'User purged all data');
} catch (Exception $e) {
$pdo->rollBack();
$message = sprintf($lang['profile_purge_error'], $e->getMessage());
$messageType = 'error';
}
}
}
// Handle Import Request
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['import_data'])) {
if (!$sec->validateCsrfToken($_POST['csrf_token'] ?? '')) {
$message = "Security check failed (CSRF).";
$messageType = 'error';
} else {
if (isset($_FILES['import_file']) && $_FILES['import_file']['error'] === UPLOAD_ERR_OK) {
$file_tmp_path = $_FILES['import_file']['tmp_name'];
$zip = new ZipArchive;
if ($zip->open($file_tmp_path) === TRUE) {
$gebeurtenissen_csv = $zip->getFromName('gebeurtenissen.csv');
$verbanden_csv = $zip->getFromName('verbanden.csv');
if ($gebeurtenissen_csv !== false && $verbanden_csv !== false) {
try {
$pdo->beginTransaction();
$export_id_to_db_id = [];
// Process Gebeurtenissen
$stream = fopen('php://memory', 'r+');
fwrite($stream, $gebeurtenissen_csv);
rewind($stream);
$header = fgetcsv($stream, 0, ",", "\"", "\\");
if ($header) {
$stmt_insert_g = $pdo->prepare("INSERT INTO gebeurtenissen (user_id, datum, titel, score, details) VALUES (?, ?, ?, ?, ?)");
while (($row = fgetcsv($stream, 0, ",", "\"", "\\")) !== FALSE) {
$data = array_combine($header, $row);
// Encrypt imported data
$encTitel = $sec->encrypt($data['titel']);
$encDetails = $sec->encrypt($data['details']);
$stmt_insert_g->execute([$user_id, $data['datum'], $encTitel, $data['score'], $encDetails]);
$new_db_id = $pdo->lastInsertId();
$export_id_to_db_id[$data['export_id']] = $new_db_id;
}
}
fclose($stream);
// Process Verbanden
$stream = fopen('php://memory', 'r+');
fwrite($stream, $verbanden_csv);
rewind($stream);
$header = fgetcsv($stream, 0, ",", "\"", "\\");
if ($header) {
$stmt_insert_v = $pdo->prepare("INSERT INTO verbanden (user_id, gebeurtenis_id_begin, gebeurtenis_id_eind, link_desc) VALUES (?, ?, ?, ?)");
while (($row = fgetcsv($stream, 0, ",", "\"", "\\")) !== FALSE) {
$data = array_combine($header, $row);
$begin_db_id = $export_id_to_db_id[$data['begin_export_id']] ?? null;
$end_db_id = $export_id_to_db_id[$data['end_export_id']] ?? null;
// Encrypt Link Desc
$encLinkDesc = $sec->encrypt($data['link_desc']);
if ($begin_db_id && $end_db_id) {
$stmt_insert_v->execute([$user_id, $begin_db_id, $end_db_id, $encLinkDesc]);
}
}
}
fclose($stream);
$pdo->commit();
$message = $lang['profile_import_success'];
$messageType = 'success';
$sec->logAudit($user_id, 'IMPORT_DATA', 'user', $user_id, 'User imported data via ZIP');
} catch (Exception $e) {
$pdo->rollBack();
$message = sprintf($lang['profile_import_error'], $e->getMessage());
$messageType = 'error';
}
} else {
$message = $lang['profile_import_invalid_zip'];
$messageType = 'error';
}
$zip->close();
} else {
$message = $lang['profile_import_zip_open_error'];
$messageType = 'error';
}
} else {
$message = $lang['profile_import_upload_error'];
$messageType = 'error';
}
}
}
// Check if the user has any data
$stmt_check_data = $pdo->prepare("SELECT COUNT(*) FROM gebeurtenissen WHERE user_id = ?");
$stmt_check_data->execute([$user_id]);
$has_data = $stmt_check_data->fetchColumn() > 0;
$csrfToken = $sec->generateCsrfToken();
// Bunq Handling
require_once 'src/BunqService.php';
$bunqMessage = '';
$bunqMessageType = '';
// Check current status
$stmtBunq = $pdo->prepare("SELECT encrypted_api_key, environment FROM bunq_user_settings WHERE user_id = ?");
$stmtBunq->execute([$user_id]);
$bunqSettings = $stmtBunq->fetch(PDO::FETCH_ASSOC);
$bunqConfigured = false;
$maskedKey = '';
if ($bunqSettings) {
$apiKey = $sec->decrypt($bunqSettings['encrypted_api_key']);
if ($apiKey) {
$bunqConfigured = true;
$len = strlen($apiKey);
if ($len > 6) {
$maskedKey = substr($apiKey, 0, 3) . str_repeat('*', $len - 6) . substr($apiKey, -3);
} else {
$maskedKey = '******';
}
}
}
// Handle Bunq Form Submission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && (isset($_POST['save_bunq']) || isset($_POST['forget_bunq']))) {
if (!$sec->validateCsrfToken($_POST['csrf_token'] ?? '')) {
$bunqMessage = "Security check failed (CSRF).";
$bunqMessageType = 'error';
} else {
if (isset($_POST['save_bunq'])) {
$newKey = trim($_POST['bunq_api_key']);
$env = $_POST['bunq_env'];
if (!empty($newKey)) {
try {
// 1. Encrypt and Save temporarily to test
$encKey = $sec->encrypt($newKey);
// Upsert into DB
$stmtUpsert = $pdo->prepare("
INSERT INTO bunq_user_settings (user_id, encrypted_api_key, environment)
VALUES (?, ?, ?)
ON DUPLICATE KEY UPDATE encrypted_api_key = VALUES(encrypted_api_key), environment = VALUES(environment)
");
$stmtUpsert->execute([$user_id, $encKey, $env]);
// 2. Try to initialize BunqService to verify key
// This will trigger setupContext -> automaticInstall
$bunqService = new BunqService($user_id, $pdo, $sec);
$bunqMessage = $lang['bunq_profile_success'];
$bunqMessageType = 'success';
$bunqConfigured = true;
// Update masked key
$len = strlen($newKey);
$maskedKey = substr($newKey, 0, 3) . str_repeat('*', $len - 6) . substr($newKey, -3);
// Update settings for display
$bunqSettings = ['environment' => $env];
$sec->logAudit($user_id, 'BUNQ_SETUP', 'bunq_user_settings', $user_id, 'Bunq API Configured');
} catch (Exception $e) {
$bunqMessage = "Error verifying Bunq API Key: " . $e->getMessage();
$bunqMessageType = 'error';
// Optional: Delete the invalid key? Or let user retry?
// Let's leave it so they can fix it, but state remains invalid technically if they leave.
}
} else {
$bunqMessage = "API Key cannot be empty.";
$bunqMessageType = 'error';
}
} elseif (isset($_POST['forget_bunq'])) {
// Delete context file
$bunqService = new BunqService($user_id, $pdo, $sec);
$bunqService->deleteContext();
// Remove from DB
$pdo->prepare("DELETE FROM bunq_user_settings WHERE user_id = ?")->execute([$user_id]);
$bunqConfigured = false;
$maskedKey = '';
$bunqMessage = $lang['bunq_profile_removed'];
$bunqMessageType = 'success';
$sec->logAudit($user_id, 'BUNQ_REMOVED', 'bunq_user_settings', $user_id, 'Bunq API Removed');
}
}
}
?>
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo sprintf($lang['page_title_profile'], htmlspecialchars($user_full_name)); ?></title>
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="manifest" href="site.webmanifest">
<link rel="stylesheet" href="style.css">
<style>
.profile-container { max-width: 800px; margin: 2rem auto; }
.danger-zone { border: 2px solid #D8000C; padding: 1rem; border-radius: 5px; margin-top: 2rem; }
.danger-zone h3 { color: #D8000C; }
.danger-btn { background-color: #D8000C; color: white; }
.info-row { margin-bottom: 10px; }
.label { font-weight: bold; width: 150px; display: inline-block; }
.secret-key { font-family: monospace; background: #eee; padding: 5px; font-size: 1.2em; display: inline-block; margin: 10px 0; }
</style>
</head>
<body>
<?php include 'header.inc.php'; ?>
<div class="w-full max-w-[1600px] mx-auto px-4 mt-8">
<div class="bg-white shadow-xl rounded-xl p-8 profile-container">
<h2><?php echo sprintf($lang['page_title_profile'], htmlspecialchars($user_full_name)); ?></h2>
<p><?php echo $lang['profile_welcome']; ?></p>
<?php if ($message): ?>
<div class="message <?php echo $messageType; ?>"><?php echo htmlspecialchars($message); ?></div>
<?php endif; ?>
<div class="mt-6 border-b pb-6">
<h3><?php echo $lang['footer_language']; ?></h3>
<div class="language-switcher" style="justify-content: flex-start;">
<form action="" method="GET">
<input type="radio" id="lang_dutch" name="lang" value="dutch" onchange="this.form.submit()" <?php echo (isset($_SESSION['lang']) && $_SESSION['lang'] === 'dutch') ? 'checked' : ''; ?>>
<label for="lang_dutch"><img src="languages/flags/dutch.png" alt="Dutch Flag"></label>
<input type="radio" id="lang_english" name="lang" value="english" onchange="this.form.submit()" <?php echo (isset($_SESSION['lang']) && $_SESSION['lang'] === 'english') ? 'checked' : ''; ?>>
<label for="lang_english"><img src="languages/flags/english.png" alt="English Flag"></label>
<input type="radio" id="lang_german" name="lang" value="german" onchange="this.form.submit()" <?php echo (isset($_SESSION['lang']) && $_SESSION['lang'] === 'german') ? 'checked' : ''; ?>>
<label for="lang_german"><img src="languages/flags/german.png" alt="German Flag"></label>
<input type="radio" id="lang_spanish" name="lang" value="spanish" onchange="this.form.submit()" <?php echo (isset($_SESSION['lang']) && $_SESSION['lang'] === 'spanish') ? 'checked' : ''; ?>>
<label for="lang_spanish"><img src="languages/flags/spanish.png" alt="Spanish Flag"></label>
<input type="radio" id="lang_french" name="lang" value="french" onchange="this.form.submit()" <?php echo (isset($_SESSION['lang']) && $_SESSION['lang'] === 'french') ? 'checked' : ''; ?>>
<label for="lang_french"><img src="languages/flags/french.png" alt="French Flag"></label>
</form>
</div>
</div>
<div class="mt-6 border-b pb-6">
<h3>Personal Information</h3>
<div class="info-row"><span class="label">Username:</span> <?php echo htmlspecialchars($username); ?></div>
<div class="info-row"><span class="label">Full Name:</span> <?php echo htmlspecialchars($user_full_name); ?></div>
<div class="info-row"><span class="label">Date of Birth:</span> <?php echo htmlspecialchars($user_dob); ?></div>
</div>
<div class="mt-6 border-b pb-6">
<h3><?php echo $lang['bunq_profile_heading']; ?></h3>
<?php if ($bunqMessage): ?>
<div class="message <?php echo $bunqMessageType; ?>" style="margin-bottom: 1rem;"><?php echo htmlspecialchars($bunqMessage); ?></div>
<?php endif; ?>
<?php if ($bunqConfigured): ?>
<div class="info-row">
<span class="label"><?php echo $lang['bunq_profile_status_label']; ?></span> <span style="color: green; font-weight: bold;"><?php echo $lang['bunq_profile_status_connected']; ?></span>
</div>
<div class="info-row">
<span class="label"><?php echo $lang['bunq_profile_env_label']; ?></span> <?php echo htmlspecialchars($bunqSettings['environment']); ?>
</div>
<div class="info-row">
<span class="label"><?php echo $lang['bunq_profile_apikey_label']; ?></span>
<span style="font-family: monospace;"><?php echo htmlspecialchars($maskedKey); ?></span>
</div>
<form method="POST" style="margin-top: 10px;">
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
<button type="submit" name="forget_bunq" class="action-btn danger-btn" onclick="return confirm('Weet u zeker dat u de Bunq koppeling wilt verwijderen?');"><?php echo $lang['bunq_profile_button_forget']; ?></button>
</form>
<?php else: ?>
<p><?php echo $lang['bunq_profile_intro']; ?></p>
<form method="POST" style="margin-top: 15px;">
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
<div style="margin-bottom: 10px;">
<label for="bunq_env" class="label"><?php echo $lang['bunq_profile_env_label']; ?></label>
<select name="bunq_env" id="bunq_env" style="padding: 5px; border-radius: 4px; border: 1px solid #ccc;">
<option value="SANDBOX">Sandbox (Test)</option>
<option value="PRODUCTION">Production</option>
</select>
</div>
<div style="margin-bottom: 10px;">
<label for="bunq_api_key" class="label"><?php echo $lang['bunq_profile_apikey_label']; ?></label>
<input type="password" name="bunq_api_key" id="bunq_api_key" required style="width: 100%; max-width: 400px; padding: 5px; border: 1px solid #ccc; border-radius: 4px;">
</div>
<button type="submit" name="save_bunq" class="action-btn"><?php echo $lang['bunq_profile_button_save']; ?></button>
</form>
<?php endif; ?>
</div>
<div class="mt-6 border-b pb-6">
<h3>Security Settings</h3>
<div class="info-row">
<span class="label">2-Factor Auth:</span>
<?php if ($totpEnabled): ?>
<span style="color: green; font-weight: bold;">ENABLED</span>
<form method="POST" style="margin-top: 10px; display: inline-block;">
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
<button type="submit" name="disable_totp" class="action-btn cancel-btn text-sm" onclick="return confirm('Disable 2FA?');">Disable</button>
</form>
<?php else: ?>
<span style="color: red;">DISABLED</span>
<?php if ($currentSecret): ?>
<div class="bg-gray-50 p-4 border rounded mt-2">
<p>1. Enter this Secret Key into your Authenticator App:</p>
<p class="secret-key"><?php echo $currentSecret; ?></p>
<p>2. Enter the 6-digit code below:</p>
<form method="POST" class="mt-2 flex gap-2">
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
<input type="text" name="totp_code" placeholder="123456" required class="border p-2 rounded w-32">
<button type="submit" name="verify_totp" class="action-btn">Verify & Enable</button>
</form>
</div>
<?php else: ?>
<form method="POST" style="margin-top: 10px; display: inline-block;">
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
<button type="submit" name="enable_totp" class="action-btn">Setup 2FA</button>
</form>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
<div class="data-management" style="margin-top: 2rem;">
<h3><?php echo $lang['profile_data_management']; ?></h3>
<div class="export-section" style="margin-bottom: 2rem;">
<h4><?php echo $lang['profile_export_heading']; ?></h4>
<p><?php echo $lang['profile_export_text']; ?></p>
<a href="export.php" class="action-btn"><?php echo $lang['profile_export_button']; ?></a>
</div>
<?php if ($has_data): ?>
<!-- Purge Section -->
<div class="danger-zone">
<h3><?php echo $lang['profile_danger_zone_heading']; ?></h3>
<p><?php echo $lang['profile_purge_text']; ?></p>
<form method="POST" action="profile.php" onsubmit="return confirm('WAARSCHUWING: Dit zal al uw gegevens permanent verwijderen, inclusief geüploade bestanden en media. Dit kan NIET ongedaan worden gemaakt. Heeft u een export gemaakt? Weet u het zeker?');">
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
<input type="hidden" name="purge_data" value="1">
<button type="submit" class="action-btn danger-btn"><?php echo $lang['profile_purge_button']; ?></button>
</form>
</div>
<?php else: ?>
<!-- Import Section -->
<div class="import-section">
<h4><?php echo $lang['profile_import_heading']; ?></h4>
<p><?php echo $lang['profile_import_text']; ?></p>
<form method="POST" action="profile.php" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
<div class="input-group">
<label for="import_file"><?php echo $lang['profile_import_label']; ?></label>
<input type="file" id="import_file" name="import_file" accept=".zip" required>
</div>
<button type="submit" name="import_data" class="action-btn"><?php echo $lang['profile_import_button']; ?></button>
</form>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php include 'footer.inc.php'; ?>
<script src="script.js"></script>
</body>
</html>