feat: Add detailed PHPDoc comments and improve code readability

This commit is contained in:
Keith Solomon
2025-08-15 18:12:19 -05:00
parent b9cb61750d
commit 17e925ec8e
3 changed files with 283 additions and 99 deletions

View File

@@ -1,4 +1,17 @@
<?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') {
@@ -6,13 +19,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$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>
@@ -22,17 +38,31 @@ $config = $stmt->fetchAll(PDO::FETCH_KEY_PAIR);
<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>
<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="<?= $name ?>" name="<?= $name ?>" value="<?= htmlspecialchars($value) ?>">
<input
type="text"
id="<?php echo $name ?>"
name="<?php echo $name ?>"
value="<?php echo htmlspecialchars($value) ?>"
>
<?php endif; ?>
</div>
<?php endforeach; ?>
@@ -41,4 +71,4 @@ $config = $stmt->fetchAll(PDO::FETCH_KEY_PAIR);
<a href="index.php">Back to Game</a>
</div>
</body>
</html>
</html>