Fitness guide

This commit is contained in:
Flatlogic Bot 2025-12-15 02:05:58 +00:00
parent 5c4168df8d
commit f493f5764a
6 changed files with 577 additions and 142 deletions

131
admin_edit_exercise.php Normal file
View File

@ -0,0 +1,131 @@
<?php
require_once 'db/config.php';
$id = $_GET['id'] ?? null;
if (!$id) {
header("Location: admin_exercises.php");
exit;
}
// Handle form submission for updating an exercise
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_exercise'])) {
$name = $_POST['name'];
$description = $_POST['description'];
$video_url = $_POST['video_url'];
$muscle_group = $_POST['muscle_group'];
if (!empty($name)) {
$stmt = db()->prepare("UPDATE exercises SET name = ?, description = ?, video_url = ?, muscle_group = ? WHERE id = ?");
$stmt->execute([$name, $description, $video_url, $muscle_group, $id]);
}
header("Location: admin_exercises.php");
exit;
}
// Fetch the exercise
$stmt = db()->prepare("SELECT * FROM exercises WHERE id = ?");
$stmt->execute([$id]);
$exercise = $stmt->fetch();
if (!$exercise) {
header("Location: admin_exercises.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Exercise</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
<style>
body {
font-family: 'Inter', sans-serif;
background-color: #f8fafc;
color: #0f172a;
}
.container {
max-width: 1024px;
margin: 0 auto;
padding: 2rem;
}
h1 {
font-size: 2.25rem;
font-weight: 700;
margin-bottom: 2rem;
}
.card {
background-color: #ffffff;
border-radius: 0.5rem;
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
padding: 2rem;
}
.form-group {
margin-bottom: 1.5rem;
}
.form-group label {
display: block;
font-weight: 500;
margin-bottom: 0.5rem;
}
.form-group input,
.form-group textarea {
width: 100%;
padding: 0.75rem;
border: 1px solid #e2e8f0;
border-radius: 0.375rem;
}
.btn {
background-color: #14b8a6;
color: #ffffff;
padding: 0.75rem 1.5rem;
border: none;
border-radius: 0.375rem;
font-weight: 600;
cursor: pointer;
transition: background-color 0.3s;
}
.btn:hover {
background-color: #0d9488;
}
.btn-secondary {
background-color: #f1f5f9;
color: #0f172a;
margin-left: 1rem;
}
.btn-secondary:hover {
background-color: #e2e8f0;
}
</style>
</head>
<body>
<div class="container">
<h1>Edit Exercise</h1>
<div class="card">
<form action="admin_edit_exercise.php?id=<?php echo $exercise['id']; ?>" method="POST">
<div class="form-group">
<label for="name">Exercise Name</label>
<input type="text" id="name" name="name" value="<?php echo htmlspecialchars($exercise['name']); ?>" required>
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea id="description" name="description" rows="4"><?php echo htmlspecialchars($exercise['description']); ?></textarea>
</div>
<div class="form-group">
<label for="video_url">Video URL</label>
<input type="text" id="video_url" name="video_url" value="<?php echo htmlspecialchars($exercise['video_url']); ?>">
</div>
<div class="form-group">
<label for="muscle_group">Muscle Group</label>
<input type="text" id="muscle_group" name="muscle_group" value="<?php echo htmlspecialchars($exercise['muscle_group']); ?>">
</div>
<button type="submit" name="update_exercise" class="btn">Update Exercise</button>
<a href="admin_exercises.php" class="btn btn-secondary">Cancel</a>
</form>
</div>
</div>
</body>
</html>

171
admin_exercises.php Normal file
View File

@ -0,0 +1,171 @@
<?php
require_once 'db/config.php';
// Handle form submission for creating a new exercise
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['create_exercise'])) {
$name = $_POST['name'];
$description = $_POST['description'];
$video_url = $_POST['video_url'];
$muscle_group = $_POST['muscle_group'];
if (!empty($name)) {
$stmt = db()->prepare("INSERT INTO exercises (name, description, video_url, muscle_group) VALUES (?, ?, ?, ?)");
$stmt->execute([$name, $description, $video_url, $muscle_group]);
}
header("Location: admin_exercises.php");
exit;
}
// Handle deletion of an exercise
if (isset($_GET['delete'])) {
$id = $_GET['delete'];
$stmt = db()->prepare("DELETE FROM exercises WHERE id = ?");
$stmt->execute([$id]);
header("Location: admin_exercises.php");
exit;
}
// Fetch all exercises
$stmt = db()->query("SELECT * FROM exercises ORDER BY created_at DESC");
$exercises = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exercise Management</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
<style>
body {
font-family: 'Inter', sans-serif;
background-color: #f8fafc;
color: #0f172a;
}
.container {
max-width: 1024px;
margin: 0 auto;
padding: 2rem;
}
h1 {
font-size: 2.25rem;
font-weight: 700;
margin-bottom: 2rem;
}
.card {
background-color: #ffffff;
border-radius: 0.5rem;
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
padding: 2rem;
margin-bottom: 2rem;
}
.form-group {
margin-bottom: 1.5rem;
}
.form-group label {
display: block;
font-weight: 500;
margin-bottom: 0.5rem;
}
.form-group input,
.form-group textarea {
width: 100%;
padding: 0.75rem;
border: 1px solid #e2e8f0;
border-radius: 0.375rem;
}
.btn {
background-color: #14b8a6;
color: #ffffff;
padding: 0.75rem 1.5rem;
border: none;
border-radius: 0.375rem;
font-weight: 600;
cursor: pointer;
transition: background-color 0.3s;
}
.btn:hover {
background-color: #0d9488;
}
.table-container {
overflow-x: auto;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 1rem;
text-align: left;
border-bottom: 1px solid #e2e8f0;
}
th {
background-color: #f1f5f9;
}
.actions a {
color: #f97316;
text-decoration: none;
margin-right: 1rem;
}
.actions a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h1>Exercise Management</h1>
<div class="card">
<h2>Add New Exercise</h2>
<form action="admin_exercises.php" method="POST">
<div class="form-group">
<label for="name">Exercise Name</label>
<input type="text" id="name" name="name" required>
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea id="description" name="description" rows="4"></textarea>
</div>
<div class="form-group">
<label for="video_url">Video URL</label>
<input type="text" id="video_url" name="video_url">
</div>
<div class="form-group">
<label for="muscle_group">Muscle Group</label>
<input type="text" id="muscle_group" name="muscle_group">
</div>
<button type="submit" name="create_exercise" class="btn">Add Exercise</button>
</form>
</div>
<div class="card">
<h2>Exercise Library</h2>
<div class="table-container">
<table>
<thead>
<tr>
<th>Name</th>
<th>Muscle Group</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($exercises as $exercise): ?>
<tr>
<td><?php echo htmlspecialchars($exercise['name']); ?></td>
<td><?php echo htmlspecialchars($exercise['muscle_group']); ?></td>
<td class="actions">
<a href="admin_edit_exercise.php?id=<?php echo $exercise['id']; ?>">Edit</a>
<a href="admin_exercises.php?delete=<?php echo $exercise['id']; ?>" onclick="return confirm('Are you sure you want to delete this exercise?');">Delete</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>

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

@ -0,0 +1,136 @@
/*
Palette & Fonts:
--primary: #14b8a6; (Teal)
--secondary: #f97316; (Orange)
--background: #f8fafc; (Light Gray)
--surface: #ffffff; (White)
--text-color: #0f172a; (Dark Slate)
--font-family: 'Inter', sans-serif;
*/
:root {
--primary: #14b8a6;
--secondary: #f97316;
--info: #3b82f6;
--background: #f8fafc;
--surface: #ffffff;
--text-color: #0f172a;
--border-color: #e2e8f0;
--border-radius: 0.5rem;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background-color: var(--background);
color: var(--text-color);
}
.workout-container {
max-width: 1200px;
margin: 0 auto;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 700;
}
.section-title {
border-left: 4px solid var(--primary);
color: var(--text-color);
}
.progress-bar {
background-color: var(--primary);
}
.exercise-card {
border-radius: var(--border-radius);
transition: transform 0.3s ease, box-shadow 0.3s ease;
overflow: hidden; /* Ensures video placeholder respects border radius */
}
.exercise-card:hover {
transform: translateY(-5px);
box-shadow: 0 1rem 1.5rem rgba(0,0,0,0.1) !important;
}
.video-placeholder {
height: 180px;
background-size: cover;
background-position: center;
position: relative;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
.video-placeholder .play-icon {
color: white;
font-size: 3rem;
background-color: rgba(0,0,0,0.4);
border-radius: 50%;
width: 80px;
height: 80px;
display: flex;
align-items: center;
justify-content: center;
transition: transform 0.2s ease, background-color 0.2s ease;
backdrop-filter: blur(4px);
}
.exercise-card:hover .play-icon {
transform: scale(1.1);
background-color: rgba(20, 184, 166, 0.7);
}
.card-title {
font-weight: 600;
color: var(--text-color);
}
/* Soft Badge Styles */
.badge.bg-primary-soft {
background-color: rgba(20, 184, 166, 0.1);
color: #0d9488;
}
.badge.bg-secondary-soft {
background-color: rgba(249, 115, 22, 0.1);
color: #d97706;
}
.badge.bg-info-soft {
background-color: rgba(59, 130, 246, 0.1);
color: #2563eb;
}
.btn-primary {
background: linear-gradient(45deg, var(--primary), #2dd4bf);
border: none;
padding: 0.75rem 1.5rem;
font-weight: 600;
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 0.5rem 1rem rgba(20, 184, 166, 0.3) !important;
}
/* Animation */
.exercise-card-wrapper {
animation: fadeInUp 0.5s ease-out forwards;
opacity: 0;
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}

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

@ -0,0 +1,17 @@
document.addEventListener('DOMContentLoaded', function () {
const cards = document.querySelectorAll('.exercise-card-wrapper');
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry, index) => {
if (entry.isIntersecting) {
// Apply a staggered delay for the animation
entry.target.style.animationDelay = `${index * 100}ms`;
observer.unobserve(entry.target);
}
});
}, { threshold: 0.1 });
cards.forEach(card => {
observer.observe(card);
});
});

View File

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS exercises (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
video_url VARCHAR(255),
muscle_group VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

255
index.php
View File

@ -1,150 +1,121 @@
<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');
// --- Static Data Simulation ---
// In a real app, this would come from a database.
$workout_plan = [
'title' => 'General Fitness - Week 1, Day 1',
'total_time' => '45-60 min',
'sections' => [
[
'title' => 'Warm-up',
'duration' => '5-10 min',
'exercises' => [
['name' => 'Jumping Jacks', 'reps' => '30 seconds', 'sets' => 2, 'video_id' => '1047269'],
['name' => 'Arm Circles', 'reps' => '15 each way', 'sets' => 1, 'video_id' => '1047274'],
['name' => 'Leg Swings', 'reps' => '15 each leg', 'sets' => 1, 'video_id' => '1047279'],
]
],
[
'title' => 'Main Workout',
'duration' => '30-40 min',
'exercises' => [
['name' => 'Bodyweight Squats', 'reps' => '15', 'sets' => 3, 'rest' => '60s', 'video_id' => '4721626'],
['name' => 'Push-ups (or Knee Push-ups)', 'reps' => '10-12', 'sets' => 3, 'rest' => '60s', 'video_id' => '4721630'],
['name' => 'Plank', 'reps' => '30-60 seconds', 'sets' => 3, 'rest' => '60s', 'video_id' => '7030386'],
['name' => 'Glute Bridges', 'reps' => '15', 'sets' => 3, 'rest' => '60s', 'video_id' => '7030390'],
['name' => 'Dumbbell Rows (if available)', 'reps' => '12 each arm', 'sets' => 3, 'rest' => '60s', 'video_id' => '7030395'],
]
],
[
'title' => 'Cool-down',
'duration' => '5-10 min',
'exercises' => [
['name' => 'Quad Stretch', 'reps' => '30s each leg', 'sets' => 1, 'video_id' => '4761019'],
['name' => 'Hamstring Stretch', 'reps' => '30s each leg', 'sets' => 1, 'video_id' => '4761025'],
['name' => 'Chest Stretch', 'reps' => '30 seconds', 'sets' => 1, 'video_id' => '4761031'],
]
]
]
];
$phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
function render_exercise_card($exercise) {
$video_url = "https://images.pexels.com/videos/" . $exercise['video_id'] . "/pexels-photo-" . $exercise['video_id'] . ".jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500";
echo '<div class="exercise-card-wrapper col-lg-4 col-md-6 col-sm-12 mb-4">';
echo '<div class="exercise-card card h-100 shadow-sm border-0">';
echo '<div class="video-placeholder card-img-top" style="background-image: url('' . $video_url . '');">';
echo '<div class="play-icon"><i class="fas fa-play"></i></div>';
echo '</div>';
echo '<div class="card-body">';
echo '<h5 class="card-title">' . htmlspecialchars($exercise['name']) . '</h5>';
echo '<div class="details">';
echo '<span class="badge bg-primary-soft text-primary me-2">' . htmlspecialchars($exercise['reps']) . '</span>';
echo '<span class="badge bg-secondary-soft text-secondary">' . htmlspecialchars($exercise['sets']) . ' Sets</span>';
if (isset($exercise['rest'])) {
echo '<span class="badge bg-info-soft text-info ms-2">' . htmlspecialchars($exercise['rest']) . ' Rest</span>';
}
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
}
?>
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title>
<?php
// Read project preview data from environment
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
?>
<?php if ($projectDescription): ?>
<!-- Meta description -->
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<!-- Open Graph meta tags -->
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<!-- Twitter meta tags -->
<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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo htmlspecialchars($workout_plan['title']); ?> - Fitness App</title>
<!-- SEO Meta Tags -->
<meta name="description" content="Engage in a full-body workout designed for general fitness. Follow structured plans with video guides for every exercise.">
<meta name="keywords" content="fitness, workout, exercise, health, gym, home workout">
<meta name="author" content="FitApp">
<!-- Bootstrap 5 CDN -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome for Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<!-- Google Fonts -->
<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;600;700&display=swap" rel="stylesheet">
<!-- Custom CSS -->
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<main>
<div class="card">
<h1>Analyzing your requirements and generating your website…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
</div>
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will update automatically as the plan is implemented.</p>
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
<body class="bg-light">
<div class="container-fluid workout-container py-5">
<header class="text-center mb-5">
<h1 class="display-5 fw-bold"><?php echo htmlspecialchars($workout_plan['title']); ?></h1>
<p class="lead text-muted">Estimated Duration: <?php echo htmlspecialchars($workout_plan['total_time']); ?></p>
<div class="progress mt-3 mx-auto" style="max-width: 500px; height: 10px;">
<div class="progress-bar" role="progressbar" style="width: 10%;" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</header>
<?php foreach ($workout_plan['sections'] as $section): ?>
<section class="workout-section mb-5">
<h2 class="section-title h3 mb-4 ps-3"><?php echo htmlspecialchars($section['title']); ?> <small class="text-muted fw-normal">(<?php echo htmlspecialchars($section['duration']); ?>)</small></h2>
<div class="row">
<?php foreach ($section['exercises'] as $exercise): ?>
<?php render_exercise_card($exercise); ?>
<?php endforeach; ?>
</div>
</section>
<?php endforeach; ?>
<footer class="text-center mt-5">
<button class="btn btn-primary btn-lg shadow-lg">
<i class="fas fa-check-circle me-2"></i> Mark Workout as Complete
</button>
</footer>
</div>
</main>
<footer>
Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer>
<!-- Bootstrap JS Bundle -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<!-- Custom JS -->
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>
</html>