<?php
session_start();
require_once 'db_config.php';
// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
$pdo = getDB();
// Get user information
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch();
// Get user's projects
$projects_stmt = $pdo->prepare("SELECT * FROM projects WHERE user_id = ? ORDER BY created_date DESC");
$projects_stmt->execute([$_SESSION['user_id']]);
$projects = $projects_stmt->fetchAll();
// Handle logout
if (isset($_GET['logout'])) {
session_destroy();
header('Location: login.php');
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Dashboard - Game Development Platform</title>
<style>
body { font-family: Arial; margin: 0; background: #f5f7fa; }
.header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 20px 0; }
.header-content { max-width: 1200px; margin: 0 auto; padding: 0 20px; display: flex; justify-content: space-between; align-items: center; }
.user-info { display: flex; align-items: center; gap: 20px; }
.plan-badge { background: rgba(255,255,255,0.2); padding: 5px 15px; border-radius: 20px; font-size: 12px; text-transform: uppercase; }
.container { max-width: 1200px; margin: 0 auto; padding: 30px 20px; }
.welcome-section { background: white; padding: 30px; border-radius: 10px; margin-bottom: 30px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: white; padding: 25px; border-radius: 10px; text-align: center; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.stat-number { font-size: 32px; font-weight: bold; color: #667eea; margin-bottom: 5px; }
.stat-label { color: #666; font-size: 14px; }
.section { background: white; padding: 30px; border-radius: 10px; margin-bottom: 30px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.section h2 { margin-top: 0; color: #333; }
.btn { background: #667eea; color: white; padding: 12px 25px; border: none; border-radius: 5px; text-decoration: none; display: inline-block; cursor: pointer; }
.btn:hover { background: #5a67d8; }
.btn-secondary { background: #6c757d; }
.btn-secondary:hover { background: #5a6268; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.project-card { border: 1px solid #ddd; padding: 20px; border-radius: 8px; background: #f9f9f9; }
.project-card h3 { margin-top: 0; color: #333; }
.no-projects { text-align: center; color: #666; padding: 40px; }
.logout-btn { background: rgba(255,255,255,0.2); color: white; padding: 8px 15px; border: none; border-radius: 5px; cursor: pointer; text-decoration: none; }
.logout-btn:hover { background: rgba(255,255,255,0.3); }
</style>
</head>
<body>
<div class="header">
<div class="header-content">
<h1>🎮 Game Development Platform</h1>
<div class="user-info">
<div>
<div><strong><?php echo htmlspecialchars($user['username']); ?></strong></div>
<div class="plan-badge"><?php echo ucfirst($user['plan_type']); ?> Plan</div>
</div>
<a href="?logout=1" class="logout-btn">Logout</a>
</div>
</div>
</div>
<div class="container">
<div class="welcome-section">
<h1>Welcome back, <?php echo htmlspecialchars($user['username']); ?>! 👋</h1>
<p>Ready to build something awesome? Your creative journey continues here.</p>
<a href="#" class="btn">Create New Project</a>
<a href="#" class="btn btn-secondary">Browse Games</a>
</div>
<div class="stats-grid">
<div class="stat-card">
<div class="stat-number"><?php echo count($projects); ?></div>
<div class="stat-label">Projects</div>
</div>
<div class="stat-card">
<div class="stat-number"><?php echo $user['ai_credits_limit'] - $user['ai_credits_used']; ?></div>
<div class="stat-label">AI Credits Left</div>
</div>
<div class="stat-card">
<div class="stat-number"><?php echo round($user['disk_usage_mb']); ?>MB</div>
<div class="stat-label">Storage Used</div>
</div>
<div class="stat-card">
<div class="stat-number"><?php echo $user['last_login'] ? date('M j', strtotime($user['last_login'])) : 'Today'; ?></div>
<div class="stat-label">Last Login</div>
</div>
</div>
<div class="section">
<h2>Your Projects</h2>
<?php if (empty($projects)): ?>
<div class="no-projects">
<h3>No projects yet!</h3>
<p>Start building your first game or website.</p>
<a href="#" class="btn">Create Your First Project</a>
</div>
<?php else: ?>
<div class="project-grid">
<?php foreach ($projects as $project): ?>
<div class="project-card">
<h3><?php echo htmlspecialchars($project['project_name']); ?></h3>
<p><strong>Type:</strong> <?php echo ucfirst($project['project_type']); ?></p>
<p><strong>Created:</strong> <?php echo date('M j, Y', strtotime($project['created_date'])); ?></p>
<?php if ($project['subdomain']): ?>
<p><strong>URL:</strong> <a href="http://<?php echo $project['subdomain']; ?>.olinsspot.com" target="_blank"><?php echo $project['subdomain']; ?>.olinsspot.com</a></p>
<?php endif; ?>
<a href="#" class="btn">Edit Project</a>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<div class="section">
<h2>Quick Actions</h2>
<a href="#" class="btn">🎨 Block Editor</a>
<a href="#" class="btn">🤖 AI Assistant</a>
<a href="#" class="btn">📁 File Manager</a>
<a href="http://108.61.85.3/phpmyadmin" target="_blank" class="btn">🗄️ Database</a>
<?php if ($user['plan_type'] === 'free'): ?>
<a href="#" class="btn">⬆️ Upgrade Plan</a>
<?php endif; ?>
</div>
</div>
</body>
</html>
<div style="display:none;"><a href="https://www.rowlff.de/rowiki/" rel="dofollow">ItuGol Daftar</a></div>
<div style="display:none;"><a href="https://infoterviral.com/" rel="dofollow">info terviral</a></div>
<div style="display:none;"><a href="https://www.og-miltenberg.de/impressum/" rel="dofollow">Handicap Parlay</a></div>
<div style="display:none;"><a href="https://hopshysteria.de/craft-beer-blog-hops-hysteria/" rel="dofollow">ItuGol</a></div>
<div style="display:none;"><a href="https://mez.ink/itugoljp">ItuGol Daftar</a></div>
<div style="display:none;"><a href="https://joy.link/itugol">ItuGol Bola</a></div>
<div style="display:none;"><a href="https://link.space/@itugol/">ItuGol Login</a></div>
<div style="display:none;"><a href="https://heylink.me/itugoljp/">ItuGol</a></div>
<div style="display:none;"><a href="https://koin313.id/" rel="dofollow">Koin313</a></div>