<?php
// Server-side deployment: reads local files and writes them to target paths on the server
// This runs ON the server so paths are relative to the server's filesystem
header('Content-Type: text/plain; charset=utf-8');

$files = [
    'app/core/project_menu.php',
    'public/projects/index.php',
];

$base = dirname(__DIR__, 2); // goes up from public/api to the gopools root

$results = [];

foreach ($files as $f) {
    $src  = $base . '/' . $f;
    if (!file_exists($src)) {
        $results[] = "MISSING: $f";
        continue;
    }
    $content = file_get_contents($src);
    $bytes   = strlen($content);
    $encoding = mb_detect_encoding($content, ['UTF-8', 'ISO-8859-1', 'ASCII'], true);

    // Verify key markers are present
    $checks = [];
    if ($f === 'public/projects/index.php') {
        $checks['customer-filter']    = strpos($content, 'customer-filter') !== false;
        $checks['title-search']       = strpos($content, 'title-search') !== false;
        $checks['view.php?id=']       = strpos($content, 'view.php?id=') !== false;
        $checks['applyFilters']       = strpos($content, 'applyFilters') !== false;
    }
    if ($f === 'app/core/project_menu.php') {
        $checks['flex-wrap: wrap']    = strpos($content, 'flex-wrap: wrap') !== false;
        $checks['view.php Overview']  = strpos($content, "view.php") !== false;
        $checks['edit.php label edit']= strpos($content, "'edit'") !== false;
        $checks['Οικονομικά']         = strpos($content, 'Οικονομικά') !== false;
        $checks['💰']                 = strpos($content, '💰') !== false;
    }

    $checkStr = '';
    foreach ($checks as $k => $v) {
        $checkStr .= ($v ? '✅' : '❌') . " $k\n";
    }

    $results[] = "=== $f ===\nBytes: $bytes | Encoding: $encoding\n$checkStr";
}

echo implode("\n", $results);
?>
