HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ubuntu-8gb-hel1-1 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64
User: www-data (33)
PHP: 8.1.32
Disabled: NONE
Upload Files
File: /var/www/html/obaasimaghana/app/views/forum/category.php
<?php
$title = $data["category"]["name"] . ' - Forum';
$content = '
<div class="container mx-auto px-4 py-8">
    <div class="flex justify-between items-center mb-8">
        <div>
            <h1 class="text-3xl font-bold text-gray-800">' . $data["category"]["name"] . '</h1>
            <p class="text-gray-600 mt-2">' . $data["category"]["description"] . '</p>
        </div>
        <?php if(isset($_SESSION["user_id"])): ?>
            <a href="' . SITE_URL . '/forum/create/' . $data["category"]["id"] . '" class="bg-emerald-600 text-white px-4 py-2 rounded-lg hover:bg-emerald-700">
                <i class="fas fa-plus mr-2"></i>New Topic
            </a>
        <?php endif; ?>
    </div>

    <div class="grid grid-cols-1 md:grid-cols-4 gap-6">
        <!-- Categories List -->
        <div class="md:col-span-1">
            <div class="bg-white rounded-lg shadow p-4">
                <h2 class="text-lg font-semibold mb-4">Categories</h2>
                <ul class="space-y-2">';

// Add categories list
if (isset($data["categories"]) && is_array($data["categories"])) {
    foreach($data["categories"] as $category) {
        $topicCount = isset($category["topic_count"]) ? $category["topic_count"] : 0;
        $content .= '
                        <li>
                            <a href="' . SITE_URL . '/forum/category/' . $category["id"] . '" 
                               class="flex items-center justify-between p-2 rounded hover:bg-gray-50 ' . 
                               ($data["category"]["id"] == $category["id"] ? 
                               "bg-emerald-50 text-emerald-600" : "text-gray-700") . '">
                                <span class="font-medium">' . $category["name"] . '</span>
                                <span class="text-sm text-gray-500">' . $topicCount . '</span>
                            </a>
                        </li>';
    }
}

$content .= '
                </ul>
            </div>
        </div>

        <!-- Topics List -->
        <div class="md:col-span-3">
            <div class="bg-white rounded-lg shadow">';

// Check if topics exist
if(empty($data["topics"])) {
    $content .= '
                    <div class="p-8 text-center">
                        <i class="fas fa-comments text-4xl text-gray-400 mb-4"></i>
                        <p class="text-gray-600">No topics found in this category.</p>';
    
    if(isset($_SESSION["user_id"])) {
        $content .= '
                        <a href="' . SITE_URL . '/forum/create/' . $data["category"]["id"] . '" class="inline-block mt-4 text-emerald-600 hover:text-emerald-700">
                            Be the first to create a topic
                        </a>';
    }
    
    $content .= '
                    </div>';
} else {
    $content .= '
                    <div class="divide-y">';
    
    foreach($data["topics"] as $topic) {
        $content .= '
                        <div class="p-4 hover:bg-gray-50">
                            <div class="flex items-start justify-between">
                                <div>
                                    <a href="' . SITE_URL . '/forum/topic/' . $topic["id"] . '" class="text-lg font-medium text-gray-900 hover:text-emerald-600">
                                        ' . $topic["title"] . '
                                    </a>
                                    <div class="mt-1 text-sm text-gray-500">
                                        Posted by ' . $topic["author_name"] . '
                                    </div>
                                </div>
                                <div class="text-sm text-gray-500">
                                    ' . date("M j, Y", strtotime($topic["created_at"])) . '
                                </div>
                            </div>
                            <div class="mt-2 flex items-center text-sm text-gray-500">
                                <span class="flex items-center">
                                    <i class="fas fa-comments mr-1"></i>
                                    ' . $topic["reply_count"] . ' replies
                                </span>
                                <span class="mx-2">•</span>
                                <span class="flex items-center">
                                    <i class="fas fa-eye mr-1"></i>
                                    ' . $topic["view_count"] . ' views
                                </span>
                            </div>
                        </div>';
    }
    
    $content .= '
                    </div>';
}

$content .= '
            </div>
        </div>
    </div>
</div>
';

require_once APP_PATH . '/views/layouts/forum.php';
?>