Final improvements
This commit is contained in:
parent
bb6f221939
commit
d177762371
@ -133,6 +133,7 @@ class FastAPI extends API
|
||||
{
|
||||
Logger::log("Trying to connect to IPC socket...");
|
||||
try {
|
||||
\clearstatcache(true, $ipcPath);
|
||||
return yield connect($ipcPath);
|
||||
} catch (\Throwable $e) {
|
||||
$e = $e->getMessage();
|
||||
|
@ -37,7 +37,7 @@ final class ProcessRunner extends RunnerAbstract
|
||||
\escapeshellarg($session),
|
||||
'&>/dev/null &'
|
||||
]);
|
||||
\shell_exec($command);
|
||||
\proc_close(\proc_open($command, [], $foo));
|
||||
}
|
||||
private static function locateBinary(): string
|
||||
{
|
||||
|
@ -46,26 +46,26 @@ final class WebRunner extends RunnerAbstract
|
||||
}
|
||||
$rootDir = \dirname($rootDir).DIRECTORY_SEPARATOR;
|
||||
$uriDir = \dirname($uri);
|
||||
if ($uriDir !== '/') $uriDir .= DIRECTORY_SEPARATOR;
|
||||
|
||||
if (\substr($rootDir, -\strlen($uriDir)) !== $uriDir) {
|
||||
throw new ContextException("Mismatch between absolute root dir ($rootDir) and URI dir ($uriDir)");
|
||||
}
|
||||
|
||||
// Absolute root of (presumably) readable document root
|
||||
$localRootDir = \substr($rootDir, 0, \strlen($rootDir)-\strlen($uriDir)).DIRECTORY_SEPARATOR;
|
||||
$absoluteRootDir = \substr($rootDir, 0, \strlen($rootDir)-\strlen($uriDir)).DIRECTORY_SEPARATOR;
|
||||
$runPath = self::getScriptPath($absoluteRootDir);
|
||||
|
||||
$runPath = self::getScriptPath($localRootDir);
|
||||
|
||||
if (\substr($runPath, 0, \strlen($localRootDir)) === $localRootDir) { // Process runner is within readable document root
|
||||
self::$runPath = \substr($runPath, \strlen($localRootDir)-1);
|
||||
if (\substr($runPath, 0, \strlen($absoluteRootDir)) === $absoluteRootDir) { // Process runner is within readable document root
|
||||
self::$runPath = \substr($runPath, \strlen($absoluteRootDir)-1);
|
||||
} else {
|
||||
$contents = \file_get_contents(self::SCRIPT_PATH);
|
||||
$contents = \str_replace("__DIR__", \var_export($localRootDir, true), $contents);
|
||||
$contents = \str_replace("__DIR__", \var_export($absoluteRootDir, true), $contents);
|
||||
$suffix = \bin2hex(\random_bytes(10));
|
||||
$runPath = $localRootDir."/madeline-ipc-".$suffix.".php";
|
||||
$runPath = $absoluteRootDir."/madeline-ipc-".$suffix.".php";
|
||||
\file_put_contents($runPath, $contents);
|
||||
|
||||
self::$runPath = \substr($runPath, \strlen($localRootDir)-1);
|
||||
self::$runPath = \substr($runPath, \strlen($absoluteRootDir)-1);
|
||||
|
||||
\register_shutdown_function(static function () use ($runPath): void {
|
||||
@\unlink($runPath);
|
||||
|
@ -35,7 +35,7 @@ trait Start
|
||||
public function start(): \Generator
|
||||
{
|
||||
if ((yield $this->getAuthorization()) === MTProto::LOGGED_IN) {
|
||||
return yield from $this->fullGetSelf();
|
||||
return $this instanceof \danog\MadelineProto\Ipc\Client ? yield from $this->getSelf() : yield from $this->fullGetSelf();
|
||||
}
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
if (\strpos(yield Tools::readLine('Do you want to login as user or bot (u/b)? '), 'b') !== false) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user