( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
/**
* Main entry point for Looksy
*/
// Include configuration
require_once 'config/config.php';
require_once 'config/ai_config.php';
// Autoload classes
spl_autoload_register(function($className) {
$classFile = 'includes/classes/' . $className . '.php';
if (file_exists($classFile)) {
require_once $classFile;
}
});
// Initialize user
$user = new User();
$currentUser = $user->getCurrentUser();
// Get requested page
$page = isset($_GET['page']) ? $_GET['page'] : 'home';
// Define allowed pages
$allowedPages = [
'home', 'login', 'register', 'forgot_password', 'reset_password', 'dashboard', 'products',
'models', 'backgrounds', 'generate', 'virtual_dress', 'profile', 'logout',
'gallery', 'add_product', 'edit_product', 'ad_generator', 'brand_profile', 'onboarding'
];
// Validate page
if (!in_array($page, $allowedPages)) {
$page = 'home';
}
// Check authentication for protected pages
$protectedPages = [
'dashboard', 'products', 'models', 'backgrounds',
'generate', 'virtual_dress', 'profile', 'gallery', 'add_product', 'edit_product', 'ad_generator', 'brand_profile', 'onboarding'
];
if (in_array($page, $protectedPages) && !$user->isLoggedIn()) {
header('Location: index.php?page=login');
exit;
}
// Handle logout
if ($page === 'logout' && $user->isLoggedIn()) {
$user->logout();
header('Location: index.php');
exit;
}
// Enforce onboarding (brand profile required) for specific pages
// Redirect to brand_profile if missing
if ($user->isLoggedIn()) {
$requireBrandProfilePages = ['dashboard', 'products', 'virtual_dress', 'generate', 'ad_generator'];
if (in_array($page, $requireBrandProfilePages)) {
require_once 'includes/classes/BrandProfile.php';
// Initialize database and brand profile class
$database = Database::getInstance();
$conn = $database->getConnection();
$brandProfile = new BrandProfile($conn);
$userProfile = $brandProfile->getByUserId($_SESSION['user_id']);
$onboardingCompleted = $brandProfile->hasCompletedOnboarding($_SESSION['user_id']);
// If no brand profile or onboarding incomplete, redirect to onboarding page
if (!$userProfile['success'] || !$onboardingCompleted) {
header('Location: index.php?page=onboarding');
exit;
}
}
}
// Include header
include 'templates/header.php';
// Include page content
include 'templates/' . $page . '.php';
// Include footer
include 'templates/footer.php';