This commit is contained in:
Daniil Gentili 2018-03-23 10:14:29 +00:00
parent 838a1c0169
commit 40567ce3ec
4 changed files with 16 additions and 9 deletions

View File

@ -42,7 +42,7 @@ class API extends APIFactory
\danog\MadelineProto\Logger::log('Shared lock acquired, deserializing...');
try {
$unserialized = file_get_contents($realpaths['file']);
$tounserialize = file_get_contents($realpaths['file']);
} finally {
flock($realpaths['lockfile'], LOCK_UN);
fclose($realpaths['lockfile']);
@ -53,19 +53,19 @@ class API extends APIFactory
try {
$unserialized = unserialize($tounserialize);
} catch (\danog\MadelineProto\Bug74586Exception $e) {
$tounserialize = str_replace('O:26:"danog\\MadelineProto\\Button":', 'O:35:"danog\\MadelineProto\\TL\\Types\\Button":', $unserialized);
$tounserialize = str_replace('O:26:"danog\\MadelineProto\\Button":', 'O:35:"danog\\MadelineProto\\TL\\Types\\Button":', $tounserialize);
foreach (['RSA', 'TL\\TLMethod', 'TL\\TLConstructor', 'MTProto', 'API', 'DataCenter', 'Connection', 'TL\\Types\\Button', 'TL\\Types\\Bytes', 'APIFactory'] as $class) {
class_exists('\\danog\\MadelineProto\\'.$class);
}
$unserialized = \danog\Serialization::unserialize($tounserialize);
} catch (\danog\MadelineProto\Exception $e) {
$tounserialize = str_replace('O:26:"danog\\MadelineProto\\Button":', 'O:35:"danog\\MadelineProto\\TL\\Types\\Button":', $unserialized);
$tounserialize = str_replace('O:26:"danog\\MadelineProto\\Button":', 'O:35:"danog\\MadelineProto\\TL\\Types\\Button":', $tounserialize);
foreach (['RSA', 'TL\\TLMethod', 'TL\\TLConstructor', 'MTProto', 'API', 'DataCenter', 'Connection', 'TL\\Types\\Button', 'TL\\Types\\Bytes', 'APIFactory'] as $class) {
class_exists('\\danog\\MadelineProto\\'.$class);
}
Logger::log((string) $e, Logger::ERROR);
if (strpos($e->getMessage(), "Erroneous data format for unserializing 'phpseclib\\Math\\BigInteger'") === 0) {
$tounserialize = str_replace('phpseclib\\Math\\BigInteger', 'phpseclib\\Math\\BigIntegor', $unserialized);
$tounserialize = str_replace('phpseclib\\Math\\BigInteger', 'phpseclib\\Math\\BigIntegor', $tounserialize);
}
$unserialized = \danog\Serialization::unserialize($tounserialize);
}

View File

@ -348,6 +348,14 @@ class MTProto
public function parse_settings($settings)
{
if (!isset($settings['app_info']['api_id']) || !$settings['app_info']['api_id']) {
if (isset($this->settings['app_info']['api_id']) && $this->settings['app_info']['api_id']) {
$settings['app_info']['api_id'] = $this->settings['app_info']['api_id'];
$settings['app_info']['api_hash'] = $this->settings['app_info']['api_hash'];
} else {
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['api_not_set'], 0, null, 'MadelineProto', 1);
}
}
// Detect device model
try {
$device_model = php_uname('s');
@ -568,9 +576,6 @@ class MTProto
}
$this->settings = $settings;
if (!$this->settings['updates']['handle_updates']) $this->updates = [];
if (!isset($settings['app_info']['api_id']) || !$settings['app_info']['api_id']) {
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['api_not_set'], 0, null, 'MadelineProto', 1);
}
// Setup logger
$this->setup_logger();
}

View File

@ -19,6 +19,9 @@ class MyTelegramOrgWrapper
{
private $logged = false;
public function __construct($number) {
if (!extension_loaded('curl')) {
throw new Exception(['extension', 'curl']);
}
$this->number = $number;
$ch = curl_init();

View File

@ -46,8 +46,7 @@ trait ApiStart
$app['api_hash'] = readline('6) Enter your API hash: ');
return $app;
} else {
$this->my_telegram_org_wrapper = new \danog\MadelineProto\MyTelegramOrgWrapper();
$this->my_telegram_org_wrapper->phone_login(readline('Enter a phone number that is already registered on Telegram: '));
$this->my_telegram_org_wrapper = new \danog\MadelineProto\MyTelegramOrgWrapper(readline('Enter a phone number that is already registered on Telegram: '));
$this->my_telegram_org_wrapper->complete_login(readline('Enter the verification code you received in telegram: '));
if (!$this->my_telegram_org_wrapper->has_app()) {
$app = $this->my_telegram_org_wrapper->create_app(['app_name' => 'MadelineProto app', 'app_shortname' => 'MadelineProtoApp', 'app_url' => 'https://madelineproto.xyz', 'app_platform' => 'web', 'app_desc' => 'MadelineProto application']);