36776-vm/ritual.php
Flatlogic Bot 3be446013d Initialv1
2025-12-09 00:59:40 +00:00

150 lines
6.7 KiB
PHP

<?php session_start(); ?>
<?php
require_once 'db/config.php';
// Sanitize theme input
$theme = filter_input(INPUT_GET, 'theme', FILTER_SANITIZE_STRING);
if (empty($theme)) {
$theme = 'gratitude'; // Default theme
}
$level = 'beginner'; // Hardcoded for now, will be dynamic later
$affirmation_text = 'Your default affirmation text goes here. You are capable of amazing things.';
try {
$pdo = db();
// Fetch a random affirmation for the given theme and level
$stmt = $pdo->prepare(
"SELECT affirmation_text FROM affirmations WHERE theme = :theme AND level = :level ORDER BY RAND() LIMIT 1"
);
$stmt->execute(['theme' => $theme, 'level' => $level]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
if ($result && !empty($result['affirmation_text'])) {
$affirmation_text = $result['affirmation_text'];
}
} catch (PDOException $e) {
// Log the error instead of displaying it to the user
error_log("Database error in ritual.php: " . $e->getMessage());
// The page will proceed with the default affirmation text
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sacred Habits - Ritual</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
</head>
<body>
<?php $projectName = $_SERVER['PROJECT_NAME'] ?? 'Sacred Habits'; ?>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="index.php"><?php echo htmlspecialchars($projectName); ?></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">
<?php if (isset($_SESSION['user_id'])): ?>
<li class="nav-item">
<span class="navbar-text me-3">Welcome, <?php echo htmlspecialchars($_SESSION['user_name']); ?>!</span>
</li>
<li class="nav-item">
<a class="nav-link" href="progress.php">Progress</a>
</li>
<li class="nav-item">
<a class="nav-link" href="pricing.php">Subscribe</a>
</li>
<li class="nav-item">
<a class="nav-link" href="logout.php">Logout</a>
</li>
<?php else: ?>
<li class="nav-item">
<a class="nav-link" href="login.php">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="register.php">Register</a>
</li>
<?php endif; ?>
</ul>
</div>
</div>
</nav>
<div class="container my-5">
<div class="progress-bar-container mb-4">
<div class="progress-bar-fill"></div>
</div>
<!-- Step 0: Intro -->
<div class="ritual-step active text-center">
<h1 class="mb-3">Your 90-Second Ritual</h1>
<p class="lead text-muted mb-4">A moment for yourself, inspired by the theme of <strong><?php echo htmlspecialchars(ucfirst($theme)); ?></strong>.</p>
<button id="begin-ritual" class="btn btn-primary btn-lg">Begin Ritual</button>
</div>
<!-- Step 1: Release -->
<div class="ritual-step text-center">
<i data-feather="x-circle" class="mb-3" style="width: 48px; height: 48px; color: #EC4899;"></i>
<h2 class="mb-3">Release</h2>
<p class="lead">Let go of what no longer serves you. Take a deep breath out.</p>
<div id="timer" class="timer text-primary">01:30</div>
<button class="btn btn-secondary next-step mt-4">Next</button>
</div>
<!-- Step 2: Receive -->
<div class="ritual-step text-center">
<i data-feather="arrow-down-circle" class="mb-3" style="width: 48px; height: 48px; color: #6366F1;"></i>
<h2 class="mb-3">Receive</h2>
<p class="lead">Open yourself to new energy and possibility. Breathe in deeply.</p>
<button class="btn btn-primary next-step mt-4">Next</button>
</div>
<!-- Step 3: Practice -->
<div class="ritual-step text-center">
<i data-feather="heart" class="mb-3" style="width: 48px; height: 48px; color: #EC4899;"></i>
<h2 class="mb-3">Practice</h2>
<p class="lead">Repeat the affirmation, feeling its truth resonate within you.</p>
<blockquote class="blockquote fs-4 my-4">"<?php echo htmlspecialchars($affirmation_text); ?>"</blockquote>
<button class="btn btn-secondary next-step mt-4">Next</button>
</div>
<!-- Step 4: Breathe -->
<div class="ritual-step text-center">
<i data-feather="wind" class="mb-3" style="width: 48px; height: 48px; color: #6366F1;"></i>
<h2 class="mb-3">Breathe</h2>
<p class="lead">Integrate the practice with your breath. Inhale peace, exhale gratitude.</p>
<button class="btn btn-primary next-step mt-4">Next</button>
</div>
<!-- Step 5: Affirm -->
<div class="ritual-step text-center">
<i data-feather="check-circle" class="mb-3" style="width: 48px; height: 48px; color: #10B981;"></i>
<h2 class="mb-3">Affirm</h2>
<p class="lead">Lock in the feeling with one final repetition.</p>
<blockquote class="blockquote fs-4 my-4 text-primary">"<?php echo htmlspecialchars($affirmation_text); ?>"</blockquote>
<button class="btn btn-secondary next-step mt-4">Complete</button>
</div>
<!-- Step 6: Celebration -->
<div class="ritual-step text-center">
<h1 class="display-3 text-primary">✨ Ritual Complete! ✨</h1>
<p class="lead">You have honored your commitment to yourself.</p>
<a href="index.php" class="btn btn-primary mt-4">Back to Themes</a>
</div>
</div>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
<script>
feather.replace();
</script>
</body>
</html>