183 lines
8.0 KiB
PHP
183 lines
8.0 KiB
PHP
<?php
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
$recipe_id = $_GET['id'] ?? null;
|
|
|
|
if (!$recipe_id || !is_numeric($recipe_id)) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
$recipe = null;
|
|
$error_message = null;
|
|
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare('SELECT * FROM recipes WHERE id = ?');
|
|
$stmt->execute([$recipe_id]);
|
|
$recipe = $stmt->fetch();
|
|
|
|
if (!$recipe) {
|
|
http_response_code(404);
|
|
$error_message = "Recipe not found.";
|
|
}
|
|
} catch (PDOException $e) {
|
|
error_log('Database error: ' . $e->getMessage());
|
|
$error_message = 'We are currently experiencing technical difficulties. Please try again later.';
|
|
}
|
|
|
|
$project_image_url = $_SERVER['PROJECT_IMAGE_URL'] ?? 'https://via.placeholder.com/1200x630.png?text=rfresh';
|
|
$page_title = $recipe ? $recipe['title'] . ' - rfresh' : 'Recipe Not Found';
|
|
$page_description = $recipe ? htmlspecialchars($recipe['description']) : 'This recipe could not be found.';
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title><?php echo $page_title; ?></title>
|
|
<meta name="description" content="<?php echo $page_description; ?>">
|
|
|
|
<meta property="og:type" content="website">
|
|
<meta property="og:title" content="<?php echo $page_title; ?>">
|
|
<meta property="og:description" content="<?php echo $page_description; ?>">
|
|
<meta property="og:image" content="<?php echo $recipe ? htmlspecialchars($recipe['image_url']) : $project_image_url; ?>">
|
|
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
<meta name="twitter:title" content="<?php echo $page_title; ?>">
|
|
<meta name="twitter:description" content="<?php echo $page_description; ?>">
|
|
<meta name="twitter:image" content="<?php echo $recipe ? htmlspecialchars($recipe['image_url']) : $project_image_url; ?>">
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://fonts.googleapis.com/css2?family=Georgia&family=Helvetica+Neue&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
<style>
|
|
.recipe-header {
|
|
background-size: cover;
|
|
background-position: center;
|
|
color: white;
|
|
padding: 6rem 0;
|
|
text-shadow: 0 2px 10px rgba(0,0,0,0.5);
|
|
}
|
|
.recipe-content {
|
|
background: var(--card-bg-color);
|
|
margin-top: -4rem;
|
|
border-radius: 15px;
|
|
padding: 3rem;
|
|
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
|
|
}
|
|
.recipe-meta span {
|
|
margin-right: 1.5rem;
|
|
font-weight: 500;
|
|
}
|
|
.ingredients-list, .instructions-list {
|
|
padding-left: 1.2rem;
|
|
}
|
|
.ingredients-list li, .instructions-list li {
|
|
margin-bottom: 0.75rem;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm sticky-top">
|
|
<div class="container">
|
|
<a class="navbar-brand" href="/">rfresh</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav ms-auto align-items-center">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/#recipes">Our Menus</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/pricing.php">Pricing</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/login.php">Log In</a>
|
|
</li>
|
|
<li class="nav-item ms-lg-3">
|
|
<a class="btn btn-primary" href="/register.php">Sign Up</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<main>
|
|
<?php if ($error_message): ?>
|
|
<div class="container py-5 text-center">
|
|
<h1 class="display-4">Error</h1>
|
|
<p class="lead"><?php echo htmlspecialchars($error_message); ?></p>
|
|
<a href="/" class="btn btn-primary mt-3">Back to Homepage</a>
|
|
</div>
|
|
<?php else: ?>
|
|
<header class="recipe-header text-center" style="background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url(<?php echo htmlspecialchars($recipe['image_url']); ?>);">
|
|
<div class="container">
|
|
<h1 class="display-3"><?php echo htmlspecialchars($recipe['title']); ?></h1>
|
|
<p class="lead"><?php echo htmlspecialchars($recipe['description']); ?></p>
|
|
</div>
|
|
</header>
|
|
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-lg-10 mx-auto">
|
|
<div class="recipe-content">
|
|
<div class="recipe-meta text-center mb-4 pb-3 border-bottom">
|
|
<span class="badge bg-primary fs-6 me-3"><?php echo htmlspecialchars($recipe['difficulty']); ?></span>
|
|
<span class="text-muted">Prep Time: <?php echo htmlspecialchars($recipe['prep_time_minutes']); ?> minutes</span>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-5">
|
|
<h3 class="mb-3">Ingredients</h3>
|
|
<ul class="ingredients-list">
|
|
<?php
|
|
$ingredients = explode("\n", $recipe['ingredients']);
|
|
foreach ($ingredients as $ingredient) {
|
|
if (!empty(trim($ingredient))) {
|
|
echo '<li>' . htmlspecialchars(trim($ingredient)) . '</li>';
|
|
}
|
|
}
|
|
?>
|
|
</ul>
|
|
</div>
|
|
<div class="col-md-7">
|
|
<h3 class="mb-3">Instructions</h3>
|
|
<ol class="instructions-list">
|
|
<?php
|
|
$instructions = explode("\n", $recipe['instructions']);
|
|
foreach ($instructions as $instruction) {
|
|
if (!empty(trim($instruction))) {
|
|
echo '<li>' . htmlspecialchars(trim($instruction)) . '</li>';
|
|
}
|
|
}
|
|
?>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="text-center mt-5">
|
|
<a href="/" class="btn btn-outline-secondary">← Back to All Recipes</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</main>
|
|
|
|
<footer class="footer">
|
|
<div class="container text-center">
|
|
<p class="mb-1">© <?php echo date('Y'); ?> rfresh. All rights reserved.</p>
|
|
<p class="mb-0">Built with <a href="https://flatlogic.com" target="_blank" rel="noopener noreferrer">Flatlogic</a>.</p>
|
|
</div>
|
|
</footer>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
|
</body>
|
|
</html>
|