/** * processes the installer */ function process($argv) { // Determine ANSI output from --ansi and --no-ansi flags setUseAnsi($argv); if (in_array('--help', $argv)) { displayHelp(); exit(0); } $check = in_array('--check', $argv); $help = in_array('--help', $argv); $force = in_array('--force', $argv); $quiet = in_array('--quiet', $argv); $channel = in_array('--snapshot', $argv) ? 'snapshot' : (in_array('--preview', $argv) ? 'preview' : 'stable'); $disableTls = in_array('--disable-tls', $argv); $installDir = getOptValue('--install-dir', $argv, false); $version = getOptValue('--version', $argv, false); $filename = getOptValue('--filename', $argv, 'composer.phar'); $cafile = getOptValue('--cafile', $argv, false); if (!checkParams($installDir, $version, $cafile)) { exit(1); } $ok = checkPlatform($quiet, $disableTls); if (true === $disableTls) { out("You have instructed the Installer not to enforce SSL/TLS security on remote HTTPS requests.", 'info'); out("This will leave all downloads during installation vulnerable to Man-In-The-Middle (MITM) attacks.", 'info'); } if ($check) { exit($ok ? 0 : 1); } if ($ok || $force) { installComposer($version, $installDir, $filename, $quiet, $disableTls, $cafile, $channel); exit(0); } exit(1); }
/** * processes the installer */ function process($argv) { // Determine ANSI output from --ansi and --no-ansi flags setUseAnsi($argv); if (in_array('--help', $argv)) { displayHelp(); exit(0); } $check = in_array('--check', $argv); $help = in_array('--help', $argv); $force = in_array('--force', $argv); $quiet = in_array('--quiet', $argv); $channel = in_array('--snapshot', $argv) ? 'snapshot' : (in_array('--preview', $argv) ? 'preview' : 'stable'); $disableTls = in_array('--disable-tls', $argv); $installDir = getOptValue('--install-dir', $argv, false); $version = getOptValue('--version', $argv, false); $filename = getOptValue('--filename', $argv, 'composer.phar'); $cafile = getOptValue('--cafile', $argv, false); if (!checkParams($installDir, $version, $cafile)) { exit(1); } $ok = checkPlatform($warnings, $quiet, $disableTls); if ($check) { // Only show warnings if we haven't output any errors if ($ok) { showWarnings($warnings); showSecurityWarning($disableTls); } exit($ok ? 0 : 1); } if ($ok || $force) { installComposer($version, $installDir, $filename, $quiet, $disableTls, $cafile, $channel); showWarnings($warnings); showSecurityWarning($disableTls); exit(0); } exit(1); }
/** * processes the installer */ function process($argv) { $check = in_array('--check', $argv); $help = in_array('--help', $argv); $force = in_array('--force', $argv); $quiet = in_array('--quiet', $argv); $disableTls = in_array('--disable-tls', $argv); $installDir = false; $version = false; $filename = 'composer.phar'; $cafile = false; // --no-ansi wins over --ansi if (in_array('--no-ansi', $argv)) { define('USE_ANSI', false); } elseif (in_array('--ansi', $argv)) { define('USE_ANSI', true); } else { // On Windows, default to no ANSI, except in ANSICON and ConEmu. // Everywhere else, default to ANSI if stdout is a terminal. define('USE_ANSI', DIRECTORY_SEPARATOR == '\\' ? false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') : function_exists('posix_isatty') && posix_isatty(1)); } foreach ($argv as $key => $val) { if (0 === strpos($val, '--install-dir')) { if (13 === strlen($val) && isset($argv[$key + 1])) { $installDir = trim($argv[$key + 1]); } else { $installDir = trim(substr($val, 14)); } } if (0 === strpos($val, '--version')) { if (9 === strlen($val) && isset($argv[$key + 1])) { $version = trim($argv[$key + 1]); } else { $version = trim(substr($val, 10)); } } if (0 === strpos($val, '--filename')) { if (10 === strlen($val) && isset($argv[$key + 1])) { $filename = trim($argv[$key + 1]); } else { $filename = trim(substr($val, 11)); } } if (0 === strpos($val, '--cafile')) { if (8 === strlen($val) && isset($argv[$key + 1])) { $cafile = trim($argv[$key + 1]); } else { $cafile = trim(substr($val, 9)); } } } if ($help) { displayHelp(); exit(0); } $ok = checkPlatform($quiet, $disableTls); if (false !== $installDir && !is_dir($installDir)) { out("The defined install dir ({$installDir}) does not exist.", 'info'); $ok = false; } if (false !== $version && 1 !== preg_match('/^\\d+\\.\\d+\\.\\d+(\\-(alpha|beta)\\d+)*$/', $version)) { out("The defined install version ({$version}) does not match release pattern.", 'info'); $ok = false; } if (false !== $cafile && (!file_exists($cafile) || !is_readable($cafile))) { out("The defined Certificate Authority (CA) cert file ({$cafile}) does not exist or is not readable.", 'info'); $ok = false; } if (true === $disableTls) { out("You have instructed the Installer not to enforce SSL/TLS security on remote HTTPS requests.", 'info'); out("This will leave all downloads during installation vulnerable to Man-In-The-Middle (MITM) attacks.", 'info'); } if ($check) { exit($ok ? 0 : 1); } if ($ok || $force) { installComposer($version, $installDir, $filename, $quiet, $disableTls, $cafile); exit(0); } exit(1); }
if (!file_exists(__DIR__ . '/../vendor/autoload.php')) { if (!in_array('--yes', $_SERVER['argv'])) { echo "{$yellow}You must first run \"{$cyan}composer.phar install{$yellow}\" inside this directory to run this script.{$reset}\n"; echo "Would you like to run it now? [{$green}Y{$reset}/{$red}n{$reset}] "; while ($input = fgets(STDIN)) { $input = trim($input); if (strtolower($input) == 'y' || empty($input)) { installComposer(); } else { echo "\n{$red}This script will now exit.{$reset}\n"; exit; } break; } } else { installComposer(); } } else { require_once __DIR__ . '/../vendor/autoload.php'; } function installComposer() { $colors = getColors(); extract($colors); $quiet = ''; if (!in_array('--debug', $_SERVER['argv'])) { $quiet = '-q'; echo "\n{$yellow}Running composer... {$reset}"; } $rundir = __DIR__ . '/../'; echo `cd "{$rundir}" && php composer.phar update {$quiet}`;