&1', $output, $code); if ($code !== 0) { log_msg('Errore clone: ' . implode("\n", $output)); return false; } $copied = 0; foreach (scandir($temp) as $item) { if ($item === '.' || $item === '..' || in_array($item, EXCLUDE)) { continue; } $src = $temp . '/' . $item; $dst = WWW_PATH . '/' . $item; if (is_dir($dst)) exec('rm -rf ' . escapeshellarg($dst)); elseif (file_exists($dst)) unlink($dst); if (is_dir($src)) exec('cp -r ' . escapeshellarg($src) . ' ' . escapeshellarg($dst)); else copy($src, $dst); $copied++; } exec('rm -rf ' . escapeshellarg($temp)); log_msg("Completato: $copied elementi copiati"); return true; } // Main log_msg('=== Controllo aggiornamenti ==='); $remote = get_remote_commit(); if (!$remote) { log_msg('Impossibile contattare API Forgejo'); exit(1); } $local = get_local_commit(); if ($remote === $local) { log_msg('Nessun aggiornamento'); exit(0); } log_msg('Aggiornamento disponibile...'); if (update_site()) { file_put_contents(HASH_FILE, $remote); log_msg("Hash salvato: $remote"); } else { log_msg('Aggiornamento fallito'); exit(1); }