Fixes for the milliseconds

This commit is contained in:
Pinga 2023-11-09 01:01:23 +02:00
parent 63aa36ff0a
commit 7f435b6721
5 changed files with 21 additions and 14 deletions

View file

@ -365,7 +365,7 @@ class ContactsController extends Controller
$db->beginTransaction();
try {
$currentDateTime = new DateTime();
$currentDateTime = new \DateTime();
$crdate = $currentDateTime->format('Y-m-d H:i:s.v');
$db->insert(
'contact',

View file

@ -335,10 +335,10 @@ class DomainsController extends Controller
try {
$db->beginTransaction();
$currentDateTime = new DateTime();
$currentDateTime = new \DateTime();
$crdate = $currentDateTime->format('Y-m-d H:i:s.v'); // Current timestamp
$currentDateTime = new DateTime();
$currentDateTime = new \DateTime();
$currentDateTime->modify("+$date_add months");
$exdate = $currentDateTime->format('Y-m-d H:i:s.v'); // Expiry timestamp after $date_add months
@ -503,7 +503,7 @@ class DomainsController extends Controller
$from = $row['crdate'];
$to = $row['exdate'];
$currentDateTime = new DateTime();
$currentDateTime = new \DateTime();
$stdate = $currentDateTime->format('Y-m-d H:i:s.v');
$db->insert(
'statement',
@ -540,7 +540,7 @@ class DomainsController extends Controller
]
);
} else {
$currentDateTime = new DateTime();
$currentDateTime = new \DateTime();
$logdate = $currentDateTime->format('Y-m-d H:i:s.v');
$db->insert(
'error_log',
@ -552,7 +552,7 @@ class DomainsController extends Controller
);
}
} else {
$currentDateTime = new DateTime();
$currentDateTime = new \DateTime();
$host_date = $currentDateTime->format('Y-m-d H:i:s.v');
$host_id = $db->insert(
'host',

View file

@ -127,7 +127,7 @@ class HostsController extends Controller
$db->beginTransaction();
try {
$currentDateTime = new DateTime();
$currentDateTime = new \DateTime();
$crdate = $currentDateTime->format('Y-m-d H:i:s.v');
$db->insert(
'host',
@ -203,7 +203,7 @@ class HostsController extends Controller
'registrars' => $registrars,
]);
} else {
$currentDateTime = new DateTime();
$currentDateTime = new \DateTime();
$crdate = $currentDateTime->format('Y-m-d H:i:s.v');
$db->insert(
'host',

View file

@ -199,11 +199,14 @@ function handleDomainQuery($request, $response, $pdo, $domainName) {
// Perform the RDAP lookup
try {
// Query 1: Get domain details
$stmt1 = $pdo->prepare("SELECT *, DATE_FORMAT(`crdate`, '%Y-%m-%dT%TZ') AS `crdate`, DATE_FORMAT(`exdate`, '%Y-%m-%dT%TZ') AS `exdate` FROM `registry`.`domain` WHERE `name` = :domain");
$stmt1 = $pdo->prepare("SELECT * FROM `registry`.`domain` WHERE `name` = :domain");
$stmt1->bindParam(':domain', $domain, PDO::PARAM_STR);
$stmt1->execute();
$domainDetails = $stmt1->fetch(PDO::FETCH_ASSOC);
$domainDetails['crdate'] = (new DateTime($domainDetails['crdate']))->format('Y-m-d\TH:i:s.v\Z');
$domainDetails['exdate'] = (new DateTime($domainDetails['exdate']))->format('Y-m-d\TH:i:s.v\Z');
// Check if the domain exists
if (!$domainDetails) {
// Domain not found, respond with a 404 error

View file

@ -329,16 +329,20 @@ $server->on('receive', function ($server, $fd, $reactorId, $data) use ($c, $pdo)
// Perform the WHOIS lookup
try {
$query = "SELECT *,
DATE_FORMAT(`crdate`, '%Y-%m-%dT%H:%i:%sZ') AS `crdate`,
DATE_FORMAT(`update`, '%Y-%m-%dT%H:%i:%sZ') AS `update`,
DATE_FORMAT(`exdate`, '%Y-%m-%dT%H:%i:%sZ') AS `exdate`
FROM `registry`.`domain` WHERE `name` = :domain";
$query = "SELECT * FROM `registry`.`domain` WHERE `name` = :domain";
$stmt = $pdo->prepare($query);
$stmt->bindParam(':domain', $domain, PDO::PARAM_STR);
$stmt->execute();
if ($f = $stmt->fetch(PDO::FETCH_ASSOC)) {
$f['crdate'] = (new DateTime($f['crdate']))->format('Y-m-d\TH:i:s.v\Z');
if (isset($f['update']) && $f['update'] !== null) {
$f['update'] = (new DateTime($f['update']))->format('Y-m-d\TH:i:s.v\Z');
} else {
$f['update'] = '';
}
$f['exdate'] = (new DateTime($f['exdate']))->format('Y-m-d\TH:i:s.v\Z');
$query2 = "SELECT `tld` FROM `domain_tld` WHERE `id` = :tldid";
$stmt2 = $pdo->prepare($query2);
$stmt2->bindParam(':tldid', $f['tldid'], PDO::PARAM_INT);