mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-23 04:51:13 +01:00
Display performance warnings in the login UI
This commit is contained in:
parent
64de1c0242
commit
42f5eb04cd
@ -117,6 +117,7 @@
|
||||
"long_not_64": "Given value is not 64 bytes long",
|
||||
"array_invalid": "You didn't provide a valid array",
|
||||
"predicate_not_set": "Predicate (value under _) was not set!",
|
||||
"update_madelineproto": "You're running an old version of MadelineProto, an update is required!",
|
||||
"type_extract_error": "Could not extract type \"%s\", you should update MadelineProto!",
|
||||
"method_not_found": "Could not find method: ",
|
||||
"params_missing": "Missing required parameter",
|
||||
|
@ -23,6 +23,7 @@ namespace danog\MadelineProto\ApiWrappers;
|
||||
use danog\MadelineProto\Exception;
|
||||
use danog\MadelineProto\Lang;
|
||||
use danog\MadelineProto\Magic;
|
||||
use danog\MadelineProto\MTProto;
|
||||
use danog\MadelineProto\Settings;
|
||||
use danog\MadelineProto\Tools;
|
||||
|
||||
@ -84,7 +85,8 @@ trait Start
|
||||
private function webAPIEcho(Settings $settings, string $message = ''): void
|
||||
{
|
||||
$message = \htmlentities($message);
|
||||
$title = \htmlentities(Lang::$current_lang['apiManualWeb']);
|
||||
$title = MTProto::getWebWarnings();
|
||||
$title .= \htmlentities(Lang::$current_lang['apiManualWeb']);
|
||||
$title .= "<br>";
|
||||
$title .= \sprintf(Lang::$current_lang['apiChooseManualAutoTipWeb'], 'https://docs.madelineproto.xyz/docs/SETTINGS.html');
|
||||
$title .= "<br><b>$message</b>";
|
||||
|
@ -1624,7 +1624,7 @@ final class MTProto implements TLCallback, LoggerGetter
|
||||
{
|
||||
Logger::log($message);
|
||||
|
||||
$warning = '';
|
||||
$warning = $this->getWebWarnings();
|
||||
if ($this->hasEventHandler()) {
|
||||
if (!$this->hasReportPeers()) {
|
||||
Logger::log('!!! '.Lang::$current_lang['noReportPeers'].' !!!', Logger::FATAL_ERROR);
|
||||
@ -1647,13 +1647,25 @@ final class MTProto implements TLCallback, LoggerGetter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "<html><body><h1>$message</h1>$warning</body></html>";
|
||||
}
|
||||
/**
|
||||
* Get various warnings to show to the user in the web UI.
|
||||
*/
|
||||
public static function getWebWarnings(): string
|
||||
{
|
||||
$warning = '';
|
||||
if (Magic::$version !== Magic::$version_latest) {
|
||||
$warning .= "<h2 style='color:red;'>".htmlentities(Lang::$current_lang['update_madelineproto']).'</h2>';
|
||||
}
|
||||
if (!Magic::$hasOpenssl) {
|
||||
$warning .= "<h2 style='color:red;'>".\htmlentities(\sprintf(Lang::$current_lang['extensionRecommended'], 'openssl'))."</h2>";
|
||||
}
|
||||
if (!\extension_loaded('gmp')) {
|
||||
$warning .= "<h2 style='color:red;'>".\htmlentities(\sprintf(Lang::$current_lang['extensionRecommended'], 'gmp'))."</h2>";
|
||||
}
|
||||
return "<html><body><h1>$message</h1>$warning</body></html>";
|
||||
return $warning;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,6 +27,7 @@ use danog\MadelineProto\API;
|
||||
use danog\MadelineProto\Exception;
|
||||
use danog\MadelineProto\Ipc\Client;
|
||||
use danog\MadelineProto\Lang;
|
||||
use danog\MadelineProto\MTProto;
|
||||
use danog\MadelineProto\RPCErrorException;
|
||||
use danog\MadelineProto\Settings;
|
||||
use danog\MadelineProto\TL\Types\LoginQrCode;
|
||||
@ -289,7 +290,7 @@ trait Start
|
||||
return;
|
||||
}
|
||||
$title = \htmlentities($title);
|
||||
$message = \htmlentities($message);
|
||||
$message = \htmlentities($message).MTProto::getWebWarnings();
|
||||
getOutputBufferStream()->write(\sprintf(
|
||||
$this->getSettings()->getTemplates()->getHtmlTemplate(),
|
||||
"$title<br><b>$message</b>",
|
||||
|
Loading…
x
Reference in New Issue
Block a user