From f11b60ab9424a4f764adfe83c75d343c0a43b922 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 27 Feb 2018 22:25:26 +0100 Subject: [PATCH] Remove check.log check, remove session on AUTH_KEY_UNREGISTERED --- login.php | 9 ++---- updates.php | 92 ++++++++++++++++++++++++++++------------------------- 2 files changed, 52 insertions(+), 49 deletions(-) diff --git a/login.php b/login.php index 2ec26b5..bc30223 100644 --- a/login.php +++ b/login.php @@ -1,13 +1,11 @@ Già loggato. Per nuovo login, elimina il file check.log e aggiorna questa pagina."; - exit; + echo "

Già loggato. Per nuovo login, elimina il file session.madeline e aggiorna questa pagina.

"; + exit; } - register_shutdown_function('failLogin'); require '_config.php'; @@ -22,7 +20,6 @@ if(isset($_POST["code"])){ $MadelineProto->complete_2fa_login($_POST["pwd2fa"]); } echo "



LOGIN EFFETTUATO



AVVIA USERBOT

"; - file_put_contents("check.log", "ok"); $MadelineProto->serialize(); register_shutdown_function('finePagina'); exit; diff --git a/updates.php b/updates.php index 044a548..32fc0fd 100644 --- a/updates.php +++ b/updates.php @@ -1,11 +1,9 @@ session = __DIR__.'/session.madeline'; register_shutdown_function('endUpdates'); echo "

USERBOT PARTITO

"; @@ -14,54 +12,62 @@ $running = true; $offset = 0; $lastser = time(); -while($running) -{ - $updates = $MadelineProto->get_updates(['offset' => $offset]); - foreach($updates as $update) +try { + while($running) { - $offset = $update['update_id'] + 1; - - if (isset($update['update']['message']['out']) && $update['update']['message']['out'] && !$leggi_messaggi_in_uscita) { - continue; - } - $up = $update['update']['_']; - - if($up == 'updateNewMessage' or $up == 'updateNewChannelMessage') + $updates = $MadelineProto->get_updates(['offset' => $offset]); + foreach($updates as $update) { + $offset = $update['update_id'] + 1; + + if (isset($update['update']['message']['out']) && $update['update']['message']['out'] && !$leggi_messaggi_in_uscita) { + continue; + } + $up = $update['update']['_']; + + if($up == 'updateNewMessage' or $up == 'updateNewChannelMessage') + { + + if (isset($update['update']['message']['message'])){ + $msg = $update["update"]["message"]["message"]; + } + + if (isset($update['update']['message']['to_id']['channel_id'])) { + $chatID = $update['update']['message']['to_id']['channel_id']; + $chatID = '-100'.$chatID; + $type = "supergruppo"; + } + + if (isset($update['update']['message']['to_id']['chat_id'])) { + $chatID = $update['update']['message']['to_id']['chat_id']; + $chatID = '-'.$chatID; + $type = "gruppo"; + } + + if (isset($update['update']['message']['from_id'])) $userID = $update['update']['message']['from_id']; + + if (isset($update['update']['message']['to_id']['user_id'])) { + $chatID = $update['update']['message']['from_id']; + $type = "privato"; + } + + @include("_comandi.php"); - if (isset($update['update']['message']['message'])){ - $msg = $update["update"]["message"]["message"]; } - if (isset($update['update']['message']['to_id']['channel_id'])) { - $chatID = $update['update']['message']['to_id']['channel_id']; - $chatID = '-100'.$chatID; - $type = "supergruppo"; - } - if (isset($update['update']['message']['to_id']['chat_id'])) { - $chatID = $update['update']['message']['to_id']['chat_id']; - $chatID = '-'.$chatID; - $type = "gruppo"; - } - - if (isset($update['update']['message']['from_id'])) $userID = $update['update']['message']['from_id']; - - if (isset($update['update']['message']['to_id']['user_id'])) { - $chatID = $update['update']['message']['from_id']; - $type = "privato"; - } - - @include("_comandi.php"); + if(isset($msg)) unset($msg); + if(isset($chatID)) unset($chatID); + if(isset($userID)) unset($userID); + if(isset($up)) unset($up); } - - - if(isset($msg)) unset($msg); - if(isset($chatID)) unset($chatID); - if(isset($userID)) unset($userID); - if(isset($up)) unset($up); - - } +} catch (\danog\MadelineProto\RPCErrorException $e) { + \danog\MadelineProto\Logger::log([(string)$e]); + if (in_array($e->rpc, ['SESSION_REVOKED', 'AUTH_KEY_UNREGISTERED'])) { + foreach (glob('session.madeline*') as $path) { + unlink($path); + } + } }