Codice PHP:
// show the error page
function do_error()
{
global $use_global_templates;
global $vars;
global $titlebar;
global $errormsg;
global $whois_templates;
global $whois_page_titles;
$titlebar = $whois_page_titles["error"];
if($use_global_templates) { echo make_changes($whois_templates["header"]); }
echo make_changes($whois_templates["error"]);
if($use_global_templates) { echo make_changes($whois_templates["footer"]); }
exit();
}
// checks the domain is legal
function check_domain()
{
global $errormsg;
global $vars;
global $whois_exts;
if(isset($vars["ext"])
&& !isset($vars["do_global"])
&& !isset($vars["do_wizard"]) ){
if(!strlen($vars["ext"])){
$errormsg = "No top level domain selected";
return 0;
}
if(!my_in_array($vars["ext"], $whois_exts)){
$errormsg = "Top level domain not supported";
return 0;
}
}
if(isset($vars["domain"])){
if(@ereg("^-|-$",$vars["domain"])){
$errormsg = "Domain names cannot begin or end in a hyphen or contain double hyphens";
return 0;
}
if(!@ereg("([a-z]|[A-Z]|[0-9]|-){".strlen($vars["domain"])."}",$vars["domain"]) || !strlen($vars["domain"])){
$errormsg = "Domain names must only contain alphanumerical characters and hyphens";
return 0;
}
}
return 1;
}
// perform_whois function returns 1 if domain is available otherwise returns either the raw info or 0
function perform_whois($domainname, $ext, $raw)
{
global $vars;
global $errormsg;
global $whois_servers;
global $rawoutput;
global $whois_avail_strings;
$rawoutput = "";
if($raw) { return do_raw($domainname, $ext); }
if(($ns = fsockopen($whois_servers[$ext], 43)) == false){
$errormsg = "Cannot connect to [b][i]".$whois_servers[$ext]."[/i][/b]";
return -1;
}
fputs($ns, $domainname.".".$ext."\r\n");
while(!feof($ns)) { $rawoutput .= fgets($ns,128); }
fclose($ns);
$whois_avail_strings[$whois_servers[$ext]] = str_replace("\\n", "\n", $whois_avail_strings[$whois_servers[$ext]]);
// echo "\n";
$tmp = strpos($rawoutput, $whois_avail_strings[$whois_servers[$ext]]);
if(!strlen($rawoutput) || is_integer($tmp)) { return 1; }
return 0;
}
// this performs the whois lookup and then shows the data returned
function do_raw($domainname, $ext)
{
global $vars;
global $titlebar;
global $use_global_templates;
global $whois_info_servers;
global $whois_servers;
global $rawoutput;
global $errormsg;
global $whois_info_servers_backup;
global $whois_avail_strings;
global $whois_server;
global $whois_page_titles;
global $whois_templates;
choose_info_server($domainname, $ext);
if(($ns = fsockopen($whois_server,43)) == false){
if(($ns = fsockopen($whois_info_servers[$ext],43)) == false){
if(($ns = fsockopen($whois_info_servers_backup[$ext], 43)) == false){
return -1;
} else {
$whois_server = $whois_info_servers_backup[$ext];
}
} else {
$whois_server = $whois_info_servers[$ext];
}
}
//print "\n";
fputs($ns, $domainname.".".$ext."\r\n");
while(!feof($ns)) { $rawoutput .= fgets($ns, 128); }
fclose($ns);
//echo "";
$titlebar = $whois_page_titles["raw"];
if($use_global_templates) { echo make_changes($whois_templates["header"]); }
echo make_changes($whois_templates["raw"]);
if($use_global_templates) { echo make_changes($whois_templates["footer"]); }
exit();
}
function do_getsearch_mini()
{
global $whois_templates;
echo make_changes($whois_templates["searchmini"]);
exit();
}
function do_getsearch()
{
global $use_global_templates;
global $titlebar;
global $whois_page_titles;
global $whois_templates;
$titlebar = $whois_page_titles["search"];
if($use_global_templates) { echo make_changes($whois_templates["header"]); }
echo make_changes($whois_templates["search"]);
if($use_global_templates) { echo make_changes($whois_templates["footer"]); }
exit();
}
function do_avail()
{
global $use_global_templates;
global $titlebar;
global $whois_templates;
global $whois_page_titles;
$titlebar = $whois_page_titles["avail"];
if($use_global_templates) { echo make_changes($whois_templates["header"]); }
echo make_changes($whois_templates["avail"]);
if($use_global_templates) { echo make_changes($whois_templates["footer"]); }
exit();
}
function do_taken()
{
global $use_global_templates;
global $titlebar;
global $whois_page_titles;
global $whois_templates;
$titlebar = $whois_page_titles["taken"];
if($use_global_templates) { echo make_changes($whois_templates["header"]); }
echo make_changes($whois_templates["taken"]);
if($use_global_templates) { echo make_changes($whois_templates["footer"]); }
exit();
}
function do_exts()
{
global $use_global_templates;
global $whois_page_titles;
global $titlebar;
global $whois_templates;
$titlebar = $whois_page_titles["exts"];
if($use_global_templates) { echo make_changes($whois_templates["header"]); }
echo make_changes($whois_templates["extlist"]);
if($use_global_templates) { echo make_changes($whois_templates["footer"]); }
exit();
}
function do_glob()
{
global $vars;
global $whois_exts;
global $avail;
global $unavail;
global $use_global_templates;
global $titlebar;
global $whois_page_titles;
global $whois_templates;
$titlebar = $whois_page_titles["global"];
if($use_global_templates) { echo make_changes($whois_templates["header"]); }
if(!isset($vars["domain"])) {
echo make_changes($whois_templates["global"]);
} else{
for($l=0; $l<sizeof($whois_exts); $l++){
if(($r = perform_whois($vars["domain"], $whois_exts[$l], 0)) != -1){
if(!$r) { $unavail[] = $vars["domain"].".".$whois_exts[$l]; } else { $avail[] = $vars["domain"].".".$whois_exts[$l]; }
}
}
echo make_changes($whois_templates["globalres"]);
}
if($use_global_templates) { echo make_changes($whois_templates["footer"]); }
exit();
}
function do_wiz()
{
global $vars;
global $avail;
global $unavail;
global $use_global_templates;
global $titlebar;
global $errormsg;
global $whois_templates;
global $whois_page_titles;
$titlebar = $whois_page_titles["wiz"];
if($use_global_templates) { echo make_changes($whois_templates["header"]); }
if(!$vars["company"] && !$vars["keyword1"] && !$vars["keyword2"]) {
echo make_changes($whois_templates["wizard"]);
} else{
// remove whitespace from either side of each variable
$vars["company"] = strtolower(trim($vars["company"]));
$vars["keyword1"] = strtolower(trim($vars["keyword1"]));
$vars["keyword2"] = strtolower(trim($vars["keyword2"]));
$cdomains = array(
$vars["company"],
$vars["company"].$vars["keyword1"],
$vars["company"]."-".$vars["keyword1"],
$vars["keyword1"].$vars["company"],
$vars["keyword1"]."-".$vars["company"],
$vars["company"].$vars["keyword2"],
$vars["company"]."-".$vars["keyword2"],
$vars["keyword2"].$vars["company"],
$vars["keyword2"]."-".$vars["company"],
$vars["keyword1"],
$vars["keyword2"],
$vars["keyword1"].$vars["keyword2"],
$vars["keyword2"].$vars["keyword1"],
$vars["keyword1"]."-".$vars["keyword2"],
$vars["keyword2"]."-".$vars["keyword1"]
);
// remove any duplicates :)
$domains = @array_unique($cdomains);
for($l=0; $l<sizeof($domains); $l++){
$vars["domain"] = $domains[$l];
if(check_domain()){
if(($r = perform_whois($vars["domain"], $vars["ext"], 0)) != -1 && strlen($vars["domain"]) > 0){
if(!$r) { $unavail[] = $vars["domain"].".".$vars["ext"]; } else { $avail[] = $vars["domain"].".".$vars["ext"]; }
}
}
}
echo make_changes($whois_templates["wizres"]);
}
if($use_global_templates) { echo make_changes($whois_templates["footer"]); }
exit();
}
// this lump of code should sort out register_globals="off" problems :)
global $vars;
if(!isset($_SERVER)) { $_SERVER = $HTTP_SERVER_VARS; }
if(!isset($_POST)) { $_POST = $HTTP_POST_VARS; }
if(!isset($_GET)) { $_GET = $HTTP_GET_VARS; }
if(!isset($_COOKIE)) { $_COOKIE = $HTTP_COOKIE_VARS; }
if(!isset($_FILES)) { $_FILES = $HTTP_POST_FILES; }
if(!isset($_ENV)) { $_ENV = $HTTP_ENV_VARS; }
if(!isset($_SESSION)) { $_SESSION = $HTTP_SESSION_VARS; }
while(list($key, $var) = each($_GET)) { $vars[$key] = $var; }
while(list($key, $var) = each($_POST)) { $vars[$key] = $var; }
// try find out the script's path, if the first character is / then assume
// that the directory splitter is that too (otherwise use \)
$dir_split = "/";
if($_ENV["DOCUMENT_ROOT"] != "") {
if(substr($_ENV["DOCUMENT_ROOT"], 0, 1) != "/") {
$dir_split = "\\";
echo "\n";
}
}
echo "\n";
if(!isset($vars["domain"]) && !isset($vars["ext"]) && isset($vars["fulldomain"])) {
$vars["domain"] = ereg_replace("\..*$", "", $vars["fulldomain"]);
$vars["ext"] = str_replace($vars["domain"].".", "", $vars["fulldomain"]);
}
if(!isset($vars["fulldomain"]) && isset($vars["ext"]) && isset($vars["domain"])) {
$vars["fulldomain"] = $vars["domain"].".".$vars["ext"];
}
load_server_info();
load_template_names();
load_page_titles();
if(!check_domain()) { do_error(); }
if($vars["do_wizard"]) { do_wiz(); }
if($vars["do_global"]) { do_glob(); }
if($vars["list_exts"]) { do_exts(); }
if($vars["do_mini_search"]) { do_getsearch_mini(); }
if(!$vars["domain"]) { do_getsearch(); }
if(isset($vars["show_raw"])){
if(perform_whois($vars["domain"], $vars["ext"], 1) != -1) {
$errormsg = "MWhois internal error";
}
do_error();
}
$ret = perform_whois($vars["domain"], $vars["ext"], 0);
if($ret == -1) {
do_error();
}
if(!$ret) {
do_taken();
} else {
do_avail();
}
echo $output;