| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * dmarc-srg - A php parser, viewer and summary report generator for incoming DMARC reports. |
| 5 | * Copyright (C) 2020-2025 Aleksey Andreev (liuch) |
| 6 | * |
| 7 | * Available at: |
| 8 | * https://github.com/liuch/dmarc-srg |
| 9 | * |
| 10 | * This program is free software: you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License as published by the Free |
| 12 | * Software Foundation, either version 3 of the License. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 17 | * more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License along with |
| 20 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | */ |
| 22 | |
| 23 | namespace Liuch\DmarcSrg; |
| 24 | |
| 25 | use Liuch\DmarcSrg\ErrorHandler; |
| 26 | use Liuch\DmarcSrg\Exception\RuntimeException; |
| 27 | |
| 28 | require realpath(__DIR__ . '/..') . '/init.php'; |
| 29 | |
| 30 | if (Core::requestMethod() == 'POST' && Core::isJson()) { |
| 31 | $jdata = Core::getJsonData(); |
| 32 | if ($jdata && isset($jdata['password'])) { |
| 33 | try { |
| 34 | Core::sendJson( |
| 35 | Core::instance()->auth()->login(strval($jdata['username'] ?? ''), strval($jdata['password'])) |
| 36 | ); |
| 37 | } catch (RuntimeException $e) { |
| 38 | Core::sendJson(ErrorHandler::exceptionResult($e)); |
| 39 | } |
| 40 | return; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | Core::sendBad(); |