public function isDomainAvailable(Registrar_Domain $domain) { $params = array('domain-name' => $domain->getSld(), 'tlds' => array($domain->getTld(false)), 'suggest-alternative' => false); $result = $this->_makeRequest('domains/available', $params); if (!isset($result[$domain->getName()])) { return true; } $check = $result[$domain->getName()]; if ($check && $check['status'] == 'available') { return true; } return false; }
/** * Creates domain object from received data array. * @param Registrar_Domain $domain * @return Registrar_Domain */ private function _createDomainObj($result, Registrar_Domain $domain) { $type = 'contacts_registrant_'; $tel = explode('.', $result[$type . 'phonenumber']); // domain specific if (array_key_exists($type . 'firstname', $result)) { $name = $result[$type . 'firstname']; } if (array_key_exists($type . 'lastname', $result)) { $name .= ' ' . $result[$type . 'lastname']; } if (!array_key_exists($type . 'organization', $result)) { $result[$type . 'organization'] = ''; } if ($domain->getTld() == 'fr') { $name = $result[$type . 'dotfrcontactentityname']; } if ($domain->getTld() == 'it') { $result['transferauthinfo'] = ''; } $c = new Registrar_Domain_Contact(); $c->setName($name)->setEmail($result[$type . 'email'])->setCompany($result[$type . 'organization'])->setTel($tel[1])->setTelCc($tel[0])->setAddress1($result[$type . 'street'])->setAddress2($result[$type . 'street2'])->setAddress3($result[$type . 'street3'])->setCity($result[$type . 'city'])->setCountry($result[$type . 'country'])->setZip($result[$type . 'postalcode']); if (isset($result['nameserver_0'])) { $domain->setNs1($result['nameserver_0']); } if (isset($result['nameserver_1'])) { $domain->setNs2($result['nameserver_1']); } if (isset($result['nameserver_2'])) { $domain->setNs3($result['nameserver_2']); } if (isset($result['nameserver_3'])) { $domain->setNs4($result['nameserver_3']); } $privacy = 0; if (array_key_exists('privatewhois', $result)) { $privacy = $result['privatewhois'] == 'FULL' || $result['privatewhois'] == 'PARTIAL'; } $domain->setExpirationTime(strtotime($result['expirationdate'])); $domain->setPrivacyEnabled($privacy); $domain->setEpp($result['transferauthinfo']); $domain->setContactRegistrar($c); return $domain; }
/** * * Toggles domain transfer lock * @param Registrar_Domain $domain * @param integer $lock * @return bool */ private function _toggleDomainLock(Registrar_Domain $domain, $lock = 0) { $params = array('command' => 'SetRegLock', 'TLD' => $domain->getTld(), 'SLD' => $domain->getSld(), 'UnlockRegistrar' => $lock); $result = $this->_makeRequest($params); if ((string) $result->RegistrarLock == 'ACTIVE') { return true; } return false; }
public function registerDomain(Registrar_Domain $domain) { //if($this->_hasCompletedOrder($domain)) { // return true; //} $tld = $domain->getTld(); $customer = $this->_getCustomerDetails($domain); $customer_id = $customer['customer_id']; $ns = array(); $ns[] = $domain->getNs1(); $ns[] = $domain->getNs2(); if ($domain->getNs3()) { $ns[] = $domain->getNs3(); } if ($domain->getNs4()) { $ns[] = $domain->getNs4(); } //list($reg_contact_id, $admin_contact_id, $tech_contact_id, $billing_contact_id) = $this->_getAllContacts($tld, $customer_id, $domain->getContactRegistrar()); $contacts = $this->_getDefaultContactDetails($domain, $customer_id); $reg_contact_id = $contacts['registrant_contact']['contact_id']; $admin_contact_id = $contacts['admin_contact']['contact_id']; $tech_contact_id = $contacts['tech_contact']['contact_id']; $billing_contact_id = $contacts['billing_contact']['contact_id']; $params = array('domain_name' => $domain->getName(), 'years' => $domain->getRegistrationPeriod(), 'ns' => implode(',', $ns), 'customer_id' => $customer_id, 'registrant_contact_id' => $reg_contact_id, 'admin_contact_id' => $admin_contact_id, 'tech_contact_id' => $tech_contact_id, 'billing_contact_id' => $billing_contact_id, 'invoice_option' => 'no_invoice'); if ($tld == '.asia') { $params['extra'] = 'asia_contact_id=0'; } if (in_array($tld, ['.EU', '.NZ', '.RU', '.UK'])) { $params['admin_contact_id'] = -1; } if (in_array($tld, ['.EU', '.AT', '.BERLIN', '.CA', '.NL', '.NZ', '.RU', '.UK'])) { $params['billing_contact_id'] = -1; } if (in_array($tld, ['.EU', '.NZ', '.RU', '.UK'])) { $params['tech_contact_id'] = -1; } $result = $this->_makeRequest('domains', $params, 'POST'); return $result['status'] == 'Success'; }
/** * transfer domain * @return boolean */ public function transferDomain(Registrar_Domain $domain) { $tld = ltrim($domain->getTld(), '.'); $cust = $domain->getContactRegistrar(); $cust_email = $cust->getEmail(); $customer = $this->_getCustomerDetails($domain, $cust_email); if (is_array($customer)) { foreach ($customer as $cus) { $cus['email'] = trim(strtolower($cus['email'])); if ($cus['email'] == $cust_email) { $customer_id = $cus['customer_id']; } } } $get_defaultContact = $this->_getDefaultContactDetails($customer_id, $tld, $cust); $reg_contact_id = $get_defaultContact['registrant_contact']['contact_id']; $admin_contact_id = $get_defaultContact['admin_contact']['contact_id']; $tech_contact_id = $get_defaultContact['tech_contact']['contact_id']; $billing_contact_id = $get_defaultContact['billing_contact']['contact_id']; $ns_ = array(); $ns_[] = $domain->getNs1(); $ns_[] = $domain->getNs2(); if ($domain->getNs3()) { $ns_[] = $domain->getNs3(); } if ($domain->getNs4()) { $ns_[] = $domain->getNs4(); } $ns = implode(',', $ns_); // cek default ns customer LQ $def_ns = $this->_makeRequest('customers/' . $customer_id . '/ns/default'); $lq_defaultns = array(); if (!empty($def_ns["body"]["ns1"])) { // ambil defaultnya ns1 $lq_defaultns[] = $def_ns["body"]["ns1"]; } if (!empty($def_ns["body"]["ns2"])) { // ambil defaultnya ns2 $lq_defaultns[] = $def_ns["body"]["ns2"]; } if (!empty($def_ns["body"]["ns3"])) { // ambil defaultnya ns3 $lq_defaultns[] = $def_ns["body"]["ns3"]; } if (!empty($def_ns["body"]["ns4"])) { // ambil defaultnya ns4 $lq_defaultns[] = $def_ns["body"]["ns4"]; } // simpan sementara $default_ns = implode(",", $lq_defaultns); if ($this->isTestEnv()) { // khusus testmode di bikin spt berikut $default_ns = 'ns1.liqu.id,ns2.liqu.id'; } // cek kalau ns nya kosong ambil dari default nya customer if (empty($ns)) { $ns = $default_ns; } $required_params = array('domain_name' => $domain->getName(), 'auth_code' => $domain->getEpp(), 'ns' => $ns, 'customer_id' => $customer_id, 'registrant_contact_id' => $reg_contact_id, 'admin_contact_id' => $admin_contact_id, 'tech_contact_id' => $tech_contact_id, 'billing_contact_id' => $billing_contact_id, 'years' => $domain->getRegistrationPeriod(), 'invoice_option' => 'no_invoice', 'protect_privacy' => false); if ($tld == 'asia') { $required_params['extra'] = 'asia_contact_id=' . $reg_contact_id; } if ($tld == 'us') { $required_params['extra'] = 'us_contact_id=' . $reg_contact_id; } try { $result = $this->_makeRequest('domains/transfer', $required_params, 'post'); } catch (Registrar_Exception $e) { // jika gagal karena NS, set ns ke $default_ns // kemudian di register lagi domainnya if (strpos($e->getMessage(), "is not valid NameServer")) { $required_params['ns'] = $default_ns; $result = $this->_makeRequest('domains/transfer', $required_params, 'post'); } } if (!empty($result['domain_id'])) { $result['status'] = 'Success'; } else { $result['status'] = 'Failed'; } return $result['status'] == 'Success'; }
public function modifyNs(Registrar_Domain $domain) { $nameServers = array(); if (!is_null($domain->getNs1())) { $nameServers[] = $domain->getNs1(); } if (!is_null($domain->getNs2())) { $nameServers[] = $domain->getNs2(); } if (!is_null($domain->getNs3())) { $nameServers[] = $domain->getNs3(); } if (!is_null($domain->getNs4())) { $nameServers[] = $domain->getNs4(); } $nameServers = implode(",", $nameServers); $params = array('Command' => 'namecheap.domains.dns.setCustom', 'SLD' => $domain->getSld(), 'TLD' => $domain->getTld(false), 'NameServers' => $nameServers); $respond = $this->_call($params); if ($respond === false) { return false; } $status = $respond->CommandResponse->DomainDNSSetCustomResult->attributes(); if (strtolower($status['Update']) == 'true') { return true; } else { return false; } }