mirror of
https://github.com/getnamingo/registry.git
synced 2025-05-10 16:58:34 +02:00
Added epp poll; needs more testing once other functions are done
This commit is contained in:
parent
47ebb5a3d7
commit
1d31db8e6c
3 changed files with 108 additions and 0 deletions
|
@ -444,6 +444,8 @@ class EppWriter {
|
|||
$writer->endElement(); // End of 'resData'
|
||||
}
|
||||
}
|
||||
|
||||
$this->_postamble($writer, $resp);
|
||||
|
||||
}
|
||||
|
||||
|
|
94
epp/epp-poll.php
Normal file
94
epp/epp-poll.php
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
function processPoll($conn, $db, $xml, $clid) {
|
||||
$clTRID = (string) $xml->command->clTRID;
|
||||
$node = $xml->command->poll;
|
||||
$op = (string) $node['op'];
|
||||
|
||||
if ($op === 'ack') {
|
||||
$id = (string)$node['msgID'];
|
||||
$stmt = $db->prepare("SELECT id FROM poll WHERE registrar_id = :registrar_id AND id = :id LIMIT 1");
|
||||
$stmt->execute([':registrar_id' => $clid, ':id' => $id]);
|
||||
$ack_id = $stmt->fetchColumn();
|
||||
|
||||
if (!$ack_id) {
|
||||
$response['resultCode'] = 2303; // Object does not exist
|
||||
} else {
|
||||
$stmt = $db->prepare("DELETE FROM poll WHERE registrar_id = :registrar_id AND id = :id");
|
||||
$stmt->execute([':registrar_id' => $clid, ':id' => $id]);
|
||||
$response['resultCode'] = 1000;
|
||||
}
|
||||
} else {
|
||||
$stmt = $db->prepare("SELECT id, qdate, msg, msg_type, obj_name_or_id, obj_trStatus, obj_reID, obj_reDate, obj_acID, obj_acDate, obj_exDate, registrarName, creditLimit, creditThreshold, creditThresholdType, availableCredit FROM poll WHERE registrar_id = :registrar_id ORDER BY id ASC LIMIT 1");
|
||||
$stmt->execute([':registrar_id' => $clid]);
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$id = $result['id'] ?? null;
|
||||
$response['resultCode'] = $id ? 1301 : 1300;
|
||||
}
|
||||
|
||||
if ((int) $response['resultCode'] === 1300) {
|
||||
$response = [
|
||||
'command' => 'poll',
|
||||
'clTRID' => $clTRID,
|
||||
'svTRID' => generateSvTRID(),
|
||||
'resultCode' => $response['resultCode'],
|
||||
'msg' => 'Command completed successfully; no messages',
|
||||
];
|
||||
|
||||
$epp = new EPP\EppWriter();
|
||||
$xml = $epp->epp_writer($response);
|
||||
sendEppResponse($conn, $xml);
|
||||
return;
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("SELECT COUNT(id) AS counter FROM poll WHERE registrar_id = :registrar_id");
|
||||
$stmt->execute([':registrar_id' => $clid]);
|
||||
$counter = $stmt->fetchColumn();
|
||||
|
||||
$response = [];
|
||||
$response['command'] = 'poll';
|
||||
$response['count'] = $counter;
|
||||
$response['id'] = $id;
|
||||
$response['msg'] = $result['msg'] ?? null;
|
||||
$response['poll_msg_type'] = $result['msg_type'] ?? null;
|
||||
$response['lang'] = 'en-US';
|
||||
$qdate = str_replace(' ', 'T', $result['qdate'] ?? '') . '.0Z';
|
||||
$response['qDate'] = $qdate;
|
||||
|
||||
if ($poll_msg_type === 'lowBalance') {
|
||||
$response['registrarName'] = $registrarName;
|
||||
$response['creditLimit'] = $creditLimit;
|
||||
$response['creditThreshold'] = $creditThreshold;
|
||||
$response['creditThresholdType'] = $creditThresholdType;
|
||||
$response['availableCredit'] = $availableCredit;
|
||||
} elseif ($poll_msg_type === 'domainTransfer') {
|
||||
$response['name'] = $obj_name_or_id;
|
||||
$response['obj_trStatus'] = $obj_trStatus;
|
||||
$response['obj_reID'] = $obj_reID;
|
||||
$response['obj_reDate'] = str_replace(' ', 'T', $obj_reDate) . '.0Z';
|
||||
$response['obj_acID'] = $obj_acID;
|
||||
$response['obj_acDate'] = str_replace(' ', 'T', $obj_acDate) . '.0Z';
|
||||
if ($obj_exDate) {
|
||||
$response['obj_exDate'] = str_replace(' ', 'T', $obj_exDate) . '.0Z';
|
||||
}
|
||||
$response['obj_type'] = 'domain';
|
||||
$response['obj_id'] = $obj_name_or_id;
|
||||
} elseif ($poll_msg_type === 'contactTransfer') {
|
||||
$response['identifier'] = $obj_name_or_id;
|
||||
$response['obj_trStatus'] = $obj_trStatus;
|
||||
$response['obj_reID'] = $obj_reID;
|
||||
$response['obj_reDate'] = str_replace(' ', 'T', $obj_reDate) . '.0Z';
|
||||
$response['obj_acID'] = $obj_acID;
|
||||
$response['obj_acDate'] = str_replace(' ', 'T', $obj_acDate) . '.0Z';
|
||||
$response['obj_type'] = 'contact';
|
||||
$response['obj_id'] = $obj_name_or_id;
|
||||
}
|
||||
|
||||
$response['clTRID'] = $clTRID;
|
||||
$response['svTRID'] = generateSvTRID();
|
||||
|
||||
$epp = new EPP\EppWriter();
|
||||
$xml = $epp->epp_writer($response);
|
||||
sendEppResponse($conn, $xml);
|
||||
}
|
12
epp/epp.php
12
epp/epp.php
|
@ -9,6 +9,7 @@ require_once 'epp-check.php';
|
|||
require_once 'epp-info.php';
|
||||
require_once 'epp-create.php';
|
||||
require_once 'epp-renew.php';
|
||||
require_once 'epp-poll.php';
|
||||
|
||||
use Swoole\Coroutine\Server;
|
||||
use Swoole\Coroutine\Server\Connection;
|
||||
|
@ -133,6 +134,17 @@ $server->handle(function (Connection $conn) use ($table, $db, $c) {
|
|||
sendGreeting($conn);
|
||||
break;
|
||||
}
|
||||
|
||||
case isset($xml->command->poll):
|
||||
{
|
||||
$data = $table->get($connId);
|
||||
if (!$data || $data['logged_in'] !== 1) {
|
||||
sendEppError($conn, 2202, 'Authorization error');
|
||||
$conn->close();
|
||||
}
|
||||
processPoll($conn, $db, $xml, $data['clid']);
|
||||
break;
|
||||
}
|
||||
|
||||
case isset($xml->command->check) && isset($xml->command->check->children('urn:ietf:params:xml:ns:contact-1.0')->check):
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue