| Server IP : 69.72.244.102 / Your IP : 216.73.216.164 Web Server : LiteSpeed System : Linux s3434.fra1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64 User : konzalta ( 1271) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/konzalta/soko.chat/ |
Upload File : |
<?php
require_once __DIR__ . '/app/db.php';
require_once __DIR__ . '/app/helpers.php';
$counties = $pdo->query("SELECT c.*, COUNT(d.id) AS deal_count
FROM counties c
LEFT JOIN deals d ON d.county_id=c.id AND d.status='published'
WHERE c.status='active'
GROUP BY c.id
ORDER BY c.name ASC")->fetchAll();
$activeCounties = $pdo->query("SELECT c.*, COUNT(d.id) AS deal_count
FROM counties c
INNER JOIN deals d ON d.county_id=c.id AND d.status='published'
WHERE c.status='active'
GROUP BY c.id
ORDER BY deal_count DESC, c.name ASC
LIMIT 10")->fetchAll();
if (!$activeCounties) {
$activeCounties = $pdo->query("SELECT c.*, COUNT(d.id) AS deal_count
FROM counties c
LEFT JOIN deals d ON d.county_id=c.id AND d.status='published'
WHERE c.status='active'
GROUP BY c.id
ORDER BY c.name ASC
LIMIT 10")->fetchAll();
}
$categories = $pdo->query("SELECT * FROM categories WHERE status='active' ORDER BY sort_order ASC, name ASC")->fetchAll();
$latest = $pdo->query("SELECT d.*, c.name county_name, cat.name category_name
FROM deals d
LEFT JOIN counties c ON c.id=d.county_id
LEFT JOIN categories cat ON cat.id=d.category_id
WHERE d.status='published'
ORDER BY d.created_at DESC
LIMIT 20")->fetchAll();
$popular = $pdo->query("SELECT d.*, c.name county_name, cat.name category_name
FROM deals d
LEFT JOIN counties c ON c.id=d.county_id
LEFT JOIN categories cat ON cat.id=d.category_id
WHERE d.status='published'
ORDER BY d.views_count DESC, d.created_at DESC
LIMIT 10")->fetchAll();
?>
<!doctype html><html><head><meta charset="utf-8"><title><?= e(APP_NAME) ?> - Kenya Classified Deals</title><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="<?= e(APP_URL) ?>/assets/css/style.css"></head>
<body>
<div class="top"><div class="wrap"><a class="brand logo-brand" href="<?= e(APP_URL) ?>/"><img class="logo-img" src="<?= e(APP_URL) ?>/assets/img/soko-logo.png" alt="Soko.chat"></a><span class="tag"> Kenya deals by county</span><div class="nav"><a href="<?= e(APP_URL) ?>/submit.php">post a deal free</a><a href="<?= e(APP_URL) ?>/admin/login.php">admin</a></div></div></div>
<div class="hero"><div class="wrap"><strong>Free to post. Cheap to unlock.</strong> Start with the busiest counties, or browse all 47 below.</div></div>
<div class="wrap layout">
<aside class="panel">
<h3>counties</h3>
<div class="cat-list">
<?php foreach ($counties as $county): ?>
<a href="<?= e(county_url($county['slug'])) ?>"><?= e(strtolower($county['name'])) ?> <span class="muted">(<?= e($county['deal_count']) ?>)</span></a>
<?php endforeach; ?>
</div>
</aside>
<main>
<div class="panel">
<h3>top 10 most active counties</h3>
<div class="active-counties">
<?php foreach ($activeCounties as $county): ?>
<a class="active-county" href="<?= e(county_url($county['slug'])) ?>">
<strong><?= e($county['name']) ?></strong>
<span><?= e((int)$county['deal_count']) ?> active deals</span>
</a>
<?php endforeach; ?>
</div>
<h3 class="all-counties-title">all 47 counties</h3>
<div class="county-grid">
<?php foreach ($counties as $county): ?>
<a href="<?= e(county_url($county['slug'])) ?>"><?= e($county['name']) ?> <span class="muted">(<?= e((int)$county['deal_count']) ?>)</span></a>
<?php endforeach; ?>
</div>
</div>
<h3>latest deals</h3>
<div class="deal-list">
<?php foreach ($latest as $deal): ?>
<div class="deal-row">
<a class="deal-title" href="<?= e(APP_URL) ?>/deal.php?slug=<?= e($deal['slug']) ?>"><?= e($deal['title']) ?></a>
<div class="muted"><?= e($deal['county_name'] ?: 'Kenya') ?> · <?= e($deal['category_name'] ?: 'Deal') ?> · <?= e($deal['location']) ?> · <?= e($deal['created_at']) ?></div>
<?php if ($deal['price']): ?><div class="price"><?= e($deal['price']) ?></div><?php endif; ?>
</div>
<?php endforeach; ?>
<?php if (!$latest): ?><div class="deal-row">No published deals yet.</div><?php endif; ?>
</div>
</main>
<aside class="panel">
<h3>categories</h3>
<div class="cat-list">
<?php foreach ($categories as $cat): ?>
<a href="<?= e(APP_URL) ?>/search.php?category=<?= e($cat['slug']) ?>"><?= e(strtolower($cat['name'])) ?></a>
<?php endforeach; ?>
</div>
<hr>
<h3>popular</h3>
<?php foreach ($popular as $deal): ?>
<p><a href="<?= e(APP_URL) ?>/deal.php?slug=<?= e($deal['slug']) ?>"><?= e($deal['title']) ?></a><br><span class="muted"><?= e((int)$deal['views_count']) ?> views</span></p>
<?php endforeach; ?>
</aside>
</div>
<div class="footer">soko.chat · a county-based classifieds board for WhatsApp deals</div>
</body></html>