diff --git a/include/cli/modules/unpack.php b/include/cli/modules/unpack.php index 5635a03c98726ad7232ba066ac384b75d2ae80f6..72f5fae8228f9676df60376e79f234d0ceed56d0 100644 --- a/include/cli/modules/unpack.php +++ b/include/cli/modules/unpack.php @@ -197,21 +197,22 @@ class Unpacker extends Module { if (isset($location)) return $location; - $bootstrap_php = $this->destination . '/bootstrap.php'; - if (!is_file($bootstrap_php)) - return @$this->include_path ?: ''; - - $lines = preg_grep("/define\s*\(\s*'INCLUDE_DIR'/", - explode("\n", file_get_contents($bootstrap_php))); - - // NOTE: that this won't work for crafty folks who have a define or some - // variable in the value of their include path - if (!defined('ROOT_DIR')) - define('ROOT_DIR', rtrim($this->destination, '/').'/'); - foreach ($lines as $line) - @eval($line); - - return $location = rtrim(INCLUDE_DIR, '/').'/'; + $pipes = array(); + $php = proc_open('php', array( + 0 => array('pipe', 'r'), + 1 => array('pipe', 'w'), + ), $pipes); + + fwrite($pipes[0], "<?php + include '{$this->destination}/bootstrap.php'; + print INCLUDE_DIR; + "); + fclose($pipes[0]); + + $INCLUDE_DIR = fread($pipes[1], 8192); + proc_close($php); + + return $location = rtrim($INCLUDE_DIR, '/').'/'; } function run($args, $options) {