mirror of
https://github.com/getnamingo/registry.git
synced 2025-08-02 07:41:49 +02:00
Added basic contact, host, registrar history pages
This commit is contained in:
parent
5e49fbc2bb
commit
cae51f7cd0
10 changed files with 549 additions and 2 deletions
|
@ -881,6 +881,57 @@ class ContactsController extends Controller
|
|||
|
||||
}
|
||||
|
||||
public function historyContact(Request $request, Response $response, $args)
|
||||
{
|
||||
if (envi('MINIMUM_DATA') === 'true') {
|
||||
return $response->withHeader('Location', '/dashboard')->withStatus(302);
|
||||
}
|
||||
|
||||
$db = $this->container->get('db');
|
||||
$db_audit = $this->container->get('db_audit');
|
||||
// Get the current URI
|
||||
$uri = $request->getUri()->getPath();
|
||||
|
||||
if ($args) {
|
||||
$args = trim($args);
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9\-]+$/', $args)) {
|
||||
$this->container->get('flash')->addMessage('error', 'Invalid contact ID format');
|
||||
return $response->withHeader('Location', '/contacts')->withStatus(302);
|
||||
}
|
||||
|
||||
try {
|
||||
$exists = $db_audit->selectValue('SELECT 1 FROM domain LIMIT 1');
|
||||
} catch (\PDOException $e) {
|
||||
throw new \RuntimeException('Audit table is empty or not configured');
|
||||
}
|
||||
|
||||
$contact = $db->selectRow('SELECT id, identifier FROM contact WHERE identifier = ?',
|
||||
[ $args ]);
|
||||
|
||||
if ($contact) {
|
||||
$history = $db_audit->select(
|
||||
'SELECT * FROM contact WHERE identifier = ? ORDER BY audit_timestamp DESC, audit_rownum ASC',
|
||||
[$args]
|
||||
);
|
||||
|
||||
return view($response,'admin/contacts/historyContact.twig', [
|
||||
'contact' => $contact,
|
||||
'history' => $history,
|
||||
'currentUri' => $uri
|
||||
]);
|
||||
} else {
|
||||
// Contact does not exist, redirect to the contacts view
|
||||
return $response->withHeader('Location', '/contacts')->withStatus(302);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Redirect to the contacts view
|
||||
return $response->withHeader('Location', '/contacts')->withStatus(302);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function updateContact(Request $request, Response $response, $args)
|
||||
{
|
||||
if (envi('MINIMUM_DATA') === 'true') {
|
||||
|
|
|
@ -297,7 +297,57 @@ class HostsController extends Controller
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function historyHost(Request $request, Response $response, $args)
|
||||
{
|
||||
$db = $this->container->get('db');
|
||||
$db_audit = $this->container->get('db_audit');
|
||||
// Get the current URI
|
||||
$uri = $request->getUri()->getPath();
|
||||
|
||||
if ($args && isValidHostname($args)) {
|
||||
$args = trim($args);
|
||||
|
||||
if (mb_detect_encoding($args, 'ASCII', true) === false) {
|
||||
$args = idn_to_ascii($args, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
|
||||
if ($args === false) {
|
||||
// Redirect to the hosts view
|
||||
return $response->withHeader('Location', '/hosts')->withStatus(302);
|
||||
}
|
||||
}
|
||||
|
||||
$host = $db->selectRow('SELECT id, name FROM host WHERE name = ?',
|
||||
[ $args ]);
|
||||
|
||||
if ($host) {
|
||||
try {
|
||||
$exists = $db_audit->selectValue('SELECT 1 FROM domain LIMIT 1');
|
||||
} catch (\PDOException $e) {
|
||||
throw new \RuntimeException('Audit table is empty or not configured');
|
||||
}
|
||||
|
||||
$history = $db_audit->select(
|
||||
'SELECT * FROM host WHERE name = ? ORDER BY audit_timestamp DESC, audit_rownum ASC',
|
||||
[$args]
|
||||
);
|
||||
|
||||
return view($response,'admin/hosts/historyHost.twig', [
|
||||
'host' => $host,
|
||||
'history' => $history,
|
||||
'currentUri' => $uri
|
||||
]);
|
||||
} else {
|
||||
// Host does not exist, redirect to the hosts view
|
||||
return $response->withHeader('Location', '/hosts')->withStatus(302);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Redirect to the hosts view
|
||||
return $response->withHeader('Location', '/hosts')->withStatus(302);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function updateHost(Request $request, Response $response, $args)
|
||||
{
|
||||
$db = $this->container->get('db');
|
||||
|
|
|
@ -407,7 +407,54 @@ class RegistrarsController extends Controller
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function historyRegistrar(Request $request, Response $response, $args)
|
||||
{
|
||||
$db = $this->container->get('db');
|
||||
$db_audit = $this->container->get('db_audit');
|
||||
// Get the current URI
|
||||
$uri = $request->getUri()->getPath();
|
||||
|
||||
if ($args) {
|
||||
$args = trim(preg_replace('/\s+/', ' ', $args));
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9\s.\-]+$/', $args)) {
|
||||
$this->container->get('flash')->addMessage('error', 'Invalid registrar');
|
||||
return $response->withHeader('Location', '/registrars')->withStatus(302);
|
||||
}
|
||||
|
||||
$registrar = $db->selectRow('SELECT id,name,clid FROM registrar WHERE clid = ?',
|
||||
[ $args ]);
|
||||
|
||||
if ($registrar) {
|
||||
try {
|
||||
$exists = $db_audit->selectValue('SELECT 1 FROM domain LIMIT 1');
|
||||
} catch (\PDOException $e) {
|
||||
throw new \RuntimeException('Audit table is empty or not configured');
|
||||
}
|
||||
|
||||
$history = $db_audit->select(
|
||||
'SELECT * FROM registrar WHERE clid = ? ORDER BY audit_timestamp DESC, audit_rownum ASC LIMIT 200',
|
||||
[$args]
|
||||
);
|
||||
|
||||
return view($response,'admin/registrars/historyRegistrar.twig', [
|
||||
'registrar' => $registrar,
|
||||
'history' => $history,
|
||||
'currentUri' => $uri
|
||||
]);
|
||||
} else {
|
||||
// Registrar does not exist, redirect to the registrars view
|
||||
return $response->withHeader('Location', '/registrars')->withStatus(302);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Redirect to the registrars view
|
||||
return $response->withHeader('Location', '/registrars')->withStatus(302);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function registrar(Request $request, Response $response)
|
||||
{
|
||||
$db = $this->container->get('db');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue