feat: Implement SQLite backend and configuration UI
This commit is contained in:
44
config.php
Normal file
44
config.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
require_once 'database.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
foreach ($_POST as $name => $value) {
|
||||
$stmt = $db->prepare('UPDATE configuration SET value = ? WHERE name = ?');
|
||||
$stmt->execute([$value, $name]);
|
||||
}
|
||||
header('Location: config.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $db->query('SELECT * FROM configuration');
|
||||
$config = $stmt->fetchAll(PDO::FETCH_KEY_PAIR);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Configuration - Last Days of Rome</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="stylesheet" href="config.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Configuration</h1>
|
||||
<form method="POST">
|
||||
<?php foreach ($config as $name => $value): ?>
|
||||
<div class="form-group">
|
||||
<label for="<?= $name ?>"><?= ucwords(str_replace('_', ' ', $name)) ?></label>
|
||||
<?php if (strlen($value) > 80): ?>
|
||||
<textarea id="<?= $name ?>" name="<?= $name ?>"><?= htmlspecialchars($value) ?></textarea>
|
||||
<?php else: ?>
|
||||
<input type="text" id="<?= $name ?>" name="<?= $name ?>" value="<?= htmlspecialchars($value) ?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<button type="submit">Save Configuration</button>
|
||||
</form>
|
||||
<a href="index.php">Back to Game</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user