<?php

namespace App\Controllers;

use App\Models\Domain;
use App\Utils\View;

class ApiController
{
    public function domains()
    {
        $domainModel = new Domain();
        // Get only blocked domains
        $domains = $domainModel->where('status', 'blocked');

        $list = array_column($domains, 'name');

        // Calculate Checksum (MD5 of sorted list)
        sort($list);
        $checksum = md5(json_encode($list));

        View::json([
            'domains' => $list,
            'checksum' => $checksum,
            'timestamp' => time()
        ]);
    }
}
