forked from pwrtelegram/pwrtelegram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
61 lines (58 loc) · 3.58 KB
/
index.php
File metadata and controls
61 lines (58 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/*
Copyright 2016 Daniil Gentili
(https://daniil.it)
This file is part of the PWRTelegram API.
the PWRTelegram API is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The PWRTelegram API is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License along with the PWRTelegram API.
If not, see <http://www.gnu.org/licenses/>.
*/
ini_set('log_errors', 1);
ini_set('error_log', '/tmp/php-error-index.log');
set_time_limit(0);
ignore_user_abort(1);
require_once 'src/PWRTelegram/PWRTelegram/Tools.php';
require_once 'src/PWRTelegram/PWRTelegram/API.php';
require_once 'src/PWRTelegram/PWRTelegram/Proxy.php';
require_once 'src/PWRTelegram/PWRTelegram/Main.php';
require_once '../storage_url.php';
require_once '../db_connect.php';
$pwrhomedir = realpath(__DIR__);
$API = new \PWRTelegram\PWRTelegram\Main($GLOBALS);
try {
$API->run();
} catch (\danog\MadelineProto\ResponseException $e) {
echo json_encode(['ok' => false, 'error_code' => 400, 'description' => $e->getMessage().' on line '.$e->getLine().' of '.basename($e->getFile())]);
error_log('Exception thrown: '.$e->getMessage().' on line '.$e->getLine().' of '.basename($e->getFile()));
error_log($e->getTraceAsString());
} catch (\danog\MadelineProto\Exception $e) {
echo json_encode(['ok' => false, 'error_code' => 400, 'description' => $e->getMessage().' on line '.$e->getLine().' of '.basename($e->getFile())]);
error_log('Exception thrown: '.$e->getMessage().' on line '.$e->getLine().' of '.basename($e->getFile()));
error_log($e->getTraceAsString());
} catch (\danog\MadelineProto\RPCErrorException $e) {
if ($e->getMessage() === 'SESSION_REVOKED') {
unlink($API->madeline_path);
}
if (preg_match('|FLOOD_WAIT_|', $e->getMessage())) {
$n = preg_replace('|\D|', '', $e->getMessage());
echo json_encode(['ok' => false, 'error_code' => 429, 'description' => 'Too Many Requests: retry after '.$n, 'params' => ['retry_after' => $n]]);
} else {
echo json_encode(['ok' => false, 'error_code' => $e->getCode(), 'description' => $e->getMessage()]);
}
error_log('Exception thrown: '.$e->getMessage().' on line '.$e->getLine().' of '.basename($e->getFile()));
error_log($e->getTraceAsString());
} catch (\danog\MadelineProto\TL\Exception $e) {
echo json_encode(['ok' => false, 'error_code' => 400, 'description' => $e->getMessage().' on line '.$e->getLine().' of '.basename($e->getFile())]);
error_log('Exception thrown: '.$e->getMessage().' on line '.$e->getLine().' of '.basename($e->getFile()));
error_log($e->getTraceAsString());
} catch (\PDOException $e) {
echo json_encode(['ok' => false, 'error_code' => 400, 'description' => $e->getMessage().' on line '.$e->getLine().' of '.basename($e->getFile())]);
error_log('Exception thrown: '.$e->getMessage().' on line '.$e->getLine().' of '.basename($e->getFile()));
error_log($e->getTraceAsString());
} catch (\Exception $e) {
echo json_encode(['ok' => false, 'error_code' => 400, 'description' => $e->getMessage().' on line '.$e->getLine().' of '.basename($e->getFile())]);
error_log('Exception thrown: '.$e->getMessage().' on line '.$e->getLine().' of '.basename($e->getFile()));
error_log($e->getTraceAsString());
}