HEX
Server:
System: Linux aac286ea486c 5.14.0-687.15.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jun 11 08:51:45 EDT 2026 x86_64
User: root (0)
PHP: 8.2.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,disk_free_space,diskfreespace
Upload Files
File: //platform/misc/prepend-cli.php
<?php

if (is_dir('/configs')) {
    define('PAGELYBIN', '/configs');
} else {
    define('PAGELYBIN', '/pagely');
}

// fix the problem with returning the free disk space for the whole ceph storage
// it breaks some of the major WP migration plugins because the value is too large
if (version_compare(phpversion(), '8.0.0', '>=')) {
    // php version is high enough
    if (!function_exists('disk_free_space')) {
        function disk_free_space($directory)
        {
            // always return 30GB
            return 32212254720;
        }
    }
    // do the same thing for the alias function
    if (!function_exists('diskfreespace')) {
        function diskfreespace($directory)
        {
            return disk_free_space($directory);
        }
    }
}

// Before we include anything from the user, include our creds
if (file_exists(PAGELYBIN . '/config.php')) {
    include PAGELYBIN . '/config.php';
} else {
    // If this looks like WP CLI, then check if `--path` is being passed
    $mwpPotentialSitePath = null;
    if (!empty($argv) && is_array($argv)) {
        if ($argv[0] == '/usr/local/bin/wp') {
            // Loop argv and look for --path
            foreach ($argv as $arg) {
                if (strpos($arg, '--path=') === 0) {
                    $mwpPotentialSitePath = str_replace('--path=', '', $arg);
                    break;
                }
            }
        }
    }
    // If we didn't find a path then use the CWD
    if ($mwpPotentialSitePath === null) {
        $mwpPotentialSitePath = getcwd();
    }
    // Resolve the path and check if it matches our regex
    $mwpPotentialSitePath = realpath($mwpPotentialSitePath);
    if ($mwpPotentialSitePath !== false && is_dir($mwpPotentialSitePath) && preg_match('@^(/sites/[^/]+)@', $mwpPotentialSitePath, $mwpSiteMatches)) {
        // If a config file exists at <sitepath>/pagely/config.php, then include it, otherwise do nothing
        $mwpSiteConfigPath = $mwpSiteMatches[1] . '/pagely/config.php';
        if (file_exists($mwpSiteConfigPath)) {
            include $mwpSiteConfigPath;
        }
    }
    unset($mwpPotentialSitePath, $mwpSiteMatches, $mwpSiteConfigPath);
}