|
navigate($_REQUEST['page']);
class EP_Dev_Whois
{
var $CORE;
var $absolute_path;
/* ------------------------------------------------------------------ */
// Constructor
/* ------------------------------------------------------------------ */
function EP_Dev_Whois()
{
// set error reporting level
error_reporting(E_ALL ^ E_NOTICE);
// absolute path
$this->absolute_path = "/home/visionp/public_html/whois/";
// detect and (if necessary) set absolute path
if ($this->absolute_path == "")
$this->absolute_path = dirname(__FILE__) . "/";
// try include and error if bad abs path
if (!file_exists($this->absolute_path . "global.php"))
{
die(" Error Loading EP-Dev Whois Script: The specified absolute path is incorrect. ");
}
else
{
$include_success = require_once($this->absolute_path . "global.php");
}
// initialize core
$this->CORE = new EP_Dev_Whois_Global($this->absolute_path);
}
/* ------------------------------------------------------------------ */
// navigate to $page
// Calls on methods corresponding to $page
/* ------------------------------------------------------------------ */
function navigate($page)
{
switch ($page)
{
case "EmailImage" :
// if no image verification, just redirect request to main page
if (preg_match("/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9\.-]+$/", $_REQUEST['email']))
$this->CORE->SECURITYIMAGE->displaySecurityImage($_REQUEST['email']);
break;
case "SecurityImage" :
// if no image verification, just redirect request to main page
if (empty($this->CORE->CONFIG->SCRIPT['image_verification']))
{
$this->navigate("");
}
elseif (is_numeric($_REQUEST['code']))
$this->CORE->SECURITYIMAGE->displayImage($_REQUEST['code']);
break;
case "WhoisReport" :
$domain = $_REQUEST['domain'];
$ext = $_REQUEST['ext'];
// ensure extension exists
if (empty($ext))
$this->CORE->ERROR->stop("no_extension");
// validate domain
$this->CORE->DOMAINS->validateDomain($domain, $ext);
// validate image (if enabled)
if ($this->CORE->CONFIG->SCRIPT['image_verification'] == "gd")
{
if (is_numeric($_REQUEST['code']) && isset($_REQUEST['vcode']) && $this->CORE->SECURITYIMAGE->checkSecurityString($_REQUEST['code'], $_REQUEST['vcode'], $domain . $ext))
{
// show report
$this->page_WhoisReport($domain, $ext);
}
else
{
// show image verification page
$this->page_ImageVerification($domain, $ext);
}
}
else
{
// show report
$this->page_WhoisReport($domain, $ext);
}
break;
case "WhoisSearch" :
$base_extensions = array();
// search for all extensions
foreach(array_keys($_REQUEST) as $current_key)
{
if (ereg("^ext[0-9]+$", $current_key))
$base_extensions[] = $_REQUEST[$current_key];
}
$domains = explode("\n", str_replace("\r\n", "\n", $_REQUEST['domain']));
if ($this->CORE->CONFIG->BUYMODE['CONFIG']['enable'])
{
foreach($domains as $domain)
{
if (!empty($domain))
{
$extensions = $base_extensions;
// validate domain
$this->CORE->DOMAINS->validateDomain($domain, $extensions);
// send to search method
if (!empty($whoisQueries))
$whoisQueries = array_merge($this->go_WhoisSearch($domain, $extensions, ($_REQUEST['skip_additional'] == "1")), $whoisQueries);
else
$whoisQueries = $this->go_WhoisSearch($domain, $extensions, ($_REQUEST['skip_additional'] == "1"));
}
}
if (!empty($whoisQueries))
{
// display results
$this->page_Results($whoisQueries);
}
else
{
// validate domain to force error
$this->CORE->DOMAINS->validateDomain($domains[0], $extensions);
}
}
else
{
$extensions = $base_extensions;
// ensure extension exists
if (empty($extensions[0]))
$this->CORE->ERROR->stop("no_extension");
// validate domain
$this->CORE->DOMAINS->validateDomain($domains[0], $extensions);
// show whois report
$this->page_WhoisReport($domains[0], $extensions[0]);
}
break;
case "MultipleWhoisSearch" :
$this->page_MultipleWhoisSearch();
break;
default: $this->page_Front();
}
}
/* ------------------------------------------------------------------ */
// Whois Search
// Performs whois search on $domain with $form_extensions while
// incorporating additional script features.
// RETURN: array of whois query objects
/* ------------------------------------------------------------------ */
function go_WhoisSearch($domain, $form_extensions, $skip_autosearch = false)
{
// +------------------------------
// Log Search Parameters in session
// +------------------------------
$this->CORE->USER->setValue("domain", $domain);
$this->CORE->USER->setValue("extension", $form_extensions[0]);
$this->CORE->USER->setValue("extensions", $form_extensions);
if (!$skip_autosearch)
{
$additionalExtensions = array();
// test domain against auto search extensions (required for proper IDN support)
$autoSearchExtensions = $this->CORE->DOMAINS->getAutoSearchExtensions();
foreach($autoSearchExtensions as $current_extension)
{
// if extension works with domain, add it onto current extensions
if ($this->CORE->DOMAINS->validateDomain($domain, $current_extension, true))
{
$additionalExtensions[] = $current_extension;
}
}
// append auto-search extensions, remove duplicates
$extensions = array_unique(array_merge($form_extensions, $additionalExtensions));
}
else
{
$extensions = $form_extensions;
}
// ensure extension exists
if (empty($extensions))
$this->CORE->ERROR->stop("no_extension");
// detect log type & process logs accordingly
if ($this->CORE->CONFIG->SCRIPT['LOGS']['enable'])
{
if (!$this->CORE->CONFIG->SCRIPT['LOGS']['all'] && !empty($form_extensions))
$this->CORE->LOG->update($domain, $form_extensions);
else
$this->CORE->LOG->update($domain, $extensions);
}
// extension count
$i=0;
foreach($extensions as $current_ext)
{
// only process if extension not blank
if (!empty($current_ext))
{
// perform whois lookup
$whois_queries[$i] = $this->CORE->whoisRequest($domain, $current_ext);
$whois_queries[$i]->lookup();
$extensions_used[$current_ext] = $whois_queries[$i]->isAvailable();
$i++;
}
}
// +------------------------------
// Suggested Queries Code
// +------------------------------
// if user gave extensions and domain suggestions are enabled
$suggested_domains_enabled = $this->CORE->DOMAINS->getDomainSuggestions("", "");
if (!$skip_autosearch && !empty($form_extensions) && !empty($suggested_domains_enabled))
{
$suggested_domains = array();
foreach($form_extensions as $current_extension)
{
// if domain + extension was unavailable
if (isset($extensions_used[$current_extension]) && $extensions_used[$current_extension] == false)
$suggested_domains = array_merge($suggested_domains, $this->CORE->DOMAINS->getDomainSuggestions($domain, $current_extension));
}
// ensure no duplicates
$suggested_domains = array_unique($suggested_domains);
$suggestedDomains = array();
$suggestedExtensions = array();
// cycle through suggested domains to validate them
foreach($suggested_domains as $current_domain)
{
$current_extensions = array();
if($this->CORE->DOMAINS->validateDomain($current_domain, $current_extensions, true))
{
$suggestedDomains[] = $current_domain;
$suggestedExtensions[] = $current_extensions;
}
}
$logsDomains = array();
$logsExtensions = array();
$next = count($whois_queries);
// cycle through suggested domains / extensions and process them if the combos have not already
// been processed earlier.
for($i=0; $iCORE->whoisRequest($suggestedDomains[$i], $current_ext);
$whois_queries[$next]->lookup();
if (!$whois_queries[$next]->isAvailable())
unset($whois_queries[$next]);
else
$next++;
$success = true;
}
}
if ($success)
{
$logsDomains[] = $domain;
$logsExtensions[] = $suggestedExtensions[$i];
}
}
// detect log type & process logs accordingly (again)
if ($this->CORE->CONFIG->SCRIPT['LOGS']['enable'] && $this->CORE->CONFIG->SCRIPT['LOGS']['all'])
{
for($i=0; $iCORE->LOG->update($logsDomains[$i], $logsExtensions[$i]);
}
}
}
return $whois_queries;
}
/* ------------------------------------------------------------------ */
// Front page
// Displays front page
/* ------------------------------------------------------------------ */
function page_Front()
{
// display main page
$this->CORE->DISPLAY->constructPage("main", "", "");
$this->CORE->DISPLAY->displayPage();
}
/* ------------------------------------------------------------------ */
// Multiple Whois Search Page
// Displays multiple TLD check page
/* ------------------------------------------------------------------ */
function page_MultipleWhoisSearch()
{
// display main page
$this->CORE->DISPLAY->constructPage("multiple_tlds", "", "");
$this->CORE->DISPLAY->displayPage();
}
/* ------------------------------------------------------------------ */
// Whois Report Page
// Calls & Displays whois report for $domain and $ext
/* ------------------------------------------------------------------ */
function page_WhoisReport($domain, $ext)
{
// +------------------------------
// Log Search Parameters in session
// +------------------------------
$this->CORE->USER->setValue("domain", $domain);
$this->CORE->USER->setValue("extension", $ext);
$this->CORE->USER->setValue("extensions", array($ext));
// Log query (if enabled)
if ($this->CORE->CONFIG->SCRIPT['LOGS']['enable'])
$this->CORE->LOG->update($domain, $ext);
// +------------------------------
// Generate & Display page
// +------------------------------
// load page template
$this->CORE->DISPLAY->constructPage("report", "", "Whois Report");
// generate whois request
$whois_query = $this->CORE->whoisRequest($domain, $ext);
// perform full whois lookup
$whois_query->lookup(true);
// reload display
$this->CORE->DISPLAY->reloadCore($this->CORE);
// parse for whoisreport
$this->CORE->DISPLAY->customParse("whoisreport", $whois_query->getWhoisReport());
// display page
$this->CORE->DISPLAY->displayPage();
}
/* ------------------------------------------------------------------ */
// Image Verification Page
// Displays image verification page
/* ------------------------------------------------------------------ */
function page_ImageVerification($domain, $ext)
{
// +------------------------------
// Log Search Parameters in session
// +------------------------------
$this->CORE->USER->setValue("domain", $domain);
$this->CORE->USER->setValue("extension", $ext);
$this->CORE->USER->setValue("extensions", array($ext));
// load image verificaiton template
$this->CORE->DISPLAY->constructPage("image_verification", "", "Image Verification");
// parse for image code
$this->CORE->DISPLAY->customParse("image-code", $this->CORE->SECURITYIMAGE->getRandomNumber($domain . $ext));
$this->CORE->DISPLAY->customParse("domain", $domain);
$this->CORE->DISPLAY->customParse("ext", $ext);
// display page
$this->CORE->DISPLAY->displayPage();
}
/* ------------------------------------------------------------------ */
// Results Page
// Organizes array of query objects ($whois_queries) according to
// results page template and displays result page
/* ------------------------------------------------------------------ */
function page_Results($whois_queries)
{
// load page template
$this->CORE->DISPLAY->constructPage("results", "", "Domain Name Search Results");
$available_array = array();
$unavailable_array = array();
// cycle through queries
foreach($whois_queries as $current_query)
{
// detect if query resulted in available and sort accordingly
if ($current_query->isAvailable())
$available_array[] = $current_query;
else
$unavailable_array[] = $current_query;
}
// parse for available/unavailable extensions
$this->CORE->DISPLAY->parseAvailableDomains($available_array);
$this->CORE->DISPLAY->parseUnavailableDomains($unavailable_array);
// display page
$this->CORE->DISPLAY->displayPage();
}
}
?>
|
|