HostFact - Registrar class
Domeinnaam
Op deze pagina worden alle functies besproken om domeinnamen te kunnen registeren/verhuizen, te importeren en te beëindigen.
checkDomain()
Controle of een domeinnaam nog vrij is.
Beschikbare variabelen | Beschrijving |
---|---|
$domain | Volledige domeinnaam (incl. extensie) |
Voorbeeld implementatie
function checkDomain($domain) { $my_result = $yourproxy->checkDomain($domain); if($my_result == 'free'){ return true; }elseif($my_result == 'active'){ return false; }else{ $this->Error[] = 'Checking availability for domain TLD is not supported via our API.'; return false; } }
registerDomain()
Start het domeinregistratie proces wanneer een domeinnaam nog vrij is. De domeinnaam dient geregistreerd te worden met auto renew, er wordt namelijk iedere nieuwe periode door HostFact geen renew actie ondernomen.
Beschikbare variabelen | Beschrijving |
---|---|
$domain | Volledige domeinnaam (incl. extensie) |
$nameservers | Array met 3 nameservers (zie hoofdstuk Parameters) |
$whois | Object met WHOIS informatie (zie hoofdstuk Parameters) |
Voorbeeld implementatie
function registerDomain($domain, $nameservers = array(), $whois = null) { /** if you use DNS management, the following variables are also available * $this->DNSTemplateID * $this->DNSTemplateName */ if($response === true) { // Registration is succesfull return true; } else { // Registration failed $this->Error[] = sprintf("YourName: Error while registering '%s': ", $error_msg); return false; } }
transferDomain()
Start het verhuizen van een bestaande domeinnaam. De domeinnaam dient geregistreerd te worden met auto renew, er wordt namelijk iedere nieuwe periode door HostFact geen renew actie ondernomen.
Beschikbare variabelen | Beschrijving |
---|---|
$domain | Volledige domeinnaam (incl. extensie) |
$nameservers | Array met maximaal 3 nameservers (zie hoofdstuk Parameters) |
$whois | Object met WHOIS informatie (zie hoofdstuk Parameters) |
$authcode | Verhuiscode |
Voorbeeld implementatie
function transferDomain($domain, $nameservers = array(), $whois = null, $authcode = "") { /** if you use DNS management, the following variables are also available * $this->DNSTemplateID * $this->DNSTemplateName */ if($response === true) { // Transfer is succesfull return true; } else { // Transfer failed $this->Error[] = sprintf("YourName: Error while transferring '%s': ", $error_msg); return false; } }
getDomainList()
Haalt alle domeinnamen op bij een registrar, indien mogelijk met volledige gegevens.
Deze functie wordt gebruikt voor het importeren van domeinnamen.
Beschikbare variabelen | Beschrijving |
---|---|
$contactHandle | Optioneel: om lijst te filteren |
Voorbeeld implementatie
function getDomainList($contactHandle = "") { /** * Step 1) query domain */ // Query the domain, you can use $domain $response = true; $error_msg = ''; /** * Step 2) provide feedback to HostFact */ if($response === true) { $domain_array = array(); // Loop for all domains: $nameservers_array = array('ns1.hostfact.nl','ns2.hostfact.nl'); $whois = new whois(); $whois->ownerHandle = 'ABCD001'; $whois->adminHandle = 'ABCD001'; $whois->techHandle = 'ABCD002'; $expirationdate = '2012-05-01'; $registrationdate = '2000-05-01'; $authkey = '1234567'; // Return array with data $response = array( "Domain" => $domain, "Information" => array( "nameservers" => $nameservers_array, "whois" => $whois, "expiration_date" => $expirationdate, "registration_date" => $registrationdate, "authkey" => $authkey)); $domain_array[] = $response; // When loop is ready, return array return $domain_array; } else { // No domains can be found $this->Error[] = sprintf("YourName: Error while retreiving domains: %s", $error_msg); return false; } }
getDomainInformation()
Haalt alle informatie op over een domeinnaam: registratiegegevens, nameservers, autorisatiecode en domeinnaam contacten.
Deze functie wordt gebruikt voor het importeren van domeinnamen.
Beschikbare variabelen | Beschrijving |
---|---|
$domain | Volledige domeinnaam (incl. extensie) |
Voorbeeld implementatie
function getDomainInformation($domain) { /** * Step 1) query domain */ // Query the domain, you can use $domain $response = true; $error_msg = ''; $nameservers_array = array('ns1.hostfact.nl','ns2.hostfact.nl'); $whois = new whois(); $whois->ownerHandle = 'ABCD001'; $whois->adminHandle = 'ABCD001'; $whois->techHandle = 'ABCD002'; $expirationdate = '2012-05-01'; $registrationdate = '2000-05-01'; $authkey = '1234567'; /** * Step 2) provide feedback to HostFact */ if($response === true) { // Return array with data $response = array( "Domain" => $domain, "Information" => array( "nameservers" => $nameservers_array, "whois" => $whois, "expiration_date" => $expirationdate, "registration_date" => $registrationdate, "authkey" => $authkey)); return $response; } else { // No information can be found $this->Error[] = sprintf("YourName: Error while retreiving information about '%s': %s", $domain, $error_msg); return false; } }
getToken()
Haalt de autorisatiecode op om een domeinnaam te kunnen verhuizen.
Beschikbare variabelen | Beschrijving |
---|---|
$domain | Volledige domeinnaam (incl. extensie) |
Voorbeeld implementatie
public function getToken($domain){ /** * Step 1) get EPP code/token */ $response = true; $auth_code = 'XYZ0123'; $error_msg = ''; /** * Step 2) provide feedback to HostFact */ if($response === true) { // EPP code is retrieved return $auth_code; } else { // EPP code cannot be retrieved $this->Error[] = sprintf("YourName: Error while retreiving authorization code '%s': %s", $domain, $error_msg); return false; } }
getSyncData()
Synchroniseer gegevens van actieve domeinnamen.
Beschikbare variabelen | Beschrijving |
---|---|
$list_domains | Array met een lijst van domeinnamen, waarbij de key het domeinnaam is |
Voorbeeld implementatie
/** * getSyncData() * Check domain information for one or more domains * @param mixed $list_domains Array with list of domains. Key is domain, value must be filled. * @return mixed $list_domains */ function getSyncData($list_domains) { /** * There are two scenario's for retrieving the information * 1. Get the domain list which provide sufficient information for this function * 2. We must request the info per domain. Take care of script timeout * * Both scenario's can be found below */ $scenario = 'list'; // list | onebyone if($scenario == 'list') { /** * Scenario 1: Get the domain list which provide sufficient information for this function */ // First copy the array to $check_domains, so we can check if domains doesn't exist anymore $check_domains = $list_domains; // Ask registrar for information of all domains $response = array(); // Array with all domains and their information if($response === FALSE) { $this->Error[] = 'Domain(s) could not be retrieved at the registrar'; return FALSE; } // loop trough the domain list from the registrar foreach($response as $_domain_info) { $domain_name = 'hostfact.nl'; if(!isset($list_domains[$domain_name])) { // Not in list to sync continue; } // Add data $nameservers_array = array('ns1.hostfact.nl','ns2.hostfact.nl'); $expirationdate = '2014-05-01'; $auto_renew = 'on'; // or 'off' // extend the list_domains array with data from the registrar $list_domains[$domain_name]['Information']['nameservers'] = $nameservers_array; $list_domains[$domain_name]['Information']['expiration_date'] = (isset($expirationdate)) ? $expirationdate : ''; $list_domains[$domain_name]['Information']['auto_renew'] = (isset($auto_renew)) ? $auto_renew : ''; $list_domains[$domain_name]['Status'] = 'success'; unset($check_domains[$domain_key]); } // add errors to the domains that weren't found with the registrar if(count($check_domains) > 0) { foreach($check_domains as $domain_key => $value) { $list_domains[$domain_key]['Status'] = 'error'; $list_domains[$domain_key]['Error_msg'] = 'Domain not found'; } } // Return list return $list_domains; } elseif($scenario == 'onebyone') { /** * Scenario 2: We must request the info per domain. Take care of script timeout */ $max_domains_to_check = 10; $checked_domains = 0; // Check domain one for one foreach($list_domains as $domain_name => $value) { // Ask registrar for information of domain $response = array(); // Array with domain information if($response === FALSE) { $list_domains[$domain_name]['Status'] = 'error'; $list_domains[$domain_name]['Error_msg'] = 'Domain not found'; continue; } // Add data $nameservers_array = array('ns1.hostfact.nl','ns2.hostfact.nl'); $expirationdate = '2014-05-01'; $auto_renew = 'on'; // or 'off' // extend the list_domains array with data from the registrar $list_domains[$domain_name]['Information']['nameservers'] = $nameservers_array; $list_domains[$domain_name]['Information']['expiration_date'] = (isset($expirationdate)) ? $expirationdate : ''; $list_domains[$domain_name]['Information']['auto_renew'] = (isset($auto_renew)) ? $auto_renew : ''; $list_domains[$domain_name]['Status'] = 'success'; // Increment counter $checked_domains++; // Stop loop after max domains if($checked_domains > $max_domains_to_check) { break; } } // Return list (domains which aren't completed with data, will be synced by a next cronjob) return $list_domains; } }
deleteDomain()
Verwijdert een domeinnaam. Dit kan direct of per einde looptijd (stopt de auto renewal).
Beschikbare variabelen | Beschrijving |
---|---|
$domain | Volledige domeinnaam (incl. extensie) |
$delType | Hoe verwijderen: - 'end' = einde looptijd - 'now' = direct |
Voorbeeld implementatie
function deleteDomain($domain, $delType = 'end') { if($delType == "end"){ return $this->setDomainAutoRenew($domain, false); }else{ /** * Step 1) delete domain */ // Delete the domain, you can use $domain $response = true; /** * Step 2) provide feedback to HostFact */ if($response === true) { // Deleting is succesfull return true; } else { // Deleting failed $this->Error[] = sprintf("YourName: Error while terminating '%s': %s", $domain, $error_msg); return false; } } }
setDomainAutoRenew()
Verandert de auto renew instelling, inschakelen of beëindigen (betekent opzeggen).
Beschikbare variabelen | Beschrijving |
---|---|
$domain | Volledige domeinnaam (incl. extensie) |
$autorenew | 'true' = inschakelen 'false' = beëindigen |
Voorbeeld implementatie
function setDomainAutoRenew($domain, $autorenew = true) { /** * Step 1) change autorenew for domain */ // change autorenew for the domain, you can use $domain and $autorenew $response = true; $error_msg = ''; /** * Step 2) provide feedback to HostFact */ if($response === true) { // change is succesfull return true; } else { // change failed $this->Error[] = sprintf("YourName: Error while changing auto renew '%s': %s", $domain, $error_msg); return false; } }
lockDomain()
Lockt een domeinnaam of unlockt een gelockte domeinnaam, afhankelijk van de staat van de domeinnaam.
Beschikbare variabelen | Beschrijving |
---|---|
$domain | Volledige domeinnaam (incl. extensie) |
$lock | 'true' = locken 'false' = unlocken |
Voorbeeld implementatie
function lockDomain($domain, $lock = true) { /** * Step 1) (un)lock domain */ // (un)lock the domain, you can use $domain and $lock $response = true; $error_msg = ''; /** * Step 2) provide feedback to HostFact */ if($response === true) { // (un)locking is succesfull return true; } else { // (un)locking failed $this->Error[] = sprintf("YourName: Error while (un)locking '%s': %s", $domain, $error_msg); return false; } }