fix
This commit is contained in:
192
user/catalog.php
Normal file
192
user/catalog.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/**
|
||||
* Catalogo Lezioni
|
||||
*
|
||||
* Mostra tutte le lezioni disponibili per l'acquisto
|
||||
*/
|
||||
|
||||
require_once '../includes/config.php';
|
||||
require_once '../includes/functions.php';
|
||||
|
||||
session_start();
|
||||
check_session_timeout();
|
||||
require_login();
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
|
||||
// Ottieni tutte le lezioni attive
|
||||
$all_lessons = get_all_lessons('all');
|
||||
|
||||
// Ottieni le lezioni già acquistate dall'utente
|
||||
$pdo = get_db_connection();
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT lesson_id FROM purchases
|
||||
WHERE user_id = ? AND status = 'completed'
|
||||
");
|
||||
$stmt->execute([$user_id]);
|
||||
$owned_lesson_ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Catalogo Lezioni - Pilates Platform</title>
|
||||
<link rel="stylesheet" href="../assets/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header class="header">
|
||||
<div class="container">
|
||||
<div class="header-content">
|
||||
<h1 class="logo">Pilates Studio</h1>
|
||||
<nav class="nav">
|
||||
<a href="../index.php" class="btn btn-outline">Home</a>
|
||||
<a href="dashboard.php" class="btn btn-secondary">Le Mie Lezioni</a>
|
||||
<a href="../includes/logout.php" class="btn btn-outline">Logout</a>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
<div class="dashboard">
|
||||
<!-- Sidebar con filtri -->
|
||||
<aside class="sidebar">
|
||||
<h3 style="margin-bottom: 1rem;">Filtri</h3>
|
||||
|
||||
<div style="margin-bottom: 1.5rem;">
|
||||
<label style="font-weight: 500; display: block; margin-bottom: 0.5rem;">Tipo</label>
|
||||
<label style="display: block; margin-bottom: 0.25rem;">
|
||||
<input type="checkbox" class="filter-type" value="video" checked> Videolezioni
|
||||
</label>
|
||||
<label style="display: block;">
|
||||
<input type="checkbox" class="filter-type" value="live" checked> Lezioni Live
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom: 1.5rem;">
|
||||
<label style="font-weight: 500; display: block; margin-bottom: 0.5rem;">Livello</label>
|
||||
<label style="display: block; margin-bottom: 0.25rem;">
|
||||
<input type="checkbox" class="filter-level" value="principiante" checked> Principiante
|
||||
</label>
|
||||
<label style="display: block; margin-bottom: 0.25rem;">
|
||||
<input type="checkbox" class="filter-level" value="intermedio" checked> Intermedio
|
||||
</label>
|
||||
<label style="display: block;">
|
||||
<input type="checkbox" class="filter-level" value="avanzato" checked> Avanzato
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button onclick="applyFilters()" class="btn btn-primary" style="width: 100%;">
|
||||
Applica Filtri
|
||||
</button>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="main-content">
|
||||
<h2 class="section-title" style="text-align: left;">Catalogo Lezioni</h2>
|
||||
|
||||
<?php echo display_flash_message(); ?>
|
||||
|
||||
<div class="lessons-grid" id="lessons-container">
|
||||
<?php foreach ($all_lessons as $lesson): ?>
|
||||
<?php
|
||||
$is_owned = in_array($lesson['id'], $owned_lesson_ids);
|
||||
$is_demo = $lesson['is_demo'];
|
||||
?>
|
||||
<div class="lesson-card"
|
||||
data-type="<?php echo $lesson['type']; ?>"
|
||||
data-level="<?php echo $lesson['level']; ?>">
|
||||
|
||||
<?php if ($lesson['thumbnail']): ?>
|
||||
<img src="<?php echo htmlspecialchars($lesson['thumbnail']); ?>"
|
||||
alt="<?php echo htmlspecialchars($lesson['title']); ?>"
|
||||
class="lesson-thumbnail">
|
||||
<?php else: ?>
|
||||
<div class="lesson-thumbnail-placeholder">
|
||||
<span><?php echo $lesson['type'] === 'video' ? '📹' : '📡'; ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="lesson-content">
|
||||
<h3 class="lesson-title"><?php echo htmlspecialchars($lesson['title']); ?></h3>
|
||||
<p class="lesson-description">
|
||||
<?php echo htmlspecialchars(substr($lesson['description'], 0, 100)) . '...'; ?>
|
||||
</p>
|
||||
|
||||
<div class="lesson-meta">
|
||||
<?php if ($lesson['duration']): ?>
|
||||
<span>⏱️ <?php echo $lesson['duration']; ?> min</span>
|
||||
<?php endif; ?>
|
||||
<span>📊 <?php echo ucfirst($lesson['level']); ?></span>
|
||||
</div>
|
||||
|
||||
<?php if ($lesson['type'] === 'live' && $lesson['live_date']): ?>
|
||||
<p class="text-muted" style="font-size: 0.875rem; margin: 0.5rem 0;">
|
||||
📅 <?php echo format_datetime($lesson['live_date']); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($is_demo): ?>
|
||||
<div class="lesson-price text-success">GRATIS</div>
|
||||
<a href="../lesson.php?id=<?php echo $lesson['id']; ?>" class="btn btn-success btn-small">
|
||||
Guarda Gratis
|
||||
</a>
|
||||
<?php elseif ($is_owned): ?>
|
||||
<div class="text-success" style="margin-bottom: 0.5rem;">✓ Già acquistata</div>
|
||||
<a href="../lesson.php?id=<?php echo $lesson['id']; ?>" class="btn btn-primary btn-small">
|
||||
Vai alla Lezione
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<div class="lesson-price"><?php echo format_price($lesson['price']); ?></div>
|
||||
<a href="../lesson.php?id=<?php echo $lesson['id']; ?>" class="btn btn-primary btn-small">
|
||||
Vedi Dettagli
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if (empty($all_lessons)): ?>
|
||||
<div class="card text-center">
|
||||
<p class="text-muted">Nessuna lezione disponibile al momento.</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Funzione per applicare i filtri
|
||||
function applyFilters() {
|
||||
// Ottieni i tipi selezionati
|
||||
const selectedTypes = Array.from(document.querySelectorAll('.filter-type:checked'))
|
||||
.map(cb => cb.value);
|
||||
|
||||
// Ottieni i livelli selezionati
|
||||
const selectedLevels = Array.from(document.querySelectorAll('.filter-level:checked'))
|
||||
.map(cb => cb.value);
|
||||
|
||||
// Filtra le lezioni
|
||||
const lessonCards = document.querySelectorAll('.lesson-card');
|
||||
|
||||
lessonCards.forEach(card => {
|
||||
const cardType = card.dataset.type;
|
||||
const cardLevel = card.dataset.level;
|
||||
|
||||
const typeMatch = selectedTypes.length === 0 || selectedTypes.includes(cardType);
|
||||
const levelMatch = selectedLevels.length === 0 || selectedLevels.includes(cardLevel);
|
||||
|
||||
if (typeMatch && levelMatch) {
|
||||
card.style.display = 'block';
|
||||
} else {
|
||||
card.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script src="../assets/js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
132
user/dashboard.php
Normal file
132
user/dashboard.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* Dashboard Utente
|
||||
*
|
||||
* Area personale dell'utente con le sue lezioni acquistate
|
||||
*/
|
||||
|
||||
require_once '../includes/config.php';
|
||||
require_once '../includes/functions.php';
|
||||
|
||||
session_start();
|
||||
check_session_timeout();
|
||||
require_login();
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
|
||||
// Ottieni le lezioni acquistate dall'utente
|
||||
$purchased_lessons = get_user_purchased_lessons($user_id);
|
||||
|
||||
// Ottieni info utente
|
||||
$user = get_user_by_id($user_id);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Le Mie Lezioni - Pilates Platform</title>
|
||||
<link rel="stylesheet" href="../assets/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header class="header">
|
||||
<div class="container">
|
||||
<div class="header-content">
|
||||
<h1 class="logo">Pilates Studio</h1>
|
||||
<nav class="nav">
|
||||
<a href="../index.php" class="btn btn-outline">Home</a>
|
||||
<a href="catalog.php" class="btn btn-secondary">Catalogo Lezioni</a>
|
||||
<a href="../includes/logout.php" class="btn btn-outline">Logout</a>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
<div class="dashboard">
|
||||
<!-- Sidebar -->
|
||||
<aside class="sidebar">
|
||||
<div style="text-align: center; margin-bottom: 1.5rem;">
|
||||
<div style="width: 80px; height: 80px; border-radius: 50%; background: var(--primary-light);
|
||||
margin: 0 auto 1rem; display: flex; align-items: center; justify-content: center;
|
||||
font-size: 2rem; color: white;">
|
||||
<?php echo strtoupper(substr($user['first_name'], 0, 1)); ?>
|
||||
</div>
|
||||
<strong><?php echo htmlspecialchars($user['first_name'] . ' ' . $user['last_name']); ?></strong>
|
||||
<p class="text-muted" style="font-size: 0.875rem; margin-top: 0.25rem;">
|
||||
<?php echo htmlspecialchars($user['email']); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<ul class="sidebar-menu">
|
||||
<li><a href="dashboard.php" class="active">📚 Le Mie Lezioni</a></li>
|
||||
<li><a href="catalog.php">🔍 Catalogo</a></li>
|
||||
<li><a href="profile.php">⚙️ Profilo</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="main-content">
|
||||
<h2 class="section-title" style="text-align: left;">Le Mie Lezioni</h2>
|
||||
|
||||
<?php echo display_flash_message(); ?>
|
||||
|
||||
<?php if (!empty($purchased_lessons)): ?>
|
||||
<div class="lessons-grid">
|
||||
<?php foreach ($purchased_lessons as $lesson): ?>
|
||||
<div class="lesson-card">
|
||||
<?php if ($lesson['thumbnail']): ?>
|
||||
<img src="<?php echo htmlspecialchars($lesson['thumbnail']); ?>"
|
||||
alt="<?php echo htmlspecialchars($lesson['title']); ?>"
|
||||
class="lesson-thumbnail">
|
||||
<?php else: ?>
|
||||
<div class="lesson-thumbnail-placeholder">
|
||||
<span><?php echo $lesson['type'] === 'video' ? '📹' : '📡'; ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="lesson-content">
|
||||
<h3 class="lesson-title"><?php echo htmlspecialchars($lesson['title']); ?></h3>
|
||||
<p class="lesson-description">
|
||||
<?php echo htmlspecialchars(substr($lesson['description'], 0, 100)) . '...'; ?>
|
||||
</p>
|
||||
|
||||
<div class="lesson-meta">
|
||||
<?php if ($lesson['duration']): ?>
|
||||
<span class="lesson-duration">⏱️ <?php echo $lesson['duration']; ?> min</span>
|
||||
<?php endif; ?>
|
||||
<span class="lesson-level">📊 <?php echo ucfirst($lesson['level']); ?></span>
|
||||
</div>
|
||||
|
||||
<?php if ($lesson['type'] === 'live'): ?>
|
||||
<p class="text-muted" style="font-size: 0.875rem; margin: 0.5rem 0;">
|
||||
📅 <?php echo format_datetime($lesson['live_date']); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<a href="../lesson.php?id=<?php echo $lesson['id']; ?>" class="btn btn-primary btn-small">
|
||||
<?php echo $lesson['type'] === 'video' ? 'Guarda' : 'Partecipa'; ?>
|
||||
</a>
|
||||
|
||||
<p class="text-muted" style="font-size: 0.75rem; margin-top: 0.5rem;">
|
||||
Acquistata il <?php echo format_date($lesson['purchased_at']); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="card text-center">
|
||||
<h3>Non hai ancora acquistato nessuna lezione</h3>
|
||||
<p class="text-muted mb-2">Esplora il nostro catalogo e inizia il tuo percorso di Pilates!</p>
|
||||
<a href="catalog.php" class="btn btn-primary">Sfoglia il Catalogo</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="../assets/js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
209
user/profile.php
Normal file
209
user/profile.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
/**
|
||||
* Profilo Utente
|
||||
*
|
||||
* Permette all'utente di visualizzare e modificare i propri dati
|
||||
*/
|
||||
|
||||
require_once '../includes/config.php';
|
||||
require_once '../includes/functions.php';
|
||||
|
||||
session_start();
|
||||
check_session_timeout();
|
||||
require_login();
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$user = get_user_by_id($user_id);
|
||||
|
||||
$error = '';
|
||||
$success = false;
|
||||
|
||||
// Processa aggiornamento profilo
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_profile'])) {
|
||||
$first_name = sanitize_input($_POST['first_name'] ?? '');
|
||||
$last_name = sanitize_input($_POST['last_name'] ?? '');
|
||||
$email = sanitize_input($_POST['email'] ?? '');
|
||||
$phone = sanitize_input($_POST['phone'] ?? '');
|
||||
|
||||
if (empty($first_name) || empty($last_name) || empty($email)) {
|
||||
$error = 'Nome, cognome ed email sono obbligatori';
|
||||
} elseif (!validate_email($email)) {
|
||||
$error = 'Email non valida';
|
||||
} else {
|
||||
// Verifica se l'email è già usata da un altro utente
|
||||
$pdo = get_db_connection();
|
||||
$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ? AND id != ?");
|
||||
$stmt->execute([$email, $user_id]);
|
||||
|
||||
if ($stmt->fetch()) {
|
||||
$error = 'Questa email è già in uso';
|
||||
} else {
|
||||
// Aggiorna profilo
|
||||
$stmt = $pdo->prepare("
|
||||
UPDATE users
|
||||
SET first_name = ?, last_name = ?, email = ?, phone = ?, updated_at = NOW()
|
||||
WHERE id = ?
|
||||
");
|
||||
|
||||
if ($stmt->execute([$first_name, $last_name, $email, $phone, $user_id])) {
|
||||
$success = true;
|
||||
$user = get_user_by_id($user_id); // Ricarica dati
|
||||
set_flash_message('success', 'Profilo aggiornato con successo!');
|
||||
} else {
|
||||
$error = 'Errore durante l\'aggiornamento';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Processa cambio password
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['change_password'])) {
|
||||
$current_password = $_POST['current_password'] ?? '';
|
||||
$new_password = $_POST['new_password'] ?? '';
|
||||
$confirm_password = $_POST['confirm_password'] ?? '';
|
||||
|
||||
if (empty($current_password) || empty($new_password)) {
|
||||
$error = 'Inserisci la password attuale e la nuova password';
|
||||
} elseif (!verify_password($current_password, $user['password'])) {
|
||||
$error = 'Password attuale non corretta';
|
||||
} elseif (strlen($new_password) < 6) {
|
||||
$error = 'La nuova password deve essere di almeno 6 caratteri';
|
||||
} elseif ($new_password !== $confirm_password) {
|
||||
$error = 'Le password non corrispondono';
|
||||
} else {
|
||||
$pdo = get_db_connection();
|
||||
$hashed_password = hash_password($new_password);
|
||||
|
||||
$stmt = $pdo->prepare("UPDATE users SET password = ?, updated_at = NOW() WHERE id = ?");
|
||||
|
||||
if ($stmt->execute([$hashed_password, $user_id])) {
|
||||
set_flash_message('success', 'Password cambiata con successo!');
|
||||
header('Location: profile.php');
|
||||
exit;
|
||||
} else {
|
||||
$error = 'Errore durante il cambio password';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Profilo - Pilates Platform</title>
|
||||
<link rel="stylesheet" href="../assets/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header class="header">
|
||||
<div class="container">
|
||||
<div class="header-content">
|
||||
<h1 class="logo">Pilates Studio</h1>
|
||||
<nav class="nav">
|
||||
<a href="../index.php" class="btn btn-outline">Home</a>
|
||||
<a href="dashboard.php" class="btn btn-secondary">Le Mie Lezioni</a>
|
||||
<a href="../includes/logout.php" class="btn btn-outline">Logout</a>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
<div class="dashboard">
|
||||
<!-- Sidebar -->
|
||||
<aside class="sidebar">
|
||||
<ul class="sidebar-menu">
|
||||
<li><a href="dashboard.php">📚 Le Mie Lezioni</a></li>
|
||||
<li><a href="catalog.php">🔍 Catalogo</a></li>
|
||||
<li><a href="profile.php" class="active">⚙️ Profilo</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="main-content">
|
||||
<h2 class="section-title" style="text-align: left;">Il Mio Profilo</h2>
|
||||
|
||||
<?php echo display_flash_message(); ?>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-error"><?php echo htmlspecialchars($error); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Form Dati Personali -->
|
||||
<div class="card">
|
||||
<h3 class="card-header">Dati Personali</h3>
|
||||
<form method="POST" action="">
|
||||
<div class="form-group">
|
||||
<label for="first_name" class="form-label">Nome</label>
|
||||
<input type="text" id="first_name" name="first_name" class="form-control"
|
||||
value="<?php echo htmlspecialchars($user['first_name']); ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="last_name" class="form-label">Cognome</label>
|
||||
<input type="text" id="last_name" name="last_name" class="form-control"
|
||||
value="<?php echo htmlspecialchars($user['last_name']); ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="email" class="form-label">Email</label>
|
||||
<input type="email" id="email" name="email" class="form-control"
|
||||
value="<?php echo htmlspecialchars($user['email']); ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="phone" class="form-label">Telefono (opzionale)</label>
|
||||
<input type="tel" id="phone" name="phone" class="form-control"
|
||||
value="<?php echo htmlspecialchars($user['phone'] ?? ''); ?>">
|
||||
</div>
|
||||
|
||||
<button type="submit" name="update_profile" class="btn btn-primary">
|
||||
Aggiorna Profilo
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Form Cambio Password -->
|
||||
<div class="card">
|
||||
<h3 class="card-header">Cambia Password</h3>
|
||||
<form method="POST" action="">
|
||||
<div class="form-group">
|
||||
<label for="current_password" class="form-label">Password Attuale</label>
|
||||
<input type="password" id="current_password" name="current_password"
|
||||
class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="new_password" class="form-label">Nuova Password</label>
|
||||
<input type="password" id="new_password" name="new_password"
|
||||
class="form-control" required minlength="6">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="confirm_password" class="form-label">Conferma Nuova Password</label>
|
||||
<input type="password" id="confirm_password" name="confirm_password"
|
||||
class="form-control" required minlength="6">
|
||||
</div>
|
||||
|
||||
<button type="submit" name="change_password" class="btn btn-primary">
|
||||
Cambia Password
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Info Account -->
|
||||
<div class="card">
|
||||
<h3 class="card-header">Informazioni Account</h3>
|
||||
<p><strong>Registrato il:</strong> <?php echo format_date($user['created_at']); ?></p>
|
||||
<?php if ($user['last_login']): ?>
|
||||
<p><strong>Ultimo accesso:</strong> <?php echo format_datetime($user['last_login']); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="../assets/js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user