Files
woordjes/add_language.php
2026-06-16 11:23:25 +02:00

95 lines
1.7 KiB
PHP

<?php
require_once 'includes/config.php';
require_once 'includes/auth.php';
require_once 'includes/functions.php';
require_once 'includes/jsondb.php';
requireLogin();
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$language =
sanitize($_POST['language']);
if (!$language) {
$error = 'Taal ontbreekt';
} else {
$path =
languagePath(
$_SESSION['user'],
$language
);
if (!is_dir($path)) {
mkdir(
$path . '/lists',
0775,
true
);
JsonDB::write(
$path . '/metadata.json',
[
'name' => $language,
'created' => date('c')
]
);
}
header('Location: dashboard.php');
exit;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Taal toevoegen</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#222">
<link rel="manifest" href="/manifest.json">
<link rel="stylesheet" href="/assets/css/style.css">
<link rel="apple-touch-icon" sizes="180x180" href="/assets/img/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/img/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/img/favicon-16x16.png">
</head>
<body>
<div class="container">
<div class="card">
<h1>Taal toevoegen</h1>
<form method="post">
<input
name="language"
placeholder="Bijv. Engels"
required>
<button>
Opslaan
</button>
</form>
<p><?= $error ?></p>
</div>
</div>
</body>
</html>