75 lines
2.2 KiB
PHP
75 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* Config file for the Last Days of Rome.
|
|
*
|
|
* PHP version: 8.0+
|
|
*
|
|
* @category Configuration
|
|
* @package Rome
|
|
* @author Keith Solomon <keith@keithsolmon.net>
|
|
* @license MIT License
|
|
* @version GIT: $Id$
|
|
* @link https://git.keithsolomon.net/keith/Warframe_Shopping_List
|
|
*/
|
|
|
|
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 name, value 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="<?php echo $name ?>">
|
|
<?php echo ucwords(str_replace('_', ' ', $name)) ?>
|
|
</label>
|
|
<?php if (strlen($value) > 80) : ?>
|
|
<textarea
|
|
id="<?php echo $name ?>"
|
|
name="<?php echo $name ?>"
|
|
>
|
|
<?php echo htmlspecialchars($value) ?>
|
|
</textarea>
|
|
<?php else: ?>
|
|
<input
|
|
type="text"
|
|
id="<?php echo $name ?>"
|
|
name="<?php echo $name ?>"
|
|
value="<?php echo 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>
|