diff --git a/langs/en.json b/langs/en.json index bc5ede1e7..46841a56f 100644 --- a/langs/en.json +++ b/langs/en.json @@ -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", diff --git a/src/ApiWrappers/Start.php b/src/ApiWrappers/Start.php index d246ff6c8..82f685221 100644 --- a/src/ApiWrappers/Start.php +++ b/src/ApiWrappers/Start.php @@ -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 .= "
"; $title .= \sprintf(Lang::$current_lang['apiChooseManualAutoTipWeb'], 'https://docs.madelineproto.xyz/docs/SETTINGS.html'); $title .= "
$message"; diff --git a/src/MTProto.php b/src/MTProto.php index f76b6382d..a837be87d 100644 --- a/src/MTProto.php +++ b/src/MTProto.php @@ -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 "

$message

$warning"; + } + /** + * 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 .= "

".htmlentities(Lang::$current_lang['update_madelineproto']).'

'; + } if (!Magic::$hasOpenssl) { $warning .= "

".\htmlentities(\sprintf(Lang::$current_lang['extensionRecommended'], 'openssl'))."

"; } if (!\extension_loaded('gmp')) { $warning .= "

".\htmlentities(\sprintf(Lang::$current_lang['extensionRecommended'], 'gmp'))."

"; } - return "

$message

$warning"; + return $warning; } /** diff --git a/src/Wrappers/Start.php b/src/Wrappers/Start.php index 02cf2cc40..ffab55b80 100644 --- a/src/Wrappers/Start.php +++ b/src/Wrappers/Start.php @@ -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
$message",