Add add_language.php
This commit is contained in:
@@ -0,0 +1,87 @@
|
|||||||
|
<?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>
|
||||||
|
<link rel="stylesheet"
|
||||||
|
href="assets/css/style.css">
|
||||||
|
</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>
|
||||||
Reference in New Issue
Block a user