34334-vm/home.php
Flatlogic Bot d5d05fd44f 03
2025-09-24 06:37:02 +00:00

85 lines
3.4 KiB
PHP

<?php
// Initialize the session
session_start();
// Check if the user is logged in, if not then redirect him to login page
if (!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true) {
header("location: index.php");
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home - AI Resume Builder</title>
<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;500;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body class="dark-theme">
<div class="page-wrapper">
<!-- Sidebar -->
<aside class="sidebar">
<div class="sidebar-header">
<h2>AI Resume Builder</h2>
</div>
<nav class="sidebar-nav">
<a href="home.php" class="active">Home</a>
<a href="create.php">Create</a>
<a href="#" id="logout-btn-sidebar">Sign Out</a>
</nav>
</aside>
<!-- Main Content -->
<main class="main-content">
<div class="page-header">
<h1>Choose Your Template</h1>
<p>Select a template to start building your professional resume.</p>
</div>
<div id="template-grid" class="template-grid">
<!-- Templates will be loaded here by JavaScript -->
</div>
</main>
</div>
<script src="https://www.gstatic.com/firebasejs/9.6.1/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.6.1/firebase-auth-compat.js"></script>
<script src="assets/js/auth.js?v=<?php echo time(); ?>"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const grid = document.getElementById('template-grid');
fetch('api/pexels.php')
.then(response => response.json())
.then(images => {
if (!images || images.error) {
grid.innerHTML = `<p style="color: #ff4d4d;">Error loading templates: ${images ? images.error : 'Unknown error'}</p>`;
return;
}
let html = '';
images.forEach(image => {
const templateURL = `create.php?template=${encodeURIComponent(image.local_url)}`;
html += `
<a href="${templateURL}" class="template-card">
<img src="${image.local_url}" alt="${image.alt || 'Resume Template'}">
<div class="template-overlay">
<span class="btn-select">Select</span>
</div>
</a>
`;
});
grid.innerHTML = html;
})
.catch(error => {
console.error('Failed to fetch templates:', error);
grid.innerHTML = '<p style="color: #ffcc00;">Could not load templates. Please try again later.</p>';
});
});
</script>
</body>
</html>