Updates to EPP server to match RST

This commit is contained in:
Pinga 2025-06-27 17:29:59 +03:00
parent 8ac4875c9c
commit 98ae5dc19c

View file

@ -21,6 +21,9 @@ use Swoole\Timer;
use Swoole\Coroutine\Server; use Swoole\Coroutine\Server;
use Swoole\Coroutine\Server\Connection; use Swoole\Coroutine\Server\Connection;
use Namingo\Rately\Rately; use Namingo\Rately\Rately;
use Selective\XmlDSig\PublicKeyStore;
use Selective\XmlDSig\CryptoVerifier;
use Selective\XmlDSig\XmlSignatureVerifier;
$table = new Table(1024); $table = new Table(1024);
$table->column('clid', Table::TYPE_STRING, 64); $table->column('clid', Table::TYPE_STRING, 64);
@ -150,77 +153,109 @@ $server->handle(function (Connection $conn) use ($table, $eppExtensionsTable, $p
$conn->close(); $conn->close();
break; break;
} }
$data = $conn->recv();
$connId = spl_object_id($conn); $connId = spl_object_id($conn);
if ($data === false || strlen($data) < 4) { static $buffer = '';
sendEppError($conn, $pdo, 2000, 'Invalid or no data received');
$chunk = $conn->recv();
if ($chunk === '' || $chunk === false) {
$conn->close(); $conn->close();
break; break;
} }
$buffer .= $chunk;
$length = unpack('N', substr($data, 0, 4))[1]; while (strlen($buffer) >= 4) {
$xmlData = substr($data, 4, $length - 4); $len = unpack('N', substr($buffer, 0, 4))[1];
if ($len < 5) {
sendEppError($conn, $pdo, 2000, 'Invalid frame length');
$conn->close();
break 2;
}
if (strlen($buffer) < $len) {
break;
}
// If you're using PHP < 8.0 $xmlData = substr($buffer, 4, $len - 4);
libxml_disable_entity_loader(true); $buffer = substr($buffer, $len);
libxml_use_internal_errors(true);
$xml = simplexml_load_string($xmlData); // If you're using PHP < 8.0
if ($xml === false) { libxml_disable_entity_loader(true);
sendEppError($conn, $pdo, 2001, 'Invalid XML syntax'); libxml_use_internal_errors(true);
continue;
}
$xml->registerXPathNamespace('e', 'urn:ietf:params:xml:ns:epp-1.0'); $xml = simplexml_load_string($xmlData);
$xml->registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance'); if ($xml === false) {
$xml->registerXPathNamespace('domain', 'urn:ietf:params:xml:ns:domain-1.0'); sendEppError($conn, $pdo, 2001, 'Invalid XML syntax');
$xml->registerXPathNamespace('contact', 'urn:ietf:params:xml:ns:contact-1.0'); continue;
$xml->registerXPathNamespace('host', 'urn:ietf:params:xml:ns:host-1.0'); }
$xml->registerXPathNamespace('rgp', 'urn:ietf:params:xml:ns:rgp-1.0');
$xml->registerXPathNamespace('secDNS', 'urn:ietf:params:xml:ns:secDNS-1.1');
$xml->registerXPathNamespace('launch', 'urn:ietf:params:xml:ns:launch-1.0');
$xml->registerXPathNamespace('fee', 'urn:ietf:params:xml:ns:epp:fee-1.0');
$xml->registerXPathNamespace('mark', 'urn:ietf:params:xml:ns:mark-1.0');
$xml->registerXPathNamespace('allocationToken', 'urn:ietf:params:xml:ns:allocationToken-1.0');
if ($xml->getName() != 'epp') { $xml->registerXPathNamespace('e', 'urn:ietf:params:xml:ns:epp-1.0');
sendEppError($conn, $pdo, 2001, 'Root element must be <epp>'); $xml->registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
continue; $xml->registerXPathNamespace('domain', 'urn:ietf:params:xml:ns:domain-1.0');
} $xml->registerXPathNamespace('contact', 'urn:ietf:params:xml:ns:contact-1.0');
$xml->registerXPathNamespace('host', 'urn:ietf:params:xml:ns:host-1.0');
$xml->registerXPathNamespace('rgp', 'urn:ietf:params:xml:ns:rgp-1.0');
$xml->registerXPathNamespace('secDNS', 'urn:ietf:params:xml:ns:secDNS-1.1');
$xml->registerXPathNamespace('launch', 'urn:ietf:params:xml:ns:launch-1.0');
$xml->registerXPathNamespace('fee', 'urn:ietf:params:xml:ns:epp:fee-1.0');
$xml->registerXPathNamespace('mark', 'urn:ietf:params:xml:ns:mark-1.0');
$xml->registerXPathNamespace('allocationToken', 'urn:ietf:params:xml:ns:allocationToken-1.0');
switch (true) { if ($xml->getName() != 'epp') {
case isset($xml->command->login): sendEppError($conn, $pdo, 2001, 'Root element must be <epp>');
{ continue;
$clID = (string) $xml->command->login->clID; }
$pw = (string) $xml->command->login->pw;
$clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $clID);
if (!$clid) {
sendEppError($conn, $pdo, 2201, 'Unknown client identifier', $clTRID);
break;
}
$xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (checkLogin($pdo, $clID, $pw)) { switch (true) {
if (isset($xml->command->login->newPW)) { case isset($xml->command->login):
$newPW = (string) $xml->command->login->newPW; {
$options = [ $clID = (string) $xml->command->login->clID;
'memory_cost' => 1024 * 128, $pw = (string) $xml->command->login->pw;
'time_cost' => 6, $clTRID = (string) $xml->command->clTRID;
'threads' => 4, $clid = getClid($pdo, $clID);
]; if (!$clid) {
$hashedPassword = password_hash($newPW, PASSWORD_ARGON2ID, $options); sendEppError($conn, $pdo, 2201, 'Unknown client identifier', $clTRID);
try { break;
$stmt = $pdo->prepare("UPDATE registrar SET pw = :newPW WHERE clid = :clID"); }
$stmt->bindParam(':newPW', $hashedPassword); $xmlString = $xml->asXML();
$stmt->bindParam(':clID', $clID); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
$stmt->execute();
} catch (PDOException $e) { if (checkLogin($pdo, $clID, $pw)) {
sendEppError($conn, $pdo, 2400, 'Password could not be changed', $clTRID); if (isset($xml->command->login->newPW)) {
$newPW = (string) $xml->command->login->newPW;
$options = [
'memory_cost' => 1024 * 128,
'time_cost' => 6,
'threads' => 4,
];
$hashedPassword = password_hash($newPW, PASSWORD_ARGON2ID, $options);
try {
$stmt = $pdo->prepare("UPDATE registrar SET pw = :newPW WHERE clid = :clID");
$stmt->bindParam(':newPW', $hashedPassword);
$stmt->bindParam(':clID', $clID);
$stmt->execute();
} catch (PDOException $e) {
sendEppError($conn, $pdo, 2400, 'Password could not be changed', $clTRID);
}
$svTRID = generateSvTRID();
$response = [
'command' => 'login',
'resultCode' => 1000,
'lang' => 'en-US',
'clTRID' => $clTRID,
'svTRID' => $svTRID,
'msg' => 'Password changed successfully. Session will be terminated'
];
$epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response);
updateTransaction($pdo, 'login', null, null, 1000, 'Password changed successfully. Session will be terminated', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml);
$conn->close();
break;
} }
$table->set($connId, ['clid' => $clID, 'logged_in' => 1]);
$svTRID = generateSvTRID(); $svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'login', 'command' => 'login',
@ -228,22 +263,31 @@ $server->handle(function (Connection $conn) use ($table, $eppExtensionsTable, $p
'lang' => 'en-US', 'lang' => 'en-US',
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => $svTRID, 'svTRID' => $svTRID,
'msg' => 'Password changed successfully. Session will be terminated'
]; ];
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
updateTransaction($pdo, 'login', null, null, 1000, 'Password changed successfully. Session will be terminated', $svTRID, $xml, $trans); $log->info('registrar ' . $clID . ' logged in');
updateTransaction($pdo, 'login', null, null, 1000, 'Command completed successfully', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
$conn->close(); } else {
break; sendEppError($conn, $pdo, 2200, 'Authentication error', $clTRID);
} }
break;
}
$table->set($connId, ['clid' => $clID, 'logged_in' => 1]); case isset($xml->command->logout):
{
$data = $table->get($connId);
$clid = getClid($pdo, $clID);
$table->del($connId);
$clTRID = (string) $xml->command->clTRID;
$xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
$svTRID = generateSvTRID(); $svTRID = generateSvTRID();
$response = [ $response = [
'command' => 'login', 'command' => 'logout',
'resultCode' => 1000, 'resultCode' => 1500,
'lang' => 'en-US', 'lang' => 'en-US',
'clTRID' => $clTRID, 'clTRID' => $clTRID,
'svTRID' => $svTRID, 'svTRID' => $svTRID,
@ -251,375 +295,348 @@ $server->handle(function (Connection $conn) use ($table, $eppExtensionsTable, $p
$epp = new EPP\EppWriter(); $epp = new EPP\EppWriter();
$xml = $epp->epp_writer($response); $xml = $epp->epp_writer($response);
$log->info('registrar ' . $clID . ' logged in'); $log->info('registrar ' . $clID . ' logged out');
updateTransaction($pdo, 'login', null, null, 1000, 'Command completed successfully', $svTRID, $xml, $trans); updateTransaction($pdo, 'logout', null, null, 1500, 'Command completed successfully; ending session', $svTRID, $xml, $trans);
sendEppResponse($conn, $xml); sendEppResponse($conn, $xml);
} else { $conn->close();
sendEppError($conn, $pdo, 2200, 'Authentication error', $clTRID); break;
} }
break;
}
case isset($xml->command->logout): case isset($xml->hello):
{ {
$data = $table->get($connId); sendGreeting($conn, $eppExtensionsTable);
$clid = getClid($pdo, $clID); break;
$table->del($connId); }
$clTRID = (string) $xml->command->clTRID;
$xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
$svTRID = generateSvTRID();
$response = [
'command' => 'logout',
'resultCode' => 1500,
'lang' => 'en-US',
'clTRID' => $clTRID,
'svTRID' => $svTRID,
];
$epp = new EPP\EppWriter(); case isset($xml->command->poll):
$xml = $epp->epp_writer($response); {
$log->info('registrar ' . $clID . ' logged out'); $data = $table->get($connId);
updateTransaction($pdo, 'logout', null, null, 1500, 'Command completed successfully; ending session', $svTRID, $xml, $trans); $clTRID = (string) $xml->command->clTRID;
sendEppResponse($conn, $xml); $clid = getClid($pdo, $data['clid']);
$conn->close(); $xmlString = $xml->asXML();
break; $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
} if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close();
}
processPoll($conn, $pdo, $xml, $data['clid'], $trans);
break;
}
case isset($xml->hello): case isset($xml->command->check) && isset($xml->command->check->children('urn:ietf:params:xml:ns:contact-1.0')->check):
{ {
sendGreeting($conn, $eppExtensionsTable); $data = $table->get($connId);
break; $clTRID = (string) $xml->command->clTRID;
} $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close();
}
if ($c['minimum_data']) {
sendEppError($conn, $pdo, 2101, 'Contact commands are not supported in minimum data mode', $clTRID);
$conn->close();
}
processContactCheck($conn, $pdo, $xml, $trans);
break;
}
case isset($xml->command->poll): case isset($xml->command->create) && isset($xml->command->create->children('urn:ietf:params:xml:ns:contact-1.0')->create):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
if ($c['minimum_data']) {
sendEppError($conn, $pdo, 2101, 'Contact commands are not supported in minimum data mode', $clTRID);
$conn->close();
}
processContactCreate($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
} }
processPoll($conn, $pdo, $xml, $data['clid'], $trans);
break;
}
case isset($xml->command->check) && isset($xml->command->check->children('urn:ietf:params:xml:ns:contact-1.0')->check): case isset($xml->command->info) && isset($xml->command->info->children('urn:ietf:params:xml:ns:contact-1.0')->info):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
if ($c['minimum_data']) {
sendEppError($conn, $pdo, 2101, 'Contact commands are not supported in minimum data mode', $clTRID);
$conn->close();
}
processContactInfo($conn, $pdo, $xml, $data['clid'], $trans);
break;
} }
if ($c['minimum_data']) {
sendEppError($conn, $pdo, 2101, 'Contact commands are not supported in minimum data mode', $clTRID);
$conn->close();
}
processContactCheck($conn, $pdo, $xml, $trans);
break;
}
case isset($xml->command->create) && isset($xml->command->create->children('urn:ietf:params:xml:ns:contact-1.0')->create): case isset($xml->command->update) && isset($xml->command->update->children('urn:ietf:params:xml:ns:contact-1.0')->update):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
if ($c['minimum_data']) {
sendEppError($conn, $pdo, 2101, 'Contact commands are not supported in minimum data mode', $clTRID);
$conn->close();
}
processContactUpdate($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
} }
if ($c['minimum_data']) {
sendEppError($conn, $pdo, 2101, 'Contact commands are not supported in minimum data mode', $clTRID);
$conn->close();
}
processContactCreate($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
}
case isset($xml->command->info) && isset($xml->command->info->children('urn:ietf:params:xml:ns:contact-1.0')->info): case isset($xml->command->delete) && isset($xml->command->delete->children('urn:ietf:params:xml:ns:contact-1.0')->delete):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
if ($c['minimum_data']) {
sendEppError($conn, $pdo, 2101, 'Contact commands are not supported in minimum data mode', $clTRID);
$conn->close();
}
processContactDelete($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
} }
if ($c['minimum_data']) {
sendEppError($conn, $pdo, 2101, 'Contact commands are not supported in minimum data mode', $clTRID);
$conn->close();
}
processContactInfo($conn, $pdo, $xml, $data['clid'], $trans);
break;
}
case isset($xml->command->update) && isset($xml->command->update->children('urn:ietf:params:xml:ns:contact-1.0')->update): case isset($xml->command->transfer) && isset($xml->command->transfer->children('urn:ietf:params:xml:ns:contact-1.0')->transfer):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
if ($c['minimum_data']) {
sendEppError($conn, $pdo, 2101, 'Contact commands are not supported in minimum data mode', $clTRID);
$conn->close();
}
processContactTransfer($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
} }
if ($c['minimum_data']) {
sendEppError($conn, $pdo, 2101, 'Contact commands are not supported in minimum data mode', $clTRID);
$conn->close();
}
processContactUpdate($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
}
case isset($xml->command->delete) && isset($xml->command->delete->children('urn:ietf:params:xml:ns:contact-1.0')->delete): case isset($xml->command->check) && isset($xml->command->check->children('urn:ietf:params:xml:ns:domain-1.0')->check):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
processDomainCheck($conn, $pdo, $xml, $trans, $data['clid']);
break;
} }
if ($c['minimum_data']) {
sendEppError($conn, $pdo, 2101, 'Contact commands are not supported in minimum data mode', $clTRID);
$conn->close();
}
processContactDelete($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
}
case isset($xml->command->transfer) && isset($xml->command->transfer->children('urn:ietf:params:xml:ns:contact-1.0')->transfer): case isset($xml->command->info) && isset($xml->command->info->children('urn:ietf:params:xml:ns:domain-1.0')->info):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
processDomainInfo($conn, $pdo, $xml, $clid, $trans);
break;
} }
if ($c['minimum_data']) {
sendEppError($conn, $pdo, 2101, 'Contact commands are not supported in minimum data mode', $clTRID);
$conn->close();
}
processContactTransfer($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
}
case isset($xml->command->check) && isset($xml->command->check->children('urn:ietf:params:xml:ns:domain-1.0')->check): case isset($xml->command->update) && isset($xml->command->update->children('urn:ietf:params:xml:ns:domain-1.0')->update):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
processDomainUpdate($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
} }
processDomainCheck($conn, $pdo, $xml, $trans, $data['clid']);
break;
}
case isset($xml->command->info) && isset($xml->command->info->children('urn:ietf:params:xml:ns:domain-1.0')->info): case isset($xml->command->create) && isset($xml->command->create->children('urn:ietf:params:xml:ns:domain-1.0')->create):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
processDomainCreate($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans, $c['minimum_data']);
break;
} }
processDomainInfo($conn, $pdo, $xml, $clid, $trans);
break;
}
case isset($xml->command->update) && isset($xml->command->update->children('urn:ietf:params:xml:ns:domain-1.0')->update): case isset($xml->command->delete) && isset($xml->command->delete->children('urn:ietf:params:xml:ns:domain-1.0')->delete):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
processDomainDelete($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
} }
processDomainUpdate($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
}
case isset($xml->command->create) && isset($xml->command->create->children('urn:ietf:params:xml:ns:domain-1.0')->create): case isset($xml->command->transfer) && isset($xml->command->transfer->children('urn:ietf:params:xml:ns:domain-1.0')->transfer):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
processDomainTransfer($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
} }
processDomainCreate($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans, $c['minimum_data']);
break;
}
case isset($xml->command->delete) && isset($xml->command->delete->children('urn:ietf:params:xml:ns:domain-1.0')->delete): case isset($xml->command->check) && isset($xml->command->check->children('urn:ietf:params:xml:ns:host-1.0')->check):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
processHostCheck($conn, $pdo, $xml, $trans);
break;
} }
processDomainDelete($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
}
case isset($xml->command->transfer) && isset($xml->command->transfer->children('urn:ietf:params:xml:ns:domain-1.0')->transfer): case isset($xml->command->create) && isset($xml->command->create->children('urn:ietf:params:xml:ns:host-1.0')->create):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
processHostCreate($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
} }
processDomainTransfer($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
}
case isset($xml->command->check) && isset($xml->command->check->children('urn:ietf:params:xml:ns:host-1.0')->check): case isset($xml->command->info) && isset($xml->command->info->children('urn:ietf:params:xml:ns:host-1.0')->info):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
processHostInfo($conn, $pdo, $xml, $trans);
break;
} }
processHostCheck($conn, $pdo, $xml, $trans);
break;
}
case isset($xml->command->create) && isset($xml->command->create->children('urn:ietf:params:xml:ns:host-1.0')->create): case isset($xml->command->update) && isset($xml->command->update->children('urn:ietf:params:xml:ns:host-1.0')->update):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
processHostUpdate($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
} }
processHostCreate($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
}
case isset($xml->command->info) && isset($xml->command->info->children('urn:ietf:params:xml:ns:host-1.0')->info): case isset($xml->command->delete) && isset($xml->command->delete->children('urn:ietf:params:xml:ns:host-1.0')->delete):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
processHostDelete($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
} }
processHostInfo($conn, $pdo, $xml, $trans);
break;
}
case isset($xml->command->update) && isset($xml->command->update->children('urn:ietf:params:xml:ns:host-1.0')->update): case isset($xml->command->info) && isset($xml->command->info->children('https://namingo.org/epp/funds-1.0')->info):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
processFundsInfo($conn, $pdo, $xml, $data['clid'], $trans);
break;
} }
processHostUpdate($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
}
case isset($xml->command->delete) && isset($xml->command->delete->children('urn:ietf:params:xml:ns:host-1.0')->delete): case isset($xml->command->renew) && isset($xml->command->renew->children('urn:ietf:params:xml:ns:domain-1.0')->renew):
{ {
$data = $table->get($connId); $data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID; $clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']); $clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML(); $xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString); $trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) { if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID); sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close(); $conn->close();
}
processDomainRenew($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
} }
processHostDelete($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
}
case isset($xml->command->info) && isset($xml->command->info->children('https://namingo.org/epp/funds-1.0')->info): default:
{ {
$data = $table->get($connId); sendEppError($conn, $pdo, 2000, 'Unrecognized command');
$clTRID = (string) $xml->command->clTRID; break;
$clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close();
} }
processFundsInfo($conn, $pdo, $xml, $data['clid'], $trans);
break;
}
case isset($xml->command->renew) && isset($xml->command->renew->children('urn:ietf:params:xml:ns:domain-1.0')->renew):
{
$data = $table->get($connId);
$clTRID = (string) $xml->command->clTRID;
$clid = getClid($pdo, $data['clid']);
$xmlString = $xml->asXML();
$trans = createTransaction($pdo, $clid, $clTRID, $xmlString);
if (!$data || $data['logged_in'] !== 1) {
sendEppError($conn, $pdo, 2202, 'Authorization error', $clTRID);
$conn->close();
}
processDomainRenew($conn, $pdo, $xml, $data['clid'], $c['db_type'], $trans);
break;
}
default:
{
sendEppError($conn, $pdo, 2000, 'Unrecognized command');
break;
} }
} }
} catch (PDOException $e) { } catch (PDOException $e) {