Phar fixes

This commit is contained in:
Daniil Gentili 2019-05-11 00:17:57 +00:00
parent e83575ffdb
commit 8c59efbd96

View File

@ -25,11 +25,14 @@ $p->addFromString('.git/refs/heads/master', $argv[3]);
$p->setStub('<?php
$backtrace = debug_backtrace();
if ($backtrace && in_array(basename($backtrace[0]["file"]), ["madeline.php", "phar.php"]) && isset($backtrace[1]["file"]) && !defined("PHAR_DEBUG")) {
if (!isset($backtrace[0]["file"]) || !in_array(basename($backtrace[0]["file"]), ["madeline.php", "phar.php"])) {
die("madeline.phar cannot be required manually: use the automatic loader, instead: https://docs.madelineproto.xyz/docs/INSTALLATION.html#simple".PHP_EOL);
}
if (isset($backtrace[1]["file"])) {
chdir(dirname($backtrace[1]["file"]));
if ($contents = file_get_contents("https://phar.madelineproto.xyz/phar.php?v=new")) {
file_put_contents($backtrace[0]["file"], $contents);
}
}
if ($contents = file_get_contents("https://phar.madelineproto.xyz/phar.php?v=new")) {
file_put_contents($backtrace[0]["file"], $contents);
}
Phar::interceptFileFuncs();