Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6a3594b03 | ||
|
|
f493f5764a |
131
admin_edit_exercise.php
Normal file
131
admin_edit_exercise.php
Normal 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
171
admin_exercises.php
Normal 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
136
assets/css/custom.css
Normal 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
17
assets/js/main.js
Normal 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);
|
||||||
|
});
|
||||||
|
});
|
||||||
9
db/migrations/001_create_exercises_table.sql
Normal file
9
db/migrations/001_create_exercises_table.sql
Normal 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
|
||||||
|
);
|
||||||
127
generator.php
Normal file
127
generator.php
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>AI Workout Generator</title>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<header class="main-header">
|
||||||
|
<h1>AI Workout Generator</h1>
|
||||||
|
<p>Fill out the form below to get a personalized workout plan.</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<form action="generator.php" method="POST">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="goal">Fitness Goal</label>
|
||||||
|
<select id="goal" name="goal" class="form-control">
|
||||||
|
<option value="build_muscle">Build Muscle</option>
|
||||||
|
<option value="lose_weight">Lose Weight</option>
|
||||||
|
<option value="improve_endurance">Improve Endurance</option>
|
||||||
|
<option value="general_fitness">General Fitness</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="level">Fitness Level</label>
|
||||||
|
<select id="level" name="level" class="form-control">
|
||||||
|
<option value="beginner">Beginner</option>
|
||||||
|
<option value="intermediate">Intermediate</option>
|
||||||
|
<option value="advanced">Advanced</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="duration">Workout Duration (minutes)</label>
|
||||||
|
<select id="duration" name="duration" class="form-control">
|
||||||
|
<option value="30">30 minutes</option>
|
||||||
|
<option value="45">45 minutes</option>
|
||||||
|
<option value="60">60 minutes</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Available Equipment</label>
|
||||||
|
<div class="checkbox-group">
|
||||||
|
<label><input type="checkbox" name="equipment[]" value="none" checked> None (Bodyweight)</label>
|
||||||
|
<label><input type="checkbox" name="equipment[]" value="dumbbells"> Dumbbells</label>
|
||||||
|
<label><input type="checkbox" name="equipment[]" value="barbell"> Barbell</label>
|
||||||
|
<label><input type="checkbox" name="equipment[]" value="kettlebells"> Kettlebells</label>
|
||||||
|
<label><input type="checkbox" name="equipment[]" value="resistance_bands"> Resistance Bands</label>
|
||||||
|
<label><input type="checkbox" name="equipment[]" value="full_gym"> Full Gym Access</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary">Generate Workout</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="workout-result">
|
||||||
|
<?php
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
require_once __DIR__ . '/ai/LocalAIApi.php';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$goal = $_POST['goal'] ?? 'general_fitness';
|
||||||
|
$level = $_POST['level'] ?? 'beginner';
|
||||||
|
$duration = $_POST['duration'] ?? '30';
|
||||||
|
$equipment = isset($_POST['equipment']) ? implode(', ', $_POST['equipment']) : 'none';
|
||||||
|
|
||||||
|
$system_prompt = "You are an expert fitness coach. Your task is to create a personalized workout plan based on the user's goals, fitness level, and available equipment. Respond with a JSON object. The JSON object should have a single key 'workout' which is an array of sections. Each section object should have 'title' (e.g., 'Warm-up', 'Main Workout', 'Cool-down') and 'exercises' which is an array of exercise objects. Each exercise object should have 'name', 'sets', 'reps' (e.g., '3 sets of 10-12 reps' or '60 seconds'), and 'video_url' which is a URL to a YouTube video demonstrating the exercise.";
|
||||||
|
|
||||||
|
$user_prompt = "Please generate a workout plan for me based on the following details:\n- Fitness Goal: {$goal}\n- Fitness Level: {$level}\n- Workout Duration: {$duration} minutes\n- Available Equipment: {$equipment}";
|
||||||
|
|
||||||
|
echo '<div class="card"><div class="card-header"><h2>Your Personalized Workout Plan</h2></div><div class="card-body"><p>Generating your workout, please wait...</p></div></div>';
|
||||||
|
|
||||||
|
$resp = LocalAIApi::createResponse(
|
||||||
|
[
|
||||||
|
'input' => [
|
||||||
|
['role' => 'system', 'content' => $system_prompt],
|
||||||
|
['role' => 'user', 'content' => $user_prompt],
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!empty($resp['success'])) {
|
||||||
|
$text = LocalAIApi::extractText($resp);
|
||||||
|
$workout_data = json_decode($text, true);
|
||||||
|
|
||||||
|
if ($workout_data && isset($workout_data['workout'])) {
|
||||||
|
echo '<div class="card animated fadeIn">';
|
||||||
|
foreach ($workout_data['workout'] as $section) {
|
||||||
|
echo '<div class="workout-section">';
|
||||||
|
echo '<h3>' . htmlspecialchars($section['title']) . '</h3>';
|
||||||
|
echo '<ul class="exercise-list">';
|
||||||
|
foreach ($section['exercises'] as $exercise) {
|
||||||
|
echo '<li>';
|
||||||
|
echo '<strong>' . htmlspecialchars($exercise['name']) . '</strong>';
|
||||||
|
echo '<span>' . htmlspecialchars($exercise['sets']) . ' of ' . htmlspecialchars($exercise['reps']) . '</span>';
|
||||||
|
if (!empty($exercise['video_url'])) {
|
||||||
|
echo '<a href="' . htmlspecialchars($exercise['video_url']) . '" target="_blank">Watch Video</a>';
|
||||||
|
}
|
||||||
|
echo '</li>';
|
||||||
|
}
|
||||||
|
echo '</ul>';
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
echo '</div>';
|
||||||
|
} else {
|
||||||
|
echo '<div class="card"><div class="card-body"><p>Error: The AI returned an invalid workout structure. Here is the raw response:</p><pre>' . htmlspecialchars($text) . '</pre></div></div>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo '<div class="card"><div class="card-body"><p>Error generating workout. Details: ' . htmlspecialchars($resp['error'] ?? 'Unknown error') . '</p></div></div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/js/main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
255
index.php
255
index.php
@ -1,150 +1,121 @@
|
|||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
// --- Static Data Simulation ---
|
||||||
@ini_set('display_errors', '1');
|
// In a real app, this would come from a database.
|
||||||
@error_reporting(E_ALL);
|
$workout_plan = [
|
||||||
@date_default_timezone_set('UTC');
|
'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;
|
function render_exercise_card($exercise) {
|
||||||
$now = date('Y-m-d H:i:s');
|
$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">
|
<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><?php echo htmlspecialchars($workout_plan['title']); ?> - Fitness App</title>
|
||||||
<?php
|
|
||||||
// Read project preview data from environment
|
<!-- SEO Meta Tags -->
|
||||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
<meta name="description" content="Engage in a full-body workout designed for general fitness. Follow structured plans with video guides for every exercise.">
|
||||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
<meta name="keywords" content="fitness, workout, exercise, health, gym, home workout">
|
||||||
?>
|
<meta name="author" content="FitApp">
|
||||||
<?php if ($projectDescription): ?>
|
|
||||||
<!-- Meta description -->
|
<!-- Bootstrap 5 CDN -->
|
||||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<!-- Open Graph meta tags -->
|
|
||||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<!-- Font Awesome for Icons -->
|
||||||
<!-- Twitter meta tags -->
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
||||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
|
||||||
<?php endif; ?>
|
<!-- Google Fonts -->
|
||||||
<?php if ($projectImageUrl): ?>
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<!-- Open Graph image -->
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
|
||||||
<!-- Twitter image -->
|
|
||||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
<!-- Custom CSS -->
|
||||||
<?php endif; ?>
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
<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 class="bg-light">
|
||||||
<main>
|
|
||||||
<div class="card">
|
<div class="container-fluid workout-container py-5">
|
||||||
<h1>Analyzing your requirements and generating your website…</h1>
|
<header class="text-center mb-5">
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
<h1 class="display-5 fw-bold"><?php echo htmlspecialchars($workout_plan['title']); ?></h1>
|
||||||
<span class="sr-only">Loading…</span>
|
<p class="lead text-muted">Estimated Duration: <?php echo htmlspecialchars($workout_plan['total_time']); ?></p>
|
||||||
</div>
|
<div class="progress mt-3 mx-auto" style="max-width: 500px; height: 10px;">
|
||||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
<div class="progress-bar" role="progressbar" style="width: 10%;" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
</div>
|
||||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
</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>
|
</div>
|
||||||
</main>
|
|
||||||
<footer>
|
<!-- Bootstrap JS Bundle -->
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
</footer>
|
<!-- Custom JS -->
|
||||||
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user