X-Git-Url: https://git.cweiske.de/bdrem.git/blobdiff_plain/5274821c5d92a9267ec992ec1d6757c4765ee5e8..2d28ae7a776e4a7d9d989ee6dcc714b5e0045924:/src/phar-stub.php diff --git a/src/phar-stub.php b/src/phar-stub.php index 3c80130..8535a6f 100644 --- a/src/phar-stub.php +++ b/src/phar-stub.php @@ -1,12 +1,32 @@ + * @copyright 2014 Christian Weiske + * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3 + * @link http://cweiske.de/bdrem.htm + */ if (!in_array('phar', stream_get_wrappers()) || !class_exists('Phar', false)) { echo "Phar extension not avaiable\n"; exit(255); } $web = 'www/index.php'; -$cli = 'bin/bdrem.php'; +$cli = 'bin/phar-bdrem.php'; +/** + * Rewrite the HTTP request path to an internal file. + * Maps "" and "/" to "www/index.php". + * + * @param string $path Path from the browser, relative to the .phar + * + * @return string Internal path. + */ function rewritePath($path) { if ($path == '' || $path == '/') { @@ -16,8 +36,18 @@ function rewritePath($path) } //Phar::interceptFileFuncs(); -set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path()); +set_include_path( + 'phar://' . __FILE__ + . PATH_SEPARATOR . 'phar://' . __FILE__ . '/lib/' +); Phar::webPhar(null, $web, null, array(), 'rewritePath'); -include 'phar://' . __FILE__ . '/' . $cli; + +//work around https://bugs.php.net/bug.php?id=52322 +if (php_sapi_name() == 'cgi-fcgi') { + require 'phar://' . __FILE__ . '/' . $web; + exit(); +} + +require 'phar://' . __FILE__ . '/' . $cli; __HALT_COMPILER(); ?>