mirror of
https://github.com/danog/telerpc.git
synced 2024-11-26 12:04:47 +01:00
Add more global codes
This commit is contained in:
parent
0262a6c326
commit
d16e275a29
21
src/Main.php
21
src/Main.php
@ -199,12 +199,13 @@ final class Main
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$allowed = ['SESSION_PASSWORD_NEEDED' => true, 'BOT_METHOD_INVALID' => true];
|
|
||||||
|
|
||||||
$q = $this->pdo->prepare('SELECT error, method FROM errors');
|
$q = $this->pdo->prepare('SELECT error, method FROM errors');
|
||||||
$q->execute();
|
$q->execute();
|
||||||
$r = $q->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_GROUP);
|
$r = $q->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_GROUP);
|
||||||
foreach ($r as $error => $methods) {
|
foreach (array_merge($r, self::GLOBAL_CODES) as $error => $methods) {
|
||||||
|
if (is_int($methods)) {
|
||||||
|
$methods = [];
|
||||||
|
}
|
||||||
$anyok = false;
|
$anyok = false;
|
||||||
foreach ($methods as $method) {
|
foreach ($methods as $method) {
|
||||||
if (RPCErrorException::isBad($error, 0, $method)) {
|
if (RPCErrorException::isBad($error, 0, $method)) {
|
||||||
@ -218,7 +219,6 @@ final class Main
|
|||||||
if (!$anyok) {
|
if (!$anyok) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$allowed[$error] = true;
|
|
||||||
|
|
||||||
$q = $this->pdo->prepare('SELECT description FROM error_descriptions WHERE error=?');
|
$q = $this->pdo->prepare('SELECT description FROM error_descriptions WHERE error=?');
|
||||||
$q->execute([$error]);
|
$q->execute([$error]);
|
||||||
@ -239,19 +239,6 @@ final class Main
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$q = $this->pdo->prepare('SELECT error FROM error_descriptions');
|
|
||||||
$q->execute();
|
|
||||||
$r = $q->fetchAll(PDO::FETCH_COLUMN);
|
|
||||||
foreach ($r as $error) {
|
|
||||||
if (!isset($allowed[$error])) {
|
|
||||||
$q = $this->pdo->prepare('DELETE FROM errors WHERE error=?');
|
|
||||||
$q->execute([$error]);
|
|
||||||
$q = $this->pdo->prepare('DELETE FROM error_descriptions WHERE error=?');
|
|
||||||
$q->execute([$error]);
|
|
||||||
echo 'Delete '.$error."\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = $this->v2();
|
$r = $this->v2();
|
||||||
\file_put_contents('data/v2.json', \json_encode(['ok' => true, 'result' => $r]));
|
\file_put_contents('data/v2.json', \json_encode(['ok' => true, 'result' => $r]));
|
||||||
[$r, $hr] = $this->v3();
|
[$r, $hr] = $this->v3();
|
||||||
|
Loading…
Reference in New Issue
Block a user