v 25-10-30

This commit is contained in:
Flatlogic Bot 2025-10-30 15:35:40 +00:00
parent 44636e8e76
commit 3d23e3f6ab
5 changed files with 181 additions and 145 deletions

20
assets/css/custom.css Normal file
View File

@ -0,0 +1,20 @@
/* custom.css */
body {
background-color: #f8f9fa;
}
.navbar {
margin-bottom: 2rem;
}
.card-header {
background-color: #28a745;
color: white;
}
.toast-container {
position: fixed;
top: 1rem;
right: 1rem;
z-index: 1055;
}

9
assets/js/main.js Normal file
View File

@ -0,0 +1,9 @@
// main.js
document.addEventListener('DOMContentLoaded', function () {
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('success')) {
const toastEl = document.getElementById('successToast');
const toast = new bootstrap.Toast(toastEl);
toast.show();
}
});

View File

@ -8,10 +8,31 @@ define('DB_PASS', '9eb17a13-4a89-4e11-8517-0c201096e935');
function db() { function db() {
static $pdo; static $pdo;
if (!$pdo) { if (!$pdo) {
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [ try {
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, $pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]); PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
} catch (PDOException $e) {
// If the database doesn't exist, you might want to handle that here
// For now, we'll just re-throw the exception.
throw $e;
}
} }
return $pdo; return $pdo;
} }
function run_migrations() {
$pdo = db();
$migrations_dir = __DIR__ . '/migrations';
if (!is_dir($migrations_dir)) {
return;
}
$files = glob($migrations_dir . '/*.sql');
foreach ($files as $file) {
$sql = file_get_contents($file);
if ($sql) {
$pdo->exec($sql);
}
}
}

View File

@ -0,0 +1,8 @@
-- 001_create_results_table.sql
CREATE TABLE IF NOT EXISTS results (
id INT AUTO_INCREMENT PRIMARY KEY,
shooter_id INT NOT NULL,
result_text VARCHAR(255) NOT NULL,
comments TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

260
index.php
View File

@ -1,150 +1,128 @@
<?php <?php
declare(strict_types=1); require_once 'db/config.php';
@ini_set('display_errors', '1');
@error_reporting(E_ALL); // Run migrations to ensure the table exists
@date_default_timezone_set('UTC'); run_migrations();
$pdo = db();
$shooter_id = 1; // Simulate logged-in shooter
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['result_text'])) {
$result_text = trim($_POST['result_text']);
$comments = trim($_POST['comments']);
if (!empty($result_text)) {
$stmt = $pdo->prepare("INSERT INTO results (shooter_id, result_text, comments) VALUES (?, ?, ?)");
$stmt->execute([$shooter_id, $result_text, $comments]);
// Redirect to avoid form resubmission, with a success flag
header("Location: index.php?success=1");
exit;
}
}
// Fetch existing results for the shooter
$stmt = $pdo->prepare("SELECT * FROM results WHERE shooter_id = ? ORDER BY created_at DESC");
$stmt->execute([$shooter_id]);
$results = $stmt->fetchAll();
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
?> ?>
<!doctype html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New Style</title> <title>skyderesultater</title>
<?php <meta name="description" content="A simple application for shooters to enter and track their results.">
// Read project preview data from environment <meta name="keywords" content="shooting, results, scoring, training, shooter, instructor, skyderesultater, Built with Flatlogic Generator">
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? ''; <meta property="og:title" content="skyderesultater">
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; <meta property="og:description" content="A simple application for shooters to enter and track their results.">
?> <meta property="og:image" content="">
<?php if ($projectDescription): ?> <meta name="twitter:card" content="summary_large_image">
<!-- Meta description --> <meta name="twitter:image" content="">
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<!-- Twitter meta tags --> <link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<!-- Open Graph image -->
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<!-- Twitter image -->
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% { background-position: 0% 0%; }
100% { background-position: 100% 100%; }
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}
.loader {
margin: 1.25rem auto 1.25rem;
width: 48px;
height: 48px;
border: 3px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.hint {
opacity: 0.9;
}
.sr-only {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap; border: 0;
}
h1 {
font-size: 3rem;
font-weight: 700;
margin: 0 0 1rem;
letter-spacing: -1px;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
}
code {
background: rgba(0,0,0,0.2);
padding: 2px 6px;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
footer {
position: absolute;
bottom: 1rem;
font-size: 0.8rem;
opacity: 0.7;
}
</style>
</head> </head>
<body> <body>
<main>
<div class="card"> <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<h1>Analyzing your requirements and generating your website…</h1> <div class="container">
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes"> <a class="navbar-brand" href="#">
<span class="sr-only">Loading…</span> <i class="bi bi-bullseye"></i> skyderesultater
</div> </a>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p> </div>
<p class="hint">This page will update automatically as the plan is implemented.</p> </nav>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
<div class="container">
<div class="row">
<div class="col-md-8 offset-md-2">
<!-- Add Result Form -->
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">Add New Result</h5>
</div>
<div class="card-body">
<form action="index.php" method="POST">
<div class="mb-3">
<label for="result_text" class="form-label">Result / Score</label>
<input type="text" class="form-control" id="result_text" name="result_text" required>
</div>
<div class="mb-3">
<label for="comments" class="form-label">Comments</label>
<textarea class="form-control" id="comments" name="comments" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-success">
<i class="bi bi-check-circle"></i> Save Result
</button>
</form>
</div>
</div>
<!-- Results List -->
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0">Your Past Results</h5>
</div>
<div class="card-body">
<?php if (empty($results)): ?>
<p class="text-center text-muted">You have not entered any results yet.</p>
<?php else: ?>
<ul class="list-group list-group-flush">
<?php foreach ($results as $result): ?>
<li class="list-group-item">
<div class="d-flex w-100 justify-content-between">
<h6 class="mb-1"><?php echo htmlspecialchars($result['result_text']); ?></h6>
<small class="text-muted"><?php echo date("M j, Y, g:i a", strtotime($result['created_at'])); ?></small>
</div>
<p class="mb-1"><?php echo nl2br(htmlspecialchars($result['comments'])); ?></p>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div> </div>
</main>
<footer> <!-- Success Toast -->
Page updated: <?= htmlspecialchars($now) ?> (UTC) <div class="toast-container">
</footer> <div id="successToast" class="toast align-items-center text-white bg-success border-0" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">
<i class="bi bi-check-circle-fill"></i> Result saved successfully!
</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body> </body>
</html> </html>