diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..2d34d98 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: Lint + +on: + push: + pull_request: + +jobs: + php-lint: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: ['8.3', '8.4'] + steps: + - uses: actions/checkout@v6 + + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + + - run: php -l setup.php diff --git a/setup.php b/setup.php index d85f106..e395e38 100644 --- a/setup.php +++ b/setup.php @@ -294,6 +294,26 @@ function parsePhpSize($size) $curlAvailable = function_exists('curl_init'); $allowUrlFopen = (bool) ini_get('allow_url_fopen'); +/** + * Mitgeliefertes Release-Archiv neben setup.php suchen (Install-Package). + * Liegt ein ignis-*.zip / intraRP-*.zip im selben Verzeichnis, wird es + * direkt entpackt — kein GitHub-Download nötig. Bei mehreren Treffern + * gewinnt alphabetisch das letzte (= höchste Version). + */ +function findBundledArchive(): ?string +{ + foreach (['ignis-*.zip', 'intraRP-*.zip'] as $pattern) { + $matches = glob(__DIR__ . DIRECTORY_SEPARATOR . $pattern); + if (!empty($matches)) { + sort($matches, SORT_NATURAL); + return end($matches); + } + } + return null; +} + +$bundledArchive = findBundledArchive(); + // Writable-Check auf das Verzeichnis in dem setup.php liegt — dort wird // die .env geschrieben und das ZIP extrahiert. Wenn das nicht writable // ist, kann das Setup sofort scheitern, ohne vorher 100MB runterzuladen. @@ -654,8 +674,10 @@ function cleanupProgress(): void { $errors = []; $success = []; $downloadMethodOk = $curlAvailable || $allowUrlFopen; +// Mit mitgeliefertem Archiv ist kein Download nötig — die fehlende +// Download-Methode blockiert das Setup dann nicht. $canProceed = $phpVersionOk - && $downloadMethodOk + && ($downloadMethodOk || $bundledArchive !== null) && class_exists('ZipArchive') && $allExtensionsOk && $setupDirWritable; @@ -962,13 +984,16 @@ function runGitInstall(string $baseDir, string $branchMode, string $customBranch $errors[] = 'Zu viele Setup-Versuche in kurzer Zeit. Bitte kurz warten.'; } - $gitBranch = $_POST['git_branch'] ?? 'release'; + $gitBranch = $_POST['git_branch'] ?? ($bundledArchive !== null ? 'local' : 'release'); $customBranch = trim($_POST['custom_branch'] ?? ''); // Whitelist - if (!in_array($gitBranch, ['release', 'main', 'custom'], true)) { + if (!in_array($gitBranch, ['local', 'release', 'main', 'custom'], true)) { $errors[] = 'Ungültiger Branch-Modus.'; - $gitBranch = 'release'; + $gitBranch = $bundledArchive !== null ? 'local' : 'release'; + } + if ($gitBranch === 'local' && $bundledArchive === null) { + $errors[] = 'Kein mitgeliefertes Archiv (ignis-*.zip) neben setup.php gefunden.'; } if ($gitBranch === 'custom' && !isValidBranchName($customBranch)) { $errors[] = 'Custom Branch-Name enthält ungültige Zeichen.'; @@ -983,11 +1008,30 @@ function runGitInstall(string $baseDir, string $branchMode, string $customBranch $migrateOutput = ''; $needsManualComposer = false; - writeProgress('connect', 'Verbindung zu GitHub...', 0); + writeProgress('connect', $gitBranch === 'local' ? 'Mitgeliefertes Paket wird vorbereitet...' : 'Verbindung zu GitHub...', 0); // ─── Schritt A: Quellcode installieren ────────────────────────── if (empty($errors)) { - if ($gitBranch === 'release') { + if ($gitBranch === 'local') { + // Install-Package: das neben setup.php liegende Archiv wird + // entpackt statt etwas herunterzuladen. Nach erfolgreichem + // Entpacken wird das Archiv gelöscht. + $zipPath = $bundledArchive; + writeProgress('zip', 'Paket wird entpackt...', 25); + $zip = new ZipArchive(); + $rc = $zip->open($zipPath); + if ($rc === true) { + $zip->extractTo($baseDir); + $zip->close(); + @unlink($zipPath); + if (file_exists($zipPath)) { + $warnings[] = 'Das Installations-Archiv ' . htmlspecialchars(basename($zipPath)) . ' konnte nicht gelöscht werden — bitte manuell entfernen.'; + } + $success[] = 'Mitgeliefertes Paket ' . htmlspecialchars(basename($zipPath)) . ' erfolgreich installiert.'; + } else { + $errors[] = 'ZIP-Entpacken fehlgeschlagen (Code: ' . $rc . ').'; + } + } elseif ($gitBranch === 'release') { $rel = fetchLatestRelease('EmergencyForge', 'intraRP'); if (!$rel['ok']) { $errors[] = 'Konnte Release-Informationen nicht abrufen: ' . ($rel['error'] ?? ''); @@ -1200,6 +1244,12 @@ function runGitInstall(string $baseDir, string $branchMode, string $customBranch } if (empty($errors)) { + // Beilagen des Install-Packages mit aufräumen, falls vorhanden. + $bundledReadme = __DIR__ . DIRECTORY_SEPARATOR . 'readme.txt'; + if (file_exists($bundledReadme)) { + @unlink($bundledReadme); + } + @unlink($setupFile); clearstatcache(true, $setupFile); $selfDeleteOk = !file_exists($setupFile); @@ -3104,13 +3154,16 @@ function runGitInstall(string $baseDir, string $branchMode, string $customBranch - +
Download
- + + Nicht erforderlich +
Mitgeliefertes Paket wird verwendet — kein Download nötig
+ cURL verfügbar
Optimale Methode für große Downloads
@@ -3203,10 +3256,28 @@ function runGitInstall(string $baseDir, string $branchMode, string $customBranch
- -
-

Git Repository

+ +
+

+ +
+ + +
+ +
+
+
@@ -3250,6 +3321,7 @@ function runGitInstall(string $baseDir, string $branchMode, string $customBranch Repository: github.com/EmergencyForge/intraRP
+