123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <?php
- define('INSTALLDIR', dirname(__DIR__));
- define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
- define('GNUSOCIAL', true);
- define('STATUSNET', true);
- require_once INSTALLDIR . '/lib/util/common.php';
- call_user_func(function () {
- $cwd = null;
-
- $argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
- foreach ($argv as $i => $arg) {
- if ($arg === '--cwd') {
- if ($i >= count($argv) - 1) {
- echo 'Missing --cwd argument.' . PHP_EOL;
- exit(1);
- }
- $cwd = $argv[$i + 1];
- break;
- }
- if (preg_match('/^--cwd=/', $arg)) {
- $cwd = substr($arg, 6);
- break;
- }
- }
-
- if (!isset($cwd)) {
- $cwd = getcwd();
- }
- $cwd = str_replace('\\', '/', $cwd);
- $chunks = explode('/', $cwd);
- while (!empty($chunks)) {
- $path = implode('/', $chunks);
-
- if (is_file($path . '/composer.json')) {
- if (!empty($cfg = json_decode(
- file_get_contents($path . '/composer.json'),
- true
- ))) {
- if (isset($cfg['name']) && $cfg['name'] === 'psy/psysh') {
-
-
- if (is_file($path . '/vendor/autoload.php')) {
- require $path . '/vendor/autoload.php';
- }
- return;
- }
- }
- }
-
- if (is_file($path . '/composer.lock')) {
- if (!empty($cfg = json_decode(
- file_get_contents($path . '/composer.lock'),
- true
- ))) {
- foreach (array_merge($cfg['packages'], $cfg['packages-dev']) as $pkg) {
- if (isset($pkg['name']) && $pkg['name'] === 'psy/psysh') {
-
-
- if (is_file($path . '/vendor/autoload.php')) {
- require $path . '/vendor/autoload.php';
- }
- return;
- }
- }
- }
- }
- array_pop($chunks);
- }
- });
- if (!class_exists('Psy\Shell')) {
-
- if (is_file(__DIR__ . '/../vendor/autoload.php')) {
- require __DIR__ . '/../vendor/autoload.php';
- } elseif (is_file(__DIR__ . '/../../../autoload.php')) {
- require __DIR__ . '/../../../autoload.php';
- } else {
- echo 'PsySH dependencies not found, be sure to run `composer install`.' . PHP_EOL;
- echo 'See https://getcomposer.org to get Composer.' . PHP_EOL;
- exit(1);
- }
-
- }
- if (version_compare(PHP_VERSION, '5.3.6', '<')) {
- $trace = debug_backtrace();
- } elseif (version_compare(PHP_VERSION, '5.4.0', '<')) {
- $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
- } else {
- $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
- }
- if (Psy\Shell::isIncluded($trace)) {
- unset($trace);
- return;
- }
- unset($trace);
- if (!function_exists('Psy\bin')) {
- $argv = $_SERVER['argv'];
- $first = array_shift($argv);
- if (preg_match('/php(\.exe)?$/', $first)) {
- array_shift($argv);
- }
- array_unshift($argv, 'vendor/bin/psysh');
- echo 'A local PsySH dependency was found, but it cannot be loaded. Please update to' . PHP_EOL;
- echo 'the latest version, or run the local copy directly, e.g.:' . PHP_EOL;
- echo PHP_EOL;
- echo ' ' . implode(' ', $argv) . PHP_EOL;
- exit(1);
- }
- call_user_func(Psy\bin());
|