mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-22 18:51:13 +01:00
Final fixes
This commit is contained in:
parent
bd8602c57d
commit
0016c68a7c
@ -156,6 +156,7 @@ final class Lang
|
||||
'signupWeb' => 'Registrazione',
|
||||
'go' => 'Vai',
|
||||
'loginChoosePromptWeb' => 'Vuoi effettuare il login come utente o come bot?',
|
||||
'loginWebQr' => 'Puoi anche effettuare il login automaticamente scansionando il seguente codice QR:',
|
||||
'loginOptionBot' => 'Bot',
|
||||
'loginOptionUser' => 'Utente',
|
||||
'loginBotTokenWeb' => 'Token del bot',
|
||||
@ -175,6 +176,7 @@ final class Lang
|
||||
[
|
||||
'go' => 'Go',
|
||||
'loginChoosePromptWeb' => 'Do you want to login as a user or as a bot?',
|
||||
'loginWebQr' => 'You can also login automatically by scanning the following QR code:',
|
||||
'loginOptionBot' => 'Bot',
|
||||
'loginOptionUser' => 'User',
|
||||
'apiChooseManualAutoTip' => 'Note that you can also provide the API ID/hash directly in the code using the settings: %s',
|
||||
|
@ -123,7 +123,7 @@ trait Start
|
||||
if (isset($_POST['password'])) {
|
||||
$this->webComplete2faLogin();
|
||||
} else {
|
||||
$this->webEcho(Lang::$current_lang['loginNoPass']);
|
||||
$this->webEcho(Lang::$current_lang['loginUserPassWeb']);
|
||||
}
|
||||
} elseif ($this->getAuthorization() === MTProto::WAITING_SIGNUP) {
|
||||
if (isset($_POST['first_name'])) {
|
||||
|
@ -54,13 +54,14 @@ trait Templates
|
||||
$token = \htmlentities(Lang::$current_lang['loginBotTokenWeb']);
|
||||
$form = "<input type='text' name='token' placeholder='$token' required/>";
|
||||
}
|
||||
} elseif (isset($_GET['waitQrCodeOrLogin'])) {
|
||||
} elseif (isset($_GET['waitQrCodeOrLogin']) || isset($_GET['getQrCode'])) {
|
||||
header('Content-type: application/json');
|
||||
try {
|
||||
/** @var ?LoginQrCode */
|
||||
$qr = $this->qrLogin()?->waitForLoginOrQrCodeExpiration(new TimeoutCancellation(
|
||||
5.0
|
||||
));
|
||||
$qr = $this->qrLogin();
|
||||
if (isset($_GET['waitQrCodeOrLogin'])) {
|
||||
$qr = $qr?->waitForLoginOrQrCodeExpiration(new TimeoutCancellation(5.0));
|
||||
}
|
||||
} catch (CancelledException) {
|
||||
/** @var ?LoginQrCode */
|
||||
$qr = $this->qrLogin();
|
||||
@ -81,13 +82,29 @@ trait Templates
|
||||
$title = Lang::$current_lang['loginChoosePromptWeb'];
|
||||
$optionBot = \htmlentities(Lang::$current_lang['loginOptionBot']);
|
||||
$optionUser = \htmlentities(Lang::$current_lang['loginOptionUser']);
|
||||
$trailer = '<div id="qr-code"></div><script>
|
||||
var x = new XMLHttpRequest();
|
||||
x.onload = function() {
|
||||
document.getElementById("demo").innerHTML = this.responseText;
|
||||
}
|
||||
x.open("GET", "?waitQrCodeOrLogin", true);
|
||||
x.send();
|
||||
$trailer = '
|
||||
<div id="qr-code-container" style="display: none">
|
||||
<p>'.htmlentities(Lang::$current_lang['loginWebQr']).'</p>
|
||||
<div id="qr-code"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function longPollQr(query) {
|
||||
var x = new XMLHttpRequest();
|
||||
x.onload = function() {
|
||||
var res = JSON.parse(this.responseText);
|
||||
if (res.logged_in) {
|
||||
location.reload();
|
||||
} else {
|
||||
document.getElementById("qr-code-container").style = "";
|
||||
document.getElementById("qr-code").innerHTML = res.svg;
|
||||
longPollQr("waitQrCodeOrLogin");
|
||||
}
|
||||
};
|
||||
x.open("GET", "'.(\explode('?', $_SERVER['REQUEST_URI'], 2)[0] ?? '').'?"+query, true);
|
||||
x.send();
|
||||
}
|
||||
longPollQr("getQrCode");
|
||||
</script>';
|
||||
$form = "<select name='type'><option value='phone'>$optionUser</option><option value='bot'>$optionBot</option></select>";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user