PHP Classes

File: sample.php

Recommend this page to a friend!
  Classes of Peter Schmalfeldt  >  Whois Lookup  >  sample.php  >  Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: Whois Lookup
Get details about domains or addresses with Whois
Author: By
Last change:
Date: 13 years ago
Size: 2,274 bytes


Class file image Download
 * @category ServerTools
 * @package Whois
 * @author Peter Schmalfeldt <>
 * @link

 * Begin Document
## include class

## check for $_POST or $_GET variable called 'domain'
$url = (strlen($_POST['domain'])>0) ? $_POST['domain']:$_GET['domain'];

## if domain is not empty, instantiate Whois object
if(strlen($url)>0) $whois = new Whois($url);

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" xml:lang="en" lang="en">
    <title>Whois Lookup</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <form action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data" autocomplete="off">
        Domain/IP: <input type="text" name="domain" id="domain" value="<?=$whois->domain?>" style="width: 250px;" spellcheck="false" title="Enter a Domain Name or IP Address." />
        <input type="submit" value="&nbsp;Whois Lookup&nbsp;" title="Perform a Whois Lookup on this Domain Name or IP Address." />
## provide link to open URL in new window since domain name exists
if($whois->url && !preg_match("/No match for/i", $whois->data) && !preg_match("/Error:/i", $whois->data))
'<input type="button" value="&nbsp;Open URL&nbsp;" title="Open this URL in a new window." onclick="\''.$whois->url.'\')" />';
## provide link to in new window to purchase domain since domain name does not exist
if(preg_match("/No match for/i", $whois->data))
'<input type="button" value="&nbsp;Order Domain&nbsp;" title="Order this Domain Name with" onclick="\''.$whois->domainarray[1].'&tld=.'.strtoupper($whois->domainarray[0]).'&checkAvail=1&ci=12014\')" />';

## show the results from the whois lookup
'<textarea readonly="readonly" spellcheck="false" style="width: 100%; height: 500px;">'.htmlspecialchars($whois->data).'</textarea>';

For more information send a message to info at phpclasses dot org.