Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong expiration date detected #129

Closed
mlocati opened this issue Aug 18, 2020 · 6 comments
Closed

Wrong expiration date detected #129

mlocati opened this issue Aug 18, 2020 · 6 comments

Comments

@mlocati
Copy link

mlocati commented Aug 18, 2020

PHP-Whois version: 4.0.0

PHP version: 7.2.33

Description
The reported expiration for one of our domains (progesoft-italia.com) is wrong.
From the control panel offered by our domain registration provider, we can read this:

image

(Sorry for Italian, it says that the domain expiration is 2021-07-22)

But this library says that the expiration is 2020-07-22

How to reproduce

Try the following code:

<?php
use Iodev\Whois\Factory;
require_once './vendor/autoload.php';
$whois = Factory::get()->createWhois();
$info = $whois->loadDomainInfo('progesoft-italia.com');
echo gmdate('Y-m-d', $info->expirationDate);

I'd expect it outputs 2021-07-22, but it outputs 2020-07-22

Possible Solution

I've seen that the library performs 2 queries, the first using whois.verisign-grs.com and the second using whois.register.it
Manually running those queries, we have:

$ whois -h whois.verisign-grs.com progesoft-italia.com 2>/dev/null | grep -i exp | grep 20
   Registry Expiry Date: 2021-07-22T13:07:14Z
$ whois -h whois.register.it progesoft-italia.com 2>/dev/null | grep -i exp | grep 20
Registrar Registration Expiration Date: 2020-07-22T00:00:00Z

As you can see, whois.verisign-grs.com returns 2021-07-22 (the value we'd expect), whereas whois.register.it returns the value returned by this library.

@bessone
Copy link
Contributor

bessone commented Nov 9, 2020

Somehow related to #123

@mlocati
Copy link
Author

mlocati commented Nov 9, 2020

Yep, they are related. It'd be nice to have a way to get only the first query result (thus, skipping this second query).

I have a patch file for this. Are the maintainers interested in this?

@io-developer
Copy link
Owner

Checked. Now it's correct. Maybe previous parsing improvements fixed it..

@mlocati
Copy link
Author

mlocati commented Jul 13, 2021

Checked. Now it's correct. Maybe previous parsing improvements fixed it..

Nope, that's not the reason.
The reason is that the whois server returned two dates, and php-whois always return the second date.

@mlocati
Copy link
Author

mlocati commented Jul 13, 2021

I solved this issue by patching php-whois version 3.5.0 (the version we are using) like this:

From 4e88993de778be765624ab09f1bd42f05c6f295d Mon Sep 17 00:00:00 2001
From: Michele Locati <[email protected]>
Date: Tue, 15 Sep 2020 08:52:23 +0200
Subject: [PATCH] Allow skipping recursive whois

---
 src/Iodev/Whois/Modules/Tld/TldModule.php | 22 +++++++++++++---------
 src/Iodev/Whois/Whois.php                 |  5 +++--
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/Iodev/Whois/Modules/Tld/TldModule.php b/src/Iodev/Whois/Modules/Tld/TldModule.php
index d72a17a..c570744 100644
--- a/src/Iodev/Whois/Modules/Tld/TldModule.php
+++ b/src/Iodev/Whois/Modules/Tld/TldModule.php
@@ -122,30 +122,32 @@ class TldModule extends Module
     /**
      * @param string $domain
      * @param TldServer $server
+     * @param bool $descend
      * @return DomainResponse
      * @throws ServerMismatchException
      * @throws ConnectionException
      * @throws WhoisException
      */
-    public function lookupDomain($domain, TldServer $server = null)
+    public function lookupDomain($domain, TldServer $server = null, $descend = true)
     {
         $servers = $server ? [$server] : $this->matchServers($domain);
-        list ($response) = $this->loadDomainData($domain, $servers);
+        list ($response) = $this->loadDomainData($domain, $servers, $descend);
         return $response;
     }
 
     /**
      * @param string $domain
      * @param TldServer $server
+     * @param bool $descend
      * @return DomainInfo
      * @throws ServerMismatchException
      * @throws ConnectionException
      * @throws WhoisException
      */
-    public function loadDomainInfo($domain, TldServer $server = null)
+    public function loadDomainInfo($domain, TldServer $server = null, $descend = true)
     {
         $servers = $server ? [$server] : $this->matchServers($domain);
-        list (, $info) = $this->loadDomainData($domain, $servers);
+        list (, $info) = $this->loadDomainData($domain, $servers, $descend);
         return $info;
     }
 
@@ -169,11 +171,12 @@ class TldModule extends Module
     /**
      * @param string $domain
      * @param TldServer[] $servers
+     * @param bool $descend
      * @return array
      * @throws ConnectionException
      * @throws WhoisException
      */
-    private function loadDomainData($domain, $servers)
+    private function loadDomainData($domain, $servers, $descend)
     {
         $this->lastUsedServers = [];
         $domain = DomainHelper::toAscii($domain);
@@ -182,7 +185,7 @@ class TldModule extends Module
         $lastError = null;
         foreach ($servers as $server) {
             $this->lastUsedServers[] = $server;
-            $this->loadParsedTo($response, $info, $server, $domain, false, null, $lastError);
+            $this->loadParsedTo($response, $info, $server, $domain, false, null, $lastError, $descend);
             if ($info) {
                 break;
             }
@@ -201,10 +204,11 @@ class TldModule extends Module
      * @param $strict
      * @param $host
      * @param $lastError
+     * @param bool $descend
      * @throws ConnectionException
      * @throws WhoisException
      */
-    private function loadParsedTo(&$outResponse, &$outInfo, $server, $domain, $strict = false, $host = null, &$lastError = null)
+    private function loadParsedTo(&$outResponse, &$outInfo, $server, $domain, $strict = false, $host = null, &$lastError = null, $descend = true)
     {
         try {
             $outResponse = $this->loadResponse($server, $domain, $strict, $host);
@@ -216,11 +220,11 @@ class TldModule extends Module
             throw $lastError;
         }
         if (!$strict && !$outInfo) {
-            $this->loadParsedTo($tmpResponse, $tmpInfo, $server, $domain, true, $host, $lastError);
+            $this->loadParsedTo($tmpResponse, $tmpInfo, $server, $domain, true, $host, $lastError, $descend);
             $outResponse = $tmpInfo ? $tmpResponse : $outResponse;
             $outInfo = $tmpInfo ?: $outInfo;
         }
-        if (!$outInfo || $host == $outInfo->getWhoisServer()) {
+        if (!$outInfo || $host == $outInfo->getWhoisServer() || !$descend) {
             return;
         }
         $host = $outInfo->getWhoisServer();
diff --git a/src/Iodev/Whois/Whois.php b/src/Iodev/Whois/Whois.php
index 6ec78f2..3621807 100644
--- a/src/Iodev/Whois/Whois.php
+++ b/src/Iodev/Whois/Whois.php
@@ -93,14 +93,15 @@ class Whois
 
     /**
      * @param string $domain
+     * @param bool $descend
      * @return DomainInfo
      * @throws ServerMismatchException
      * @throws ConnectionException
      * @throws WhoisException
      */
-    public function loadDomainInfo($domain)
+    public function loadDomainInfo($domain, $descend = true)
     {
-        return $this->getTldModule()->loadDomainInfo($domain);
+        return $this->getTldModule()->loadDomainInfo($domain, null, $descend);
     }
 
     /**

@jordanade
Copy link

I'm still getting out of date expiries. In my case it was on the domain 'rsuttonart.org'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants