Steve75 Posted Saturday at 07:07 AM Share Posted Saturday at 07:07 AM Hi, How do we create a page to display WHOIS information for the websiite visitor to use? Thank you, steve 0 Quote Link to comment Share on other sites More sharing options...
K n K Web Services Posted Sunday at 06:53 AM Share Posted Sunday at 06:53 AM Hey Steve, I just built this on my own WHMCS and it works well. It's a custom client area page that shows the domain status, DNS records and full WHOIS, all inside your theme's header, footer and menu. WHOIS goes through WHMCS's own DomainWhois API, so it uses the same lookup servers your domain checker already uses. DNS uses PHP's dns_get_record(). You need two files. 1. dnscheck.php in your WHMCS root folder: <?php use WHMCS\ClientArea; define('CLIENTAREA', true); require __DIR__ . '/init.php'; $ca = new ClientArea(); $ca->setPageTitle('WHOIS & DNS Lookup'); $ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname')); $ca->addToBreadCrumb('dnscheck.php', 'WHOIS & DNS Lookup'); $ca->initPage(); $domain = strtolower(trim($_POST['domain'] ?? '')); $records = []; $whois = ''; $status = ''; $error = ''; if ($domain !== '') { if (!filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) || strpos($domain, '.') === false) { $error = 'Please enter a valid domain name.'; } else { $result = localAPI('DomainWhois', ['domain' => $domain]); if (($result['result'] ?? '') === 'success') { $status = $result['status']; $whois = html_entity_decode(strip_tags(urldecode($result['whois'] ?? '')), ENT_QUOTES); } $records = @dns_get_record($domain, DNS_A | DNS_AAAA | DNS_CNAME | DNS_MX | DNS_NS | DNS_TXT) ?: []; } } $ca->assign('domain', $domain); $ca->assign('records', $records); $ca->assign('whois', $whois); $ca->assign('status', $status); $ca->assign('error', $error); $ca->setTemplate('dnscheck'); $ca->output(); 2. dnscheck.tpl in your active theme folder (templates/yourtheme/): <form method="post" action="dnscheck.php"> <div class="input-group mb-3"> <input type="text" name="domain" class="form-control" value="{$domain|escape}" placeholder="example.com"> <button class="btn btn-primary" type="submit">Look Up</button> </div> </form> {if $error}<div class="alert alert-warning">{$error}</div>{/if} {if $status} <p><strong>Status:</strong> {if $status == 'available'}Available to register{else}Registered{/if}</p> {/if} {if $records} <h4>DNS Records</h4> <table class="table table-striped"> <tr><th>Type</th><th>Host</th><th>Value</th><th>TTL</th></tr> {foreach $records as $r} <tr> <td>{$r.type}</td> <td>{$r.host|escape}</td> <td>{if $r.ip}{$r.ip}{elseif $r.ipv6}{$r.ipv6}{elseif $r.target}{if $r.pri}{$r.pri} {/if}{$r.target|escape}{elseif $r.txt}{$r.txt|escape}{/if}</td> <td>{$r.ttl}</td> </tr> {/foreach} </table> {/if} {if $whois} <h4>WHOIS</h4> <pre style="white-space:pre-wrap;color:inherit;background:rgba(255,255,255,.05);padding:15px;border-radius:4px;">{$whois|escape}</pre> {/if} Then go to yourwhmcs.com/dnscheck.php and you're set. You can add it to your menu with a navbar hook, or just link to it from your site. A couple of notes: - The color:inherit on the WHOIS box makes it readable on both dark and light themes. - Since it's a public page, I'd add a captcha or rate limit so bots don't hammer it. - A lot of WHOIS records hide owner details now because of privacy rules, so you'll mostly see the registrar, dates and nameservers. Hope that helps! Rob K & K Web Services 0 Quote Link to comment Share on other sites More sharing options...
Steve75 Posted Sunday at 11:41 AM Author Share Posted Sunday at 11:41 AM LEGEND, thank you so much Rob 1 Quote Link to comment Share on other sites More sharing options...
carlpeeter32 Posted yesterday at 09:18 AM Share Posted yesterday at 09:18 AM Nice write-up, Rob — thanks for sharing the full working example. One thing I would add from my own experience is to validate and sanitise the domain input on the server side before passing it to any WHOIS or DNS lookup, since it is a public form and people will try all sorts of input in it. I also found it worth caching results briefly, because repeated lookups for the same domain can get slow and some WHOIS servers start throttling you. And on the captcha point, I agree — even a simple rate limit made a big difference for me when I ran something similar. Did you find the WHOIS output reliable across different TLDs, or did some registrars return very thin results? 0 Quote Link to comment Share on other sites More sharing options...
Steve75 Posted 7 hours ago Author Share Posted 7 hours ago > Since it's a public page, I'd add a captcha or rate limit so bots don't hammer it. > One thing I would add from my own experience is to validate and sanitise the domain input on the server side before passing it to any WHOIS or DNS lookup, since it is a public form and people will try all sorts of input in it. How do I do this, please (I am not a programmer)? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.