Пример #1
0
function getRequestUri()
{
    $home_dir = getHomeDirectory();
    if ($home_dir) {
        return str_replace(trim($home_dir, '/'), '', full_url($_SERVER));
    } else {
        return $_SERVER['REQUEST_URI'];
    }
}
Пример #2
0
    output("  The download was corrupted.", 'error');
    exit(1);
}
output("  Checking that the file is a valid Phar (PHP Archive)...");
try {
    new Phar(CLI_PHAR);
} catch (Exception $e) {
    output("  The file is not a valid Phar archive.", 'error');
    throw $e;
}
output("  Making the Phar executable...");
chmod(CLI_PHAR, 0755);
// Attempt automatic configuration of the shell (including the PATH).
$installedInHomeDir = false;
$configured = false;
if ($home = getHomeDirectory()) {
    $configDir = $home . '/' . CLI_CONFIG_DIR;
    if (!file_exists($configDir . '/bin')) {
        mkdir($configDir . '/bin', 0700, true);
    }
    // Extract the shell-config.rc file out of the Phar, so that it can be included
    // in the user's shell configuration. N.B. reading from a Phar only works
    // while it still has the '.phar' extension.
    output('  Extracting the shell configuration file...');
    $rcDestination = $configDir . '/shell-config.rc';
    $rcSource = 'phar://' . CLI_PHAR . '/shell-config.rc';
    if (($rcContents = file_get_contents($rcSource)) === false) {
        output(sprintf('  Failed to read file: %s', $rcSource), 'warning');
    } elseif (file_put_contents($rcDestination, $rcContents) === false) {
        output(sprintf('  Failed to write file: %s', $rcDestination), 'warning');
    }