WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : PHP Domain Availability Checker
Categories : PHP, Complete Programs, Regexps, HTTP, Sockets Click here to Update Your Picture
Gerhard Gerome
Date : Mar 15th 2007
Grade : 4 of 5 (graded 16 times)
Viewed : 34208
File : 4603.zip
Images : No Images for this code example.
Search : More code by Gerhard Gerome
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

A multiple domain availability checker. Insert the domain names you want to check in the file domains.txt and run the script.

Please see attached file above.

whois.php
<?php
$arWhoisServer
= array(
   
'com'         => array('whois.crsnic.net', 'No match for'),
   
'net'         => array('whois.crsnic.net', 'No match for'),   
   
'org'         => array('whois.pir.org', 'NOT FOUND'),
   
'biz'         => array('whois.biz', 'Not found'),
   
'mobi'        => array('whois.dotmobiregistry.net', 'NOT FOUND'),
   
'tv'         => array('whois.nic.tv', 'No match for'),
   
'in'         => array('whois.inregistry.net', 'NOT FOUND'),
   
'info'         => array('whois.afilias.net', 'NOT FOUND'),   
   
'co.uk'     => array('whois.nic.uk', 'No match'),       
   
'co.ug'     => array('wawa.eahd.or.ug', 'No entries found'),   
   
'or.ug'     => array('wawa.eahd.or.ug', 'No entries found'),
   
'nl'         => array('whois.domain-registry.nl', 'not a registered domain'),
   
'ro'         => array('whois.rotld.ro', 'No entries found for the selected'),
   
'com.au'    => array('whois.ausregistry.net.au', 'No data Found'),
   
'ca'         => array('whois.cira.ca', 'AVAIL'),
   
'org.uk'    => array('whois.nic.uk', 'No match'),
   
'name'         => array('whois.nic.name', 'No match'),
   
'us'         => array('whois.nic.us', 'Not Found'),
   
'ac.ug'     => array('wawa.eahd.or.ug', 'No entries found'),
   
'ne.ug'     => array('wawa.eahd.or.ug', 'No entries found'),
   
'sc.ug'     => array('wawa.eahd.or.ug', 'No entries found'),
   
'ws'        => array('whois.website.ws', 'No Match'),
   
'be'         => array('whois.ripe.net', 'No entries'),
   
'com.cn'     => array('whois.cnnic.cn', 'no matching record'),
   
'net.cn'     => array('whois.cnnic.cn', 'no matching record'),
   
'org.cn'     => array('whois.cnnic.cn', 'no matching record'),
   
'no'        => array('whois.norid.no', 'no matches'),
   
'se'         => array('whois.nic-se.se', 'No data found'),
   
'nu'         => array('whois.nic.nu', 'NO MATCH for'),
   
'com.tw'     => array('whois.twnic.net', 'No such Domain Name'),
   
'net.tw'     => array('whois.twnic.net', 'No such Domain Name'),
   
'org.tw'     => array('whois.twnic.net', 'No such Domain Name'),
   
'cc'         => array('whois.nic.cc', 'No match'),
   
'nl'         => array('whois.domain-registry.nl', 'is free'),
   
'pl'         => array('whois.dns.pl', 'No information about'),
   
'pt'         => array('whois.dns.pt', 'No match')
);
$arFailedDomain = array();
$arAvailableDomain = array();
$arUnavailableDomain = array();

function
checkDomainAvailability($domain){
    global
$arWhoisServer, $requestTimeout;
   
// Get the domain without http:// and www.
   
$domain = trim($domain);
   
preg_match('@^(http://www\.|http://|www\.)?([^/]+)@i', $domain, $matches);
   
$domain = $matches[2];
   
// Get the tld
   
$tld = explode('.', $domain, 2);
   
$tld = strtolower(trim($tld[1]));
   
// If the domain name is valid and we have an entry corresponding to our tld
   
if(strlen($domain) <= strlen($tld) + 1){
           
checkResult($domain, $tld, 'Invalid Domain name', 'error');
    }elseif(!
array_key_exists($tld, $arWhoisServer)){
           
checkResult($domain, $tld, "Unsupported Domain ($tld)", 'error');
    }else{
       
$server = $arWhoisServer[$tld][0];
       
$fp = fsockopen($server, 43, $errno, $error, $requestTimeout);
        if(!
$fp) {
           
checkResult($domain, $tld, "Could not connect to '$server' on port 43.", 'error');
        }else{
           
// Clear the output of the previous response
           
$output = '';
           
$domain .= "\r\n";
           
$startTime = time();
           
fputs($fp, $domain);
           
$i = 0;
            while(!
feof($fp)){
                if(
$startTime + $requestTimeout <= time()){
                   
$output .= fgets($fp);
                }else{
                   
fclose($fp);
                   
checkResult($domain, $tld, "The request timed out", 'error');
                }
            }
           
fclose($fp);
           
checkResult($domain, $tld, $output);
        }
    }
}

function
checkResult($domain, $tld = '', $response, $status = 'success'){
    global
$arWhoisServer, $arFailedDomain, $arAvailableDomain, $arUnavailableDomain;
    if(
$status == 'error'){
       
$msg = "<span class='error'>$response</span>";
       
$arFailedDomain[count($domainStatus)] = array($domain, $response);
    }else{
        if(
eregi($arWhoisServer[$tld][1], $response)){
           
$msg = "<span class='success'>Available</span>";
           
$arAvailableDomain[count($arAvailableDomain)] = $domain;
        }else{
           
$msg = "<span class='error'>Registered</span>";
           
$arUnavailableDomain[count($arUnavailableDomain)] = $domain;
        }
    }
    echo
$msg;
}
?>
<html>
<head>
<title>Whois Checker</title>
<style type="text/css">
body{background:#F2F2F2;font:bold 11px Verdana, Arial, sans-serif;}
.error{color:red;font-weight:bold;}
.success{color:green;font-weight:bold;}
.tblDomains{width:350px;font:bold 12px Verdana, Arial, sans-serif;border-collapse:collapse;}
.tblDomains td{text-align:left;border:1px #CCC solid;}
</style>
</head>

<body>
<table style="width:100%;height:100%;">
<tr><td>
<center>
<table class="tblDomains" cellspacing="0" cellpadding="5">
<?php
// Path to PHP Mailer
require("../../includes/contact/class.phpmailer.php");
$notifyFailedDomains = true;
$notifyUnavailableDomains = true;

$file = 'domains.txt';
$i = 0;
echo
"<tr><td>Opening file '$file'</td><td>";
if(
file_exists($file)){
    echo
'<span class="success">SUCCESS</span></td></tr>';
   
$domains = file($file);
   
$cnt = count($domains);
    echo
'<tr><td>Total Number of domains to check</td><td>';
    echo
$cnt ? "<span class='success'>$cnt</span>" : "<span class='error'>0</span>";
    echo
'</td></tr>';
    echo
"<tr><td colspan='2'>Checking...<br/>";
   
// Loop through each domains
   
foreach($domains as $domain){
        echo
"<tr><td>&bull; $domain</td><td>";
       
checkDomainAvailability($domain);
        echo
'</td></tr>';
    }
    echo
'<tr><td colspan="2">';
    echo
"<div>AVAILABLE DOMAINS</div>\n";
    foreach (
$arAvailableDomain as $domain){
        echo
" <div style='font-weight:bold;color:green;padding-left:20px;'>$domain</div>";
    }
    echo
"<div>UNAVAILABLE</div>\n";
    foreach (
$arUnavailableDomain as $domain){
        echo
" <div class='failed' style='padding-left:20px;'>$domain</div>";
    }
    echo
"<div>FAILED</div>\n";
    foreach (
$arFailedDomain as $domain){
        echo
" <div class='failed' style='padding-left:20px;'>$domain[0] : $domain[1]</div>";
    }
    echo
'</td></tr>';
}else{
    echo
'<span class="error">FAILED</span></td></tr>';
}
?>
</td></tr>
</table>
</center>
</td>
</tr>
</table>
</body>
</html>



domains.txt
http://www.weberdev.com
php-code-search.com
http://contest.weberdev.com
http://www.weberforums.com
http://www.webertrivia.com
www.weberblogs.com
http://www.weberindex.com
http://www.webertemplates.com
http://toolbar.weberdev.com
uptime.weberdev.com
http://content.weber-sites.com
http://seo.weberdev.com
http://digitalpoint.com
http://non-existant-domain.com



Grab links from a page
Categories : PHP, Regexps, HTTP
Gets the browser and OS from the $_SERVER['http_user_agent'] variable in PHP
Categories : PHP, HTTP, Regexps
Remote File Saving with PHP - Download and serve a remote file. The content of the file will be updated at fixed intervals.
Categories : PHP, Filesystem, Cache, Sockets, HTTP
Remote File Size
Categories : PHP, Filesystem, HTTP, Sockets
A function to check if a URL exists
Categories : PHP, CURL, HTTP
Form is a utility class for generating html forms. It provides form initialization and regex based data validation (both server and client side) with a convenient interface. This version obsoletes version 1.0a
Categories : HTML, PHP, PHP Classes, Regexps
How to use regular expressions to get the list of links from an HTML page
Categories : PHP, Regexps, HTML, HTML and PHP
databases administration remote Web
Categories : mSQL, PHP, Complete Programs, Databases
This is a very simple BBS that uses MySQL
Categories : MySQL, Databases, Complete Programs, PHP
This script allows people to add their favorite quotes to your website. This could easily be modified to be a guestbook script or comment page script.
Categories : PHP, Complete Programs, HTML and PHP, Misc
DBE - Database Expander: Edit PostgreSQL individual database tables online via your Web browser!
Categories : PostgreSQL, Complete Programs, Databases, PHP Classes, PHP
Produces browser-safe strings while preserving HTML tags.
Categories : Strings, HTTP, PHP, HTML and PHP
phpYellow Pages Standard
Categories : PHP, Complete Programs, Databases, Directories, Search
MyRedirector 1.0 is a Redirector with graphical Statistics
Categories : HTTP, Complete Programs, MySQL, URLs
Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs.
Categories : Databases, PHP, MySQL, Complete Programs