Avoid certain issues
This commit is contained in:
parent
4923eec9cd
commit
1e690d1a8f
|
@ -37,7 +37,7 @@ trait Start
|
||||||
*/
|
*/
|
||||||
private function APIStart(array $settings): \Generator
|
private function APIStart(array $settings): \Generator
|
||||||
{
|
{
|
||||||
if (PHP_SAPI === 'cli') {
|
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||||
$stdout = getStdout();
|
$stdout = getStdout();
|
||||||
yield $stdout->write('You did not define a valid API ID/API hash. Do you want to define it now manually, or automatically? (m/a)
|
yield $stdout->write('You did not define a valid API ID/API hash. Do you want to define it now manually, or automatically? (m/a)
|
||||||
Note that you can also provide the API parameters directly in the code using the settings: https://docs.madelineproto.xyz/docs/SETTINGS.html#settingsapp_infoapi_id'.PHP_EOL);
|
Note that you can also provide the API parameters directly in the code using the settings: https://docs.madelineproto.xyz/docs/SETTINGS.html#settingsapp_infoapi_id'.PHP_EOL);
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Exception extends \Exception
|
||||||
$additional = 'Follow the instructions @ https://prime.madelineproto.xyz to install it.';
|
$additional = 'Follow the instructions @ https://prime.madelineproto.xyz to install it.';
|
||||||
}
|
}
|
||||||
$message = 'MadelineProto requires the '.$extensionName.' extension to run. '.$additional;
|
$message = 'MadelineProto requires the '.$extensionName.' extension to run. '.$additional;
|
||||||
if (PHP_SAPI !== 'cli') {
|
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
|
||||||
echo $message.'<br>';
|
echo $message.'<br>';
|
||||||
}
|
}
|
||||||
$file = 'MadelineProto';
|
$file = 'MadelineProto';
|
||||||
|
|
|
@ -21,6 +21,8 @@ namespace danog\MadelineProto;
|
||||||
|
|
||||||
use Amp\ByteStream\ResourceOutputStream;
|
use Amp\ByteStream\ResourceOutputStream;
|
||||||
use Amp\Failure;
|
use Amp\Failure;
|
||||||
|
use Amp\Loop;
|
||||||
|
|
||||||
use function Amp\ByteStream\getStderr;
|
use function Amp\ByteStream\getStderr;
|
||||||
use function Amp\ByteStream\getStdout;
|
use function Amp\ByteStream\getStdout;
|
||||||
|
|
||||||
|
@ -87,12 +89,17 @@ class Logger
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
public static $printed = false;
|
public static $printed = false;
|
||||||
|
/**
|
||||||
|
* Log rotation loop ID.
|
||||||
|
*/
|
||||||
|
private string $rotateId;
|
||||||
const ULTRA_VERBOSE = 5;
|
const ULTRA_VERBOSE = 5;
|
||||||
const VERBOSE = 4;
|
const VERBOSE = 4;
|
||||||
const NOTICE = 3;
|
const NOTICE = 3;
|
||||||
const WARNING = 2;
|
const WARNING = 2;
|
||||||
const ERROR = 1;
|
const ERROR = 1;
|
||||||
const FATAL_ERROR = 0;
|
const FATAL_ERROR = 0;
|
||||||
|
|
||||||
const NO_LOGGER = 0;
|
const NO_LOGGER = 0;
|
||||||
const DEFAULT_LOGGER = 1;
|
const DEFAULT_LOGGER = 1;
|
||||||
const FILE_LOGGER = 2;
|
const FILE_LOGGER = 2;
|
||||||
|
@ -125,14 +132,14 @@ class Logger
|
||||||
if (!isset($settings['logger']['logger_param']) && isset($settings['logger']['param'])) {
|
if (!isset($settings['logger']['logger_param']) && isset($settings['logger']['param'])) {
|
||||||
$settings['logger']['logger_param'] = $settings['logger']['param'];
|
$settings['logger']['logger_param'] = $settings['logger']['param'];
|
||||||
}
|
}
|
||||||
if (PHP_SAPI !== 'cli' && isset($settings['logger']['logger_param']) && $settings['logger']['logger_param'] === 'MadelineProto.log') {
|
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg' && isset($settings['logger']['logger_param']) && $settings['logger']['logger_param'] === 'MadelineProto.log') {
|
||||||
$settings['logger']['logger_param'] = Magic::$script_cwd.'/MadelineProto.log';
|
$settings['logger']['logger_param'] = Magic::$script_cwd.'/MadelineProto.log';
|
||||||
}
|
}
|
||||||
$logger = new self($settings['logger']['logger'], $settings['logger']['logger_param'] ?? '', $prefix, $settings['logger']['logger_level'] ?? Logger::VERBOSE, $settings['logger']['max_size'] ?? 100 * 1024 * 1024);
|
$logger = new self($settings['logger']['logger'], $settings['logger']['logger_param'] ?? '', $prefix, $settings['logger']['logger_level'] ?? Logger::VERBOSE, $settings['logger']['max_size'] ?? 100 * 1024 * 1024);
|
||||||
if (!self::$default) {
|
if (!self::$default) {
|
||||||
self::$default = $logger;
|
self::$default = $logger;
|
||||||
}
|
}
|
||||||
if (PHP_SAPI !== 'cli') {
|
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
|
||||||
try {
|
try {
|
||||||
\error_reporting(E_ALL);
|
\error_reporting(E_ALL);
|
||||||
\ini_set('log_errors', 1);
|
\ini_set('log_errors', 1);
|
||||||
|
@ -170,22 +177,28 @@ class Logger
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(int $mode, $optional = null, string $prefix = '', int $level = self::NOTICE, int $max_size = 100 * 1024 * 1024)
|
public function __construct(int $mode, $optional = null, string $prefix = '', int $level = self::NOTICE, int $max_size = 10 * 1024 * 1024)
|
||||||
{
|
{
|
||||||
if ($mode === null) {
|
if ($mode === null) {
|
||||||
throw new Exception(\danog\MadelineProto\Lang::$current_lang['no_mode_specified']);
|
throw new Exception(\danog\MadelineProto\Lang::$current_lang['no_mode_specified']);
|
||||||
}
|
}
|
||||||
|
if ($mode === self::NO_LOGGER) {
|
||||||
|
$mode = (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') ? Logger::ECHO_LOGGER : Logger::FILE_LOGGER;
|
||||||
|
}
|
||||||
|
$level = \max($level, self::NOTICE);
|
||||||
|
$max_size = \max($max_size, 100 * 1024);
|
||||||
|
|
||||||
$this->mode = $mode;
|
$this->mode = $mode;
|
||||||
$this->optional = $mode == 2 ? Tools::absolute($optional) : $optional;
|
$this->optional = $mode == self::FILE_LOGGER ? Tools::absolute($optional) : $optional;
|
||||||
$this->prefix = $prefix === '' ? '' : ', '.$prefix;
|
$this->prefix = $prefix === '' ? '' : ', '.$prefix;
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
if ($this->mode === 2 && !\file_exists(\pathinfo($this->optional, PATHINFO_DIRNAME))) {
|
if ($this->mode === self::FILE_LOGGER && !\file_exists(\pathinfo($this->optional, PATHINFO_DIRNAME))) {
|
||||||
$this->optional = Magic::$script_cwd.'/MadelineProto.log';
|
$this->optional = Magic::$script_cwd.'/MadelineProto.log';
|
||||||
}
|
}
|
||||||
if ($this->mode === 2 && !\preg_match('/\\.log$/', $this->optional)) {
|
if ($this->mode === self::FILE_LOGGER && !\preg_match('/\\.log$/', $this->optional)) {
|
||||||
$this->optional .= '.log';
|
$this->optional .= '.log';
|
||||||
}
|
}
|
||||||
if ($mode === 2 && $max_size !== -1 && \file_exists($this->optional) && \filesize($this->optional) > $max_size) {
|
if ($mode === self::FILE_LOGGER && $max_size !== -1 && \file_exists($this->optional) && \filesize($this->optional) > $max_size) {
|
||||||
\unlink($this->optional);
|
\unlink($this->optional);
|
||||||
}
|
}
|
||||||
$this->colors[self::ULTRA_VERBOSE] = \implode(';', [self::FOREGROUND['light_gray'], self::SET['dim']]);
|
$this->colors[self::ULTRA_VERBOSE] = \implode(';', [self::FOREGROUND['light_gray'], self::SET['dim']]);
|
||||||
|
@ -195,14 +208,30 @@ class Logger
|
||||||
$this->colors[self::ERROR] = \implode(';', [self::FOREGROUND['white'], self::SET['bold'], self::BACKGROUND['red']]);
|
$this->colors[self::ERROR] = \implode(';', [self::FOREGROUND['white'], self::SET['bold'], self::BACKGROUND['red']]);
|
||||||
$this->colors[self::FATAL_ERROR] = \implode(';', [self::FOREGROUND['red'], self::SET['bold'], self::BACKGROUND['light_gray']]);
|
$this->colors[self::FATAL_ERROR] = \implode(';', [self::FOREGROUND['red'], self::SET['bold'], self::BACKGROUND['light_gray']]);
|
||||||
$this->newline = PHP_EOL;
|
$this->newline = PHP_EOL;
|
||||||
if ($this->mode === 3) {
|
if ($this->mode === self::ECHO_LOGGER) {
|
||||||
$this->stdout = getStdout();
|
$this->stdout = getStdout();
|
||||||
if (PHP_SAPI !== 'cli') {
|
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
|
||||||
$this->newline = '<br>'.$this->newline;
|
$this->newline = '<br>'.$this->newline;
|
||||||
}
|
}
|
||||||
} elseif ($this->mode === 2) {
|
} elseif ($this->mode === self::FILE_LOGGER) {
|
||||||
$this->stdout = new ResourceOutputStream(\fopen($this->optional, 'a+'));
|
Snitch::logFile($this->optional);
|
||||||
} elseif ($this->mode === 1) {
|
$this->stdout = new ResourceOutputStream(\fopen($this->optional, 'a'));
|
||||||
|
if ($max_size !== -1) {
|
||||||
|
$this->rotateId = Loop::repeat(
|
||||||
|
10*1000,
|
||||||
|
function () use ($max_size) {
|
||||||
|
\clearstatcache(true, $this->optional);
|
||||||
|
if (\filesize($this->optional) >= $max_size) {
|
||||||
|
$this->stdout = null;
|
||||||
|
\unlink($this->optional);
|
||||||
|
$this->stdout = new ResourceOutputStream(\fopen($this->optional, 'a'));
|
||||||
|
}
|
||||||
|
$this->logger("Automatically truncated logfile to $max_size");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
Loop::unreference($this->rotateId);
|
||||||
|
}
|
||||||
|
} elseif ($this->mode === self::DEFAULT_LOGGER) {
|
||||||
$result = @\ini_get('error_log');
|
$result = @\ini_get('error_log');
|
||||||
if ($result === 'syslog') {
|
if ($result === 'syslog') {
|
||||||
$this->stdout = getStderr();
|
$this->stdout = getStderr();
|
||||||
|
@ -213,6 +242,15 @@ class Logger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Destructor function.
|
||||||
|
*/
|
||||||
|
public function __destruct(): void
|
||||||
|
{
|
||||||
|
if ($this->rotateId) {
|
||||||
|
Loop::cancel($this->rotateId);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Log a message.
|
* Log a message.
|
||||||
*
|
*
|
||||||
|
@ -240,7 +278,7 @@ class Logger
|
||||||
*/
|
*/
|
||||||
public function logger($param, int $level = self::NOTICE, string $file = ''): void
|
public function logger($param, int $level = self::NOTICE, string $file = ''): void
|
||||||
{
|
{
|
||||||
if ($level > $this->level || $this->mode === 0) {
|
if ($level > $this->level || $this->mode === self::NO_LOGGER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!self::$printed) {
|
if (!self::$printed) {
|
||||||
|
@ -252,7 +290,7 @@ class Logger
|
||||||
$this->logger('https://github.com/danog/MadelineProto');
|
$this->logger('https://github.com/danog/MadelineProto');
|
||||||
$this->colors[self::NOTICE] = \implode(';', [self::FOREGROUND['yellow'], self::SET['bold']]);
|
$this->colors[self::NOTICE] = \implode(';', [self::FOREGROUND['yellow'], self::SET['bold']]);
|
||||||
}
|
}
|
||||||
if ($this->mode === 4) {
|
if ($this->mode === self::CALLABLE_LOGGER) {
|
||||||
\call_user_func_array($this->optional, [$param, $level]);
|
\call_user_func_array($this->optional, [$param, $level]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -266,25 +304,22 @@ class Logger
|
||||||
$file = \basename(\debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]['file'], '.php');
|
$file = \basename(\debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]['file'], '.php');
|
||||||
}
|
}
|
||||||
$param = \str_pad($file.$prefix.': ', 16 + \strlen($prefix))."\t".$param;
|
$param = \str_pad($file.$prefix.': ', 16 + \strlen($prefix))."\t".$param;
|
||||||
switch ($this->mode) {
|
if ($this->mode === self::DEFAULT_LOGGER) {
|
||||||
case 1:
|
if ($this->stdout->write($param.$this->newline) instanceof Failure) {
|
||||||
if ($this->stdout->write($param.$this->newline) instanceof Failure) {
|
\error_log($param);
|
||||||
\error_log($param);
|
}
|
||||||
}
|
return;
|
||||||
break;
|
}
|
||||||
default:
|
$param = Magic::$isatty ? "\33[".$this->colors[$level].'m'.$param."\33[0m".$this->newline : $param.$this->newline;
|
||||||
$param = Magic::$isatty ? "\33[".$this->colors[$level].'m'.$param."\33[0m".$this->newline : $param.$this->newline;
|
if ($this->stdout->write($param) instanceof Failure) {
|
||||||
if ($this->stdout->write($param) instanceof Failure) {
|
switch ($this->mode) {
|
||||||
switch ($this->mode) {
|
case self::ECHO_LOGGER:
|
||||||
case 3:
|
echo $param;
|
||||||
echo $param;
|
break;
|
||||||
break;
|
case self::FILE_LOGGER:
|
||||||
case 2:
|
\file_put_contents($this->optional, $param, FILE_APPEND);
|
||||||
\file_put_contents($this->optional, $param, FILE_APPEND);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,6 +421,11 @@ class MTProto extends AsyncConstruct implements TLCallback
|
||||||
*/
|
*/
|
||||||
private $TL;
|
private $TL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Snitch.
|
||||||
|
*/
|
||||||
|
private Snitch $snitch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of properties stored in database (memory or external).
|
* List of properties stored in database (memory or external).
|
||||||
* @see DbPropertiesFabric
|
* @see DbPropertiesFabric
|
||||||
|
@ -564,7 +569,10 @@ class MTProto extends AsyncConstruct implements TLCallback
|
||||||
'temp_rekeyed_secret_chats',
|
'temp_rekeyed_secret_chats',
|
||||||
|
|
||||||
// Report URI
|
// Report URI
|
||||||
'reportDest'
|
'reportDest',
|
||||||
|
|
||||||
|
// Packagist install report state
|
||||||
|
'packagistReported'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,6 +832,9 @@ class MTProto extends AsyncConstruct implements TLCallback
|
||||||
*/
|
*/
|
||||||
private function upgradeMadelineProto(): \Generator
|
private function upgradeMadelineProto(): \Generator
|
||||||
{
|
{
|
||||||
|
if (!isset($this->snitch)) {
|
||||||
|
$this->snitch = new Snitch;
|
||||||
|
}
|
||||||
$this->logger->logger(Lang::$current_lang['serialization_ofd'], Logger::WARNING);
|
$this->logger->logger(Lang::$current_lang['serialization_ofd'], Logger::WARNING);
|
||||||
foreach ($this->datacenter->getDataCenterConnections() as $dc_id => $socket) {
|
foreach ($this->datacenter->getDataCenterConnections() as $dc_id => $socket) {
|
||||||
if ($this->authorized === self::LOGGED_IN && \strpos($dc_id, '_') === false && $socket->hasPermAuthKey() && $socket->hasTempAuthKey()) {
|
if ($this->authorized === self::LOGGED_IN && \strpos($dc_id, '_') === false && $socket->hasPermAuthKey() && $socket->hasTempAuthKey()) {
|
||||||
|
@ -1281,10 +1292,10 @@ class MTProto extends AsyncConstruct implements TLCallback
|
||||||
*/
|
*/
|
||||||
// write to
|
// write to
|
||||||
'logger_param' => Magic::$script_cwd.'/MadelineProto.log',
|
'logger_param' => Magic::$script_cwd.'/MadelineProto.log',
|
||||||
'logger' => PHP_SAPI === 'cli' ? 3 : 2,
|
'logger' => (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') ? Logger::ECHO_LOGGER : Logger::FILE_LOGGER,
|
||||||
// overwrite previous setting and echo logs
|
// overwrite previous setting and echo logs
|
||||||
'logger_level' => Logger::VERBOSE,
|
'logger_level' => Logger::VERBOSE,
|
||||||
'max_size' => 100 * 1024 * 1024,
|
'max_size' => 10 * 1024 * 1024,
|
||||||
// Logging level, available logging levels are: ULTRA_VERBOSE, VERBOSE, NOTICE, WARNING, ERROR, FATAL_ERROR. Can be provided as last parameter to the logging function.
|
// Logging level, available logging levels are: ULTRA_VERBOSE, VERBOSE, NOTICE, WARNING, ERROR, FATAL_ERROR. Can be provided as last parameter to the logging function.
|
||||||
], 'max_tries' => [
|
], 'max_tries' => [
|
||||||
'query' => 5,
|
'query' => 5,
|
||||||
|
|
|
@ -276,7 +276,7 @@ class Magic
|
||||||
self::$revision = 'Revision: '.self::$revision.$latest;
|
self::$revision = 'Revision: '.self::$revision.$latest;
|
||||||
}
|
}
|
||||||
self::$can_parallel = false;
|
self::$can_parallel = false;
|
||||||
if (PHP_SAPI === 'cli' && !(\class_exists(\Phar::class) && \Phar::running())) {
|
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && !(\class_exists(\Phar::class) && \Phar::running())) {
|
||||||
try {
|
try {
|
||||||
$back = \debug_backtrace(0);
|
$back = \debug_backtrace(0);
|
||||||
\define('AMP_WORKER', 1);
|
\define('AMP_WORKER', 1);
|
||||||
|
@ -330,7 +330,7 @@ class Magic
|
||||||
);
|
);
|
||||||
resolver(new Rfc8484StubResolver($DohConfig));
|
resolver(new Rfc8484StubResolver($DohConfig));
|
||||||
}*/
|
}*/
|
||||||
if (PHP_SAPI !== 'cli') {
|
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
|
||||||
try {
|
try {
|
||||||
\error_reporting(E_ALL);
|
\error_reporting(E_ALL);
|
||||||
\ini_set('log_errors', 1);
|
\ini_set('log_errors', 1);
|
||||||
|
|
|
@ -54,7 +54,7 @@ class RPCErrorException extends \Exception
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
$result = \sprintf(\danog\MadelineProto\Lang::$current_lang['rpc_tg_error'], self::localizeMessage($this->caller, $this->code, $this->message)." ({$this->code})", $this->rpc, $this->file, $this->line.PHP_EOL, \danog\MadelineProto\Magic::$revision.PHP_EOL.PHP_EOL).PHP_EOL.$this->getTLTrace().PHP_EOL;
|
$result = \sprintf(\danog\MadelineProto\Lang::$current_lang['rpc_tg_error'], self::localizeMessage($this->caller, $this->code, $this->message)." ({$this->code})", $this->rpc, $this->file, $this->line.PHP_EOL, \danog\MadelineProto\Magic::$revision.PHP_EOL.PHP_EOL).PHP_EOL.$this->getTLTrace().PHP_EOL;
|
||||||
if (PHP_SAPI !== 'cli') {
|
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
|
||||||
$result = \str_replace(PHP_EOL, '<br>'.PHP_EOL, $result);
|
$result = \str_replace(PHP_EOL, '<br>'.PHP_EOL, $result);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Exception extends \Exception
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
$result = \get_class($this).($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.\danog\MadelineProto\Magic::$revision.PHP_EOL.'TL Trace (YOU ABSOLUTELY MUST READ THE TEXT BELOW):'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL;
|
$result = \get_class($this).($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.\danog\MadelineProto\Magic::$revision.PHP_EOL.'TL Trace (YOU ABSOLUTELY MUST READ THE TEXT BELOW):'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL;
|
||||||
if (PHP_SAPI !== 'cli') {
|
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
|
||||||
$result = \str_replace(PHP_EOL, '<br>'.PHP_EOL, $result);
|
$result = \str_replace(PHP_EOL, '<br>'.PHP_EOL, $result);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Exception extends \Exception
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
$result = \get_class($this).($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.\danog\MadelineProto\Magic::$revision.PHP_EOL.'TL Trace (YOU ABSOLUTELY MUST READ THE TEXT BELOW):'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL;
|
$result = \get_class($this).($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.\danog\MadelineProto\Magic::$revision.PHP_EOL.'TL Trace (YOU ABSOLUTELY MUST READ THE TEXT BELOW):'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL;
|
||||||
if (PHP_SAPI !== 'cli') {
|
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
|
||||||
$result = \str_replace(PHP_EOL, '<br>'.PHP_EOL, $result);
|
$result = \str_replace(PHP_EOL, '<br>'.PHP_EOL, $result);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
|
|
@ -79,7 +79,7 @@ trait PrettyException
|
||||||
$previous_trace = $this->tl_trace;
|
$previous_trace = $this->tl_trace;
|
||||||
$this->tl_trace = '';
|
$this->tl_trace = '';
|
||||||
$eol = PHP_EOL;
|
$eol = PHP_EOL;
|
||||||
if (PHP_SAPI !== 'cli') {
|
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
|
||||||
$eol = '<br>'.PHP_EOL;
|
$eol = '<br>'.PHP_EOL;
|
||||||
}
|
}
|
||||||
$tl = false;
|
$tl = false;
|
||||||
|
|
|
@ -65,7 +65,7 @@ trait Loop
|
||||||
$this->loop_callback = null;
|
$this->loop_callback = null;
|
||||||
}
|
}
|
||||||
static $inited = false;
|
static $inited = false;
|
||||||
if (PHP_SAPI !== 'cli' && !$inited) {
|
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg' && !$inited) {
|
||||||
$needs_restart = true;
|
$needs_restart = true;
|
||||||
try {
|
try {
|
||||||
\set_time_limit(-1);
|
\set_time_limit(-1);
|
||||||
|
@ -206,7 +206,7 @@ trait Loop
|
||||||
*/
|
*/
|
||||||
public function closeConnection($message = 'OK!')
|
public function closeConnection($message = 'OK!')
|
||||||
{
|
{
|
||||||
if (PHP_SAPI === 'cli' || isset($GLOBALS['exited']) || \headers_sent()) {
|
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' || isset($GLOBALS['exited']) || \headers_sent()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->logger->logger($message);
|
$this->logger->logger($message);
|
||||||
|
|
|
@ -36,7 +36,7 @@ trait Start
|
||||||
if ($this->authorized === self::LOGGED_IN) {
|
if ($this->authorized === self::LOGGED_IN) {
|
||||||
return yield from $this->fullGetSelf();
|
return yield from $this->fullGetSelf();
|
||||||
}
|
}
|
||||||
if (PHP_SAPI === 'cli') {
|
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) {
|
if (\strpos(yield Tools::readLine('Do you want to login as user or bot (u/b)? '), 'b') !== false) {
|
||||||
yield from $this->botLogin(yield Tools::readLine('Enter your bot token: '));
|
yield from $this->botLogin(yield Tools::readLine('Enter your bot token: '));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -78,6 +78,8 @@ function ___install_madeline()
|
||||||
$release_branch = $release_fallback_branch;
|
$release_branch = $release_fallback_branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
\define('HAD_MADELINE_PHAR', \file_exists('madeline.phar'));
|
||||||
|
|
||||||
if (!\file_exists('madeline.phar') || !\file_exists('madeline.phar.version') || \file_get_contents('madeline.phar.version') !== $release) {
|
if (!\file_exists('madeline.phar') || !\file_exists('madeline.phar.version') || \file_get_contents('madeline.phar.version') !== $release) {
|
||||||
$phar = \file_get_contents(\sprintf($phar_template, $release_branch));
|
$phar = \file_get_contents(\sprintf($phar_template, $release_branch));
|
||||||
|
|
||||||
|
@ -117,9 +119,9 @@ function ___install_madeline()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\defined('HHVM_VERSION')) {
|
if (\defined('HHVM_VERSION')) {
|
||||||
$phpVersion = 'HHVM ' . HHVM_VERSION;
|
$phpVersion = 'HHVM '.HHVM_VERSION;
|
||||||
} else {
|
} else {
|
||||||
$phpVersion = 'PHP ' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
|
$phpVersion = 'PHP '.PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION.'.'.PHP_RELEASE_VERSION;
|
||||||
}
|
}
|
||||||
$opts = ['http' =>
|
$opts = ['http' =>
|
||||||
[
|
[
|
||||||
|
@ -140,7 +142,7 @@ function ___install_madeline()
|
||||||
'timeout' => 6,
|
'timeout' => 6,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
//@\file_get_contents("https://packagist.org/downloads/", false, \stream_context_create($opts));
|
@\file_get_contents("https://packagist.org/downloads/", false, \stream_context_create($opts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user