/** * This method send create domain request. * In order to pending domain creation, response must have status REGISTRY_RESPONSE_STATUS::PENDING * * @param Domain $domain * @param int $period Domain registration period * @param array $extra Extra data * @return CreateDomainResponse */ public function CreateDomain(Domain $domain, $period, $extra = array()) { $DomainInfoResp = $this->GetDomainInfo($domain); if ($DomainInfoResp->Data['DOMAIN STATUS'] != 'FIXED') { return new CreateDomainResponse(REGISTRY_RESPONSE_STATUS::FAILED, 'Domain is not available for registration'); } $params = array('DOMAIN' => $domain->Name, 'TLD' => $this->Extension, 'TERM YEARS' => $period, 'PRICE' => $DomainInfoResp->Data['PRICE']); // Nameservers $nslist = $domain->GetNameserverList(); foreach ($nslist as $i => $ns) { $params['DNS SERVER NAME ' . ($i + 1)] = $ns->HostName; } // Contacts $contacttype_srs_map = $this->ContacttypeSRSMap; foreach ($domain->GetContactList() as $contacttype => $contact) { $params[$contacttype_srs_map[$contacttype]] = $contact->CLID; } if ($extra && $this->Manifest->GetDomainConfig()->registration->extra_fields->field) { $additional_data = array(); foreach ($extra as $k => $v) { $additional_data[] = sprintf('%s:%s', $k, $v); } $params['ADDITIONAL DATA'] = join(' ', $additional_data); } $Resp = $this->Request('REGISTER DOMAIN', $params); $status = $Resp->Succeed && $Resp->Data['REQUESTID'] ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; $Ret = new CreateDomainResponse($status, $Resp->ErrMsg); if ($Ret->Succeed()) { $Ret->CreateDate = time(); $Ret->ExpireDate = (int) $Resp->Data['EXPIRATION DATE']; $Ret->AuthCode = ''; $Ret->Protocol = $Resp->Data['REQUESTID']; } return $Ret; }
/** * This method send create domain request. * In order to pending domain creation, response must have status REGISTRY_RESPONSE_STATUS::PENDING * * @param Domain $domain * @param int $period Domain registration period * @param array $extra Extra data * @return CreateDomainResponse */ public function CreateDomain(Domain $domain, $period, $extra = array()) { $this->ValidateDomain($domain); $Registrant = $domain->GetContact(CONTACT_TYPE::REGISTRANT); $Admin = $domain->GetContact(CONTACT_TYPE::ADMIN); $Tech = $domain->GetContact(CONTACT_TYPE::TECH); if (!($nameserver_list = $domain->GetNameserverList())) { throw new Exception(_("Domain nameservers list coldn't be empty")); } $flags = $domain->GetFlagList(); $hostname = $domain->GetHostName(); $is_idn = $this->RegistryAccessible->IsIDNHostName($hostname); $params = array("name" => $is_idn ? $this->RegistryAccessible->PunycodeEncode($hostname) : $hostname, "registrant" => $Registrant->CLID, "tech" => $Tech->CLID, "admin" => $Admin->CLID, "ns" => $this->GetNSXML($nameserver_list), "pw" => rand(100000000, 999999999), 'idn' => $is_idn ? "<dnslu:idn>{$hostname}</dnslu:idn>" : '', 'flags' => $this->GetFlagsXML($flags, null, 'dnslu')); // In IDN sunrise period (February 1 2010 - April 1 2010) <domain:create> command will have to be // submitted to the registry by email. The email must follow these rules: // - Recipient: idn@sunrise.dns.lu // - Sender: <your notification email address> // - Body: The raw XML of the EPP domain:create command $cur_time = time(); if ($is_idn && $cur_time > $this->IdnSunriseStart && $cur_time < $this->IdnSunriseEnd) { $Mailer = $this->GetMailer(); $Mailer->CharSet = "utf8"; $Mailer->Body = $this->Transport->ParseTemplate2("domain-create", $params); $Mailer->AddAddress("*****@*****.**"); $Mailer->Send(); $ret = new CreateDomainResponse(REGISTRY_RESPONSE_STATUS::PENDING); $ret->CreateDate = time(); $ret->ExpireDate = strtotime("+1 year", $ret->CreateDate); return $ret; } else { $response = $this->Request("domain-create", $params); if ($response->Code == RFC3730_RESULT_CODE::OK_PENDING) { $status = REGISTRY_RESPONSE_STATUS::PENDING; } elseif ($response->Succeed) { $status = REGISTRY_RESPONSE_STATUS::SUCCESS; } else { $status = REGISTRY_RESPONSE_STATUS::FAILED; } $ret = new CreateDomainResponse($status, $response->ErrMsg, $response->Code); if (!$ret->IsFailed()) { $info = $response->Data->response->resData->children($this->XmlNamespaces['domain']); $info = $info[0]; $ret->CreateDate = strtotime((string) $info->crDate[0]); $ret->ExpireDate = strtotime("+1 year", $ret->CreateDate); $ret->AuthCode = ''; $ret->Protocol = ''; } return $ret; } }
/** * Create domain and return transaction status * * Domain info is an array of the following structure: * Fill domain Data with this values * * "crDate" => string Creation DateTime, * "exDate" => Expiration DateTime, * "status" => string Status code, * "pw" => string Password generated by registry, * "protocol" => string Protocol * * @access public * @param Domain $domain Domain name without TLD * @param array $owner_contact Domain Owner contact array * @param array $admin_contact Domain Admin contact array * @param array $tech_contact Domain Tech contact array * @param array $billing_contact Domain Billing contact array * @param array $extra Domain Billing contact array * @param integer $period Registration period, years * @param array $nameservers Array of strings containing nameservers hostnames * @return Domain * */ public function CreateDomain(Domain $domain, $period, $extra = array()) { $contacts = $domain->GetContactList(); if (!$contacts['registrant']) { throw new Exception(_('Registrant contact is undefined')); } if (!$contacts['admin']) { throw new Exception(_('Admin contact is undefined')); } if (!$contacts['tech']) { throw new Exception(_('Tech contact is undefined')); } if (!$contacts['billing']) { throw new Exception(_('Billing contact is undefined')); } $nameservers = $domain->GetNameserverList(); $params = array("ownercontact0" => $contacts['registrant']->CLID, "techcontact0" => $contacts['tech'] ? $contacts['tech']->CLID : "", "admincontact0" => $contacts['admin'] ? $contacts['admin']->CLID : "", "billingcontact0" => $contacts['billing'] ? $contacts['billing']->CLID : "", "nameserver0" => $nameservers[0]->HostName, "nameserver1" => $nameservers[1]->HostName, "period" => $period, "auth" => $this->GeneratePassword(), "domain" => $this->MakeNameIDNCompatible($domain->GetHostName())); $params = array_merge($params, (array) $extra); if ($this->PromotionCodes[$this->Extension]) { $params["X-PROMOTION-CODE"] = $this->PromotionCodes[$this->Extension]; } $response = $this->Request("AddDomain", $params); $status = $response->Succeed ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; $resp = new CreateDomainResponse($status, $response->ErrMsg, $response->Code); if (!$resp->IsFailed()) { // Match domain expiration date preg_match("/property\\[registration expiration date\\]\\[0\\][\\s]*=[\\s]*(.*?)\n/si", $response->Data, $matches); $time = strtotime($matches[1]); $resp->ExpireDate = $time; // Set create date as NOW $resp->CreateDate = time(); // Auth code $resp->AuthCode = (string) $params["auth"]; // Match domain renewal date // (Date when RRPPROXY will execute renewal cron if TLD supports auto renewal) $autorenew = (int) $this->Manifest->GetRegistryOptions()->ability->auto_renewal; if ($autorenew) { preg_match("/property\\[renewal date\\]\\[0\\][\\s]*=[\\s]*(.*?)\n/si", $response->Data, $matches); $domain->SetExtraField('RenewalDate', strtotime($matches[1])); } // Set renewal mode $mode = $autorenew ? 'AUTORENEW' : 'AUTOEXPIRE'; $this->Request('SetDomainRenewalMode', array('domain' => $params['domain'], 'renewalmode' => $mode)); } return $resp; }