. */ namespace Liuch\DmarcSrg; use Liuch\DmarcSrg\ErrorHandler; use Liuch\DmarcSrg\Report\Report; use Liuch\DmarcSrg\Exception\RuntimeException; require 'init.php'; if (!empty($_GET['report_id']) && !empty($_GET['domain'])) { if (Core::isJson()) { try { Core::instance()->auth()->isAllowed(); if (Core::method() == 'GET') { $rep = new Report( [ 'domain' => $_GET['domain'], 'report_id' => $_GET['report_id'] ] ); $rep->fetch(); Core::sendJson([ 'report' => $rep->get() ]); return; } elseif (Core::method() == 'POST') { if ($_GET['action'] === 'set') { $jdata = Core::getJsonData(); if ($jdata && isset($jdata['name']) && isset($jdata['value'])) { $name = $jdata['name']; $value = $jdata['value']; $rep = new Report( [ 'domain' => $_GET['domain'], 'report_id' => $_GET['report_id'] ] ); Core::sendJson($rep->set($name, $value)); return; } } } } catch (RuntimeException $e) { Core::sendJson(ErrorHandler::exceptionResult($e)); return; } } elseif (Core::method() == 'GET') { Core::sendHtml(); return; } } Core::sendBad();