Update eppSync.php

This commit is contained in:
Pinga 2023-07-13 15:42:39 +03:00 committed by GitHub
parent 2e11d698ee
commit 5675423dd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,10 +29,7 @@ try
foreach ($rows as $row)
{
// Decode the JSON string into an array
$config = json_decode($row["config"], true);
// Extract id
$registrar_id = $row["id"];
}
@ -57,15 +54,11 @@ function connectEpp(string $registry, $config)
{
$epp = new Epp();
$info = [
//For EPP-over-HTTPS, 'host' => 'https://registry.example.com/epp',
"host" => $config["host"],
//For EPP-over-HTTPS , port is usually 443
"port" => $config["port"], "timeout" => 30, "tls" => "1.3", "bind" => false, "bindip" => "1.2.3.4:0", "verify_peer" => false, "verify_peer_name" => false,
//For EPP-over-HTTPS , change false to 2
"verify_host" => false, "cafile" => "", "local_cert" => $config["ssl_cert"], "local_pk" => $config["ssl_key"], "passphrase" => "", "allow_self_signed" => true, ];
$epp->connect($info);
$login = $epp->login(["clID" => $config["username"], "pw" => $config["password"],
//'newpw' => 'testpassword2',
"prefix" => "tembo", ]);
if (array_key_exists("error", $login))
{
@ -112,40 +105,40 @@ try {
$ns3 = isset($ns[3]) ? $ns[3] : null;
$ns4 = isset($ns[4]) ? $ns[4] : null;
$exDate = $domainInfo['exDate'];
$datetime = new DateTime($exDate);
$formattedExDate = $datetime->format('Y-m-d H:i:s');
$exDate = $domainInfo['exDate'];
$datetime = new DateTime($exDate);
$formattedExDate = $datetime->format('Y-m-d H:i:s');
$statuses = $domainInfo['status'];
$statuses = $domainInfo['status'];
$clientStatuses = ['clientDeleteProhibited', 'clientTransferProhibited', 'clientUpdateProhibited'];
$serverStatuses = ['serverDeleteProhibited', 'serverTransferProhibited', 'serverUpdateProhibited'];
$clientStatuses = ['clientDeleteProhibited', 'clientTransferProhibited', 'clientUpdateProhibited'];
$serverStatuses = ['serverDeleteProhibited', 'serverTransferProhibited', 'serverUpdateProhibited'];
// Check if all client statuses are present in the $statuses array
$clientProhibited = count(array_intersect($clientStatuses, $statuses)) === count($clientStatuses);
// Check if all client statuses are present in the $statuses array
$clientProhibited = count(array_intersect($clientStatuses, $statuses)) === count($clientStatuses);
// Check if all server statuses are present in the $statuses array
$serverProhibited = count(array_intersect($serverStatuses, $statuses)) === count($serverStatuses);
// Check if all server statuses are present in the $statuses array
$serverProhibited = count(array_intersect($serverStatuses, $statuses)) === count($serverStatuses);
if ($clientProhibited || $serverProhibited) {
$locked = 1;
} else {
$locked = 0;
}
if ($clientProhibited || $serverProhibited) {
$locked = 1;
} else {
$locked = 0;
}
// Prepare the UPDATE statement
$stmt = $pdo->prepare('UPDATE service_domain SET ns1 = :ns1, ns2 = :ns2, ns3 = :ns3, ns4 = :ns4, expires_at = :expires_at, locked = :locked, transfer_code = :transfer_code WHERE sld = :sld AND tld = :tld');
// Prepare the UPDATE statement
$stmt = $pdo->prepare('UPDATE service_domain SET ns1 = :ns1, ns2 = :ns2, ns3 = :ns3, ns4 = :ns4, expires_at = :expires_at, locked = :locked, transfer_code = :transfer_code WHERE sld = :sld AND tld = :tld');
// Bind the values to the statement
$stmt->bindValue(':ns1', $ns1);
$stmt->bindValue(':ns2', $ns2);
$stmt->bindValue(':ns3', $ns3);
$stmt->bindValue(':ns4', $ns4);
$stmt->bindValue(':expires_at', $formattedExDate);
$stmt->bindValue(':locked', $locked);
// Bind the values to the statement
$stmt->bindValue(':ns1', $ns1);
$stmt->bindValue(':ns2', $ns2);
$stmt->bindValue(':ns3', $ns3);
$stmt->bindValue(':ns4', $ns4);
$stmt->bindValue(':expires_at', $formattedExDate);
$stmt->bindValue(':locked', $locked);
$stmt->bindValue(':transfer_code', $domainInfo["authInfo"]);
$stmt->bindValue(':sld', $domainRow['sld']);
$stmt->bindValue(':tld', $domainRow['tld']);
$stmt->bindValue(':sld', $domainRow['sld']);
$stmt->bindValue(':tld', $domainRow['tld']);
// Execute the statement
$stmt->execute();