diff --git a/automation/escrow.php b/automation/escrow.php index 068607e..97287ff 100644 --- a/automation/escrow.php +++ b/automation/escrow.php @@ -34,11 +34,6 @@ try { } try { - $domainCount = fetchCount($dbh, 'domain'); - $hostCount = fetchCount($dbh, 'host'); - $contactCount = fetchCount($dbh, 'contact'); - $registrarCount = fetchCount($dbh, 'registrar'); - // Fetching TLDs $stmt = $dbh->query("SELECT id,tld FROM domain_tld;"); $tlds = $stmt->fetchAll(); @@ -61,7 +56,12 @@ try { foreach ($tlds as $tld) { $tldname = ltrim($tld['tld'], '.'); $endOfPreviousDay = date('Y-m-d 23:59:59', strtotime('-1 day')); - + + $domainCount = fetchDomainCount($dbh, $tld['id']); + $hostCount = fetchCount($dbh, 'host'); + $contactCount = fetchCount($dbh, 'contact'); + $registrarCount = fetchCount($dbh, 'registrar'); + // Skip subdomains if (strpos($tldname, '.') !== false) { continue; @@ -84,7 +84,6 @@ try { $xml->writeAttributeNS('xmlns', 'domain', null, 'urn:ietf:params:xml:ns:domain-1.0'); $xml->writeAttributeNS('xmlns', 'contact', null, 'urn:ietf:params:xml:ns:contact-1.0'); $xml->writeAttributeNS('xmlns', 'secDNS', null, 'urn:ietf:params:xml:ns:secDNS-1.1'); - $xml->writeAttributeNS('xmlns', 'rdeHeader', null, 'urn:ietf:params:xml:ns:rdeHeader-1.0'); $xml->writeAttributeNS('xmlns', 'rdeDomain', null, 'urn:ietf:params:xml:ns:rdeDomain-1.0'); $xml->writeAttributeNS('xmlns', 'rdeHost', null, 'urn:ietf:params:xml:ns:rdeHost-1.0'); $xml->writeAttributeNS('xmlns', 'rdeContact', null, 'urn:ietf:params:xml:ns:rdeContact-1.0'); @@ -110,7 +109,6 @@ try { // Array of objURI values $objURIs = [ - 'urn:ietf:params:xml:ns:rdeHeader-1.0', 'urn:ietf:params:xml:ns:rdeContact-1.0', 'urn:ietf:params:xml:ns:rdeHost-1.0', 'urn:ietf:params:xml:ns:rdeDomain-1.0', @@ -659,7 +657,6 @@ try { // Array of objURI values $objURIs = [ - 'urn:ietf:params:xml:ns:rdeHeader-1.0', 'urn:ietf:params:xml:ns:rdeContact-1.0', 'urn:ietf:params:xml:ns:rdeHost-1.0', 'urn:ietf:params:xml:ns:rdeDomain-1.0', diff --git a/automation/helpers.php b/automation/helpers.php index 5775b5d..645d5c0 100644 --- a/automation/helpers.php +++ b/automation/helpers.php @@ -138,6 +138,22 @@ function fetchCount($pdo, $tableName) { return $result['count']; } +function fetchDomainCount($pdo, $tld_id) { + // Calculate the end of the previous day + $endOfPreviousDay = date('Y-m-d 23:59:59', strtotime('-1 day')); + + // Prepare the SQL query + $query = "SELECT COUNT(id) AS count FROM domain WHERE crdate <= :endOfPreviousDay AND tldid = :tldid"; + $stmt = $pdo->prepare($query); + $stmt->bindParam(':endOfPreviousDay', $endOfPreviousDay); + $stmt->bindParam(':tldid', $tld_id, PDO::PARAM_INT); + $stmt->execute(); + + // Fetch and return the count + $result = $stmt->fetch(); + return $result['count']; +} + // Function to check domain against Spamhaus SBL function checkSpamhaus($domain) { // Append '.sbl.spamhaus.org' to the domain