-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
128 lines (119 loc) · 5.59 KB
/
index.php
File metadata and controls
128 lines (119 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
require_once __DIR__ . '/config.php';
$pageTitle = SITE_NAME . ' — Home';
// Get recent posts with author info
$stmt = db()->query("
SELECT p.*, u.username, u.blog_slug, u.blog_title, u.version,
ct.title as category_name
FROM posts p
JOIN users u ON p.user_id = u.id
LEFT JOIN categories c ON p.category_id = c.id
LEFT JOIN languages l ON l.is_default = 1
LEFT JOIN category_translations ct ON ct.category_id = c.id AND ct.language_id = l.id
WHERE p.status = 'published' AND u.is_active = 1 AND u.blog_suspended = 0
ORDER BY p.created_at DESC
LIMIT 12
");
$posts = $stmt ? $stmt->fetch_all(MYSQLI_ASSOC) : [];
// Get featured bloggers
$bloggers = db()->query("
SELECT u.*, COUNT(p.id) as post_count
FROM users u
LEFT JOIN posts p ON p.user_id = u.id AND p.status='published'
WHERE u.is_active=1 AND u.blog_suspended=0 AND u.blog_slug IS NOT NULL
GROUP BY u.id
ORDER BY post_count DESC
LIMIT 5
")?->fetch_all(MYSQLI_ASSOC) ?? [];
include __DIR__ . '/includes/header.php';
?>
<!-- Hero -->
<div class="p-5 mb-4 rounded-4 text-white" style="background: linear-gradient(135deg, #3e729a 0%, #1a2e3e 100%);">
<div class="row align-items-center">
<div class="col-md-8">
<h1 class="display-5 fw-bold mb-3"><i class="bi bi-layers-half me-2"></i>Welcome to <?= SITE_NAME ?></h1>
<p class="lead mb-4 opacity-90">A powerful multi-user blogging platform. Create your blog, write your story, share with the world.</p>
<?php if (!auth()): ?>
<a href="<?= SITE_URL ?>/register.php" class="btn btn-light btn-lg me-2"><i class="bi bi-person-plus me-1"></i>Start Your Blog</a>
<a href="<?= SITE_URL ?>/login.php" class="btn btn-outline-light btn-lg"><i class="bi bi-box-arrow-in-right me-1"></i>Sign In</a>
<?php else: ?>
<a href="<?= SITE_URL ?>/dashboard/index.php" class="btn btn-light btn-lg"><i class="bi bi-speedometer2 me-1"></i>My Dashboard</a>
<?php endif; ?>
</div>
<div class="col-md-4 text-center d-none d-md-block">
<i class="bi bi-journal-richtext" style="font-size:8rem; opacity:.3;"></i>
</div>
</div>
</div>
<?php if (!isPro()): ?>
<!-- Header ad for basic users/guests -->
<?php renderAds('header'); ?>
<?php endif; ?>
<div class="row">
<div class="col-lg-8">
<h4 class="mb-4"><i class="bi bi-clock-history me-2 text-primary"></i>Recent Posts</h4>
<?php if (empty($posts)): ?>
<div class="alert alert-info">No posts yet. <a href="<?= SITE_URL ?>/register.php">Be the first to write!</a></div>
<?php else: ?>
<div class="row g-4">
<?php foreach ($posts as $post): ?>
<div class="col-md-6">
<div class="card post-card h-100">
<?php if ($post['thumbnail']): ?>
<img src="<?= e(UPLOAD_URL . $post['thumbnail']) ?>" alt="<?= e($post['title']) ?>">
<?php else: ?>
<div style="height:200px; background:var(--blue-light); display:flex; align-items:center; justify-content:center; border-radius:12px 12px 0 0;">
<i class="bi bi-image text-primary" style="font-size:3rem; opacity:.4;"></i>
</div>
<?php endif; ?>
<div class="card-body">
<?php if ($post['category_name']): ?>
<span class="badge mb-2" style="background:var(--blue-light);color:var(--blue);"><?= e($post['category_name']) ?></span>
<?php endif; ?>
<h6 class="card-title"><a href="<?= blogUrl($post['blog_slug'], $post['slug']) ?>" class="text-decoration-none text-dark"><?= e($post['title']) ?></a></h6>
<div class="d-flex align-items-center justify-content-between mt-3">
<small class="text-muted">
<a href="<?= blogUrl($post['blog_slug']) ?>" class="text-decoration-none text-muted">
<i class="bi bi-person me-1"></i><?= e($post['username']) ?>
<?php if ($post['version'] === 'pro'): ?><span class="pro-badge ms-1">PRO</span><?php endif; ?>
</a>
</small>
<small class="text-muted"><i class="bi bi-calendar3 me-1"></i><?= date('M j, Y', strtotime($post['created_at'])) ?></small>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<div class="col-lg-4">
<?php if (!isPro()): ?>
<?php renderAds('sidebar'); ?>
<?php endif; ?>
<div class="card sidebar-card mb-4">
<div class="card-header"><i class="bi bi-people me-2"></i>Featured Bloggers</div>
<div class="card-body p-0">
<?php foreach ($bloggers as $b): ?>
<div class="d-flex align-items-center p-3 border-bottom">
<div class="rounded-circle d-flex align-items-center justify-content-center me-3 flex-shrink-0" style="width:40px;height:40px;background:var(--blue-light);color:var(--blue);font-weight:700;">
<?= strtoupper(substr($b['username'],0,1)) ?>
</div>
<div class="flex-grow-1">
<a href="<?= blogUrl($b['blog_slug']) ?>" class="text-decoration-none fw-600 text-dark">
<?= e($b['blog_title'] ?: $b['username']) ?>
<?php if ($b['version'] === 'pro'): ?><span class="pro-badge ms-1">PRO</span><?php endif; ?>
</a>
<div class="text-muted small"><?= $b['post_count'] ?> posts</div>
</div>
</div>
<?php endforeach; ?>
<?php if (empty($bloggers)): ?><p class="text-muted p-3 mb-0">No bloggers yet.</p><?php endif; ?>
</div>
</div>
<?php if (!isPro()): ?>
<?php renderAds('footer'); ?>
<?php endif; ?>
</div>
</div>
<?php include __DIR__ . '/includes/footer.php'; ?>