/** * This method request registry for information about domain * * @param Domain $domain * @return GetRemoteDomainResponse */ public function GetRemoteDomain(Domain $domain) { $params = array( "name" => $this->MakeNameIDNCompatible($domain->GetHostName()), 'authinfo' => '' ); if ($domain->AuthCode) $params['authinfo'] = "<domain:authInfo><domain:pw>{$domain->AuthCode}</domain:pw></domain:authInfo>"; $this->BeforeRequest('domain-info', $params, __METHOD__, $domain); $response = $this->Request("domain-info", $params); $status = ($response->Succeed) ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; $resp = new GetRemoteDomainResponse($status, $response->ErrMsg, $response->Code); $resp->RawResponse = $response->Data; if ($response->Succeed) { $info = $response->Data->response->resData->children($this->XmlNamespaces['domain']); $info = $info[0]; $resp->CLID = (string)$info->clID[0]; try { $resp->CRID = (string)$info->crID[0]; } catch(Exception $e){} if ($resp->CRID) { $resp->AuthCode = ($info->authInfo[0]) ? (string)$info->authInfo[0]->pw[0] : ""; $resp->CreateDate = $this->StrToTime((string)$info->crDate[0]); if ($info->exDate[0]) { $resp->ExpireDate = $this->StrToTime((string)$info->exDate[0]); } // Get contacts foreach ($info->contact as $k=>$v) { $attrs = $v->attributes(); $ctype = (string)$attrs["type"]; switch($ctype) { case "admin": $resp->AdminContact = (string)$v; break; case "tech": $resp->TechContact = (string)$v; break; case "billing": $resp->BillingContact = (string)$v; break; } } $resp->RegistrantContact = (string)$info->registrant[0]; // Get nameservers $ns_arr = array(); $registryOptionsConfig = $this->Manifest->GetRegistryOptions(); if ((bool)$registryOptionsConfig->ability->hostattr) { // Iterate over hostAttr if ($info->ns->hostAttr) { foreach ($info->ns->hostAttr as $hostAttr) { $hostName = (string)$hostAttr->hostName; if ($hostAttr->hostAddr[0]) { $ns = new NameserverHost($hostName, (string)$hostAttr->hostAddr[0]); } else { $ns = new Nameserver($hostName); } $ns_arr[] = $ns; } } } else { // Iterate over hostObj if ($info->ns->hostObj) { foreach ($info->ns->hostObj as $v) { $hostname = (string)strtolower($v); if (FQDN::IsSubdomain($hostname, $domain->GetHostName())) { try { $ip = $this->GetHostIpAddress($hostname); $ns_arr[] = new NameserverHost($hostname, $ip); } catch (Exception $e) { $ns_arr[] = new NameserverHost($hostname, ''); } } else { // nameserver $ns_arr[] = new Nameserver($hostname); } } } } $resp->SetNameserverList($ns_arr); // Flags (Domain status) $flags = array(); foreach ($info->status as $status) { $flags[] = (string)$status->attributes()->s; } $resp->RegistryStatus = (string)$flags[0]; // Remove default 'ok' status from domain flags if (($i = array_search("ok", $flags)) !== false) { array_splice($flags, $i, 1); } $resp->SetFlagList($flags); } } return $resp; }
/** * This method request registry for information about domain * * @param Domain $domain * @return GetRemoteDomainResponse */ public function GetRemoteDomain(Domain $domain) { $hostname = $domain->GetHostName(); $is_idn = $this->RegistryAccessible->IsIDNHostName($hostname); $params = array('name' => $is_idn ? $this->RegistryAccessible->PunycodeEncode($hostname) : $hostname); $response = $this->Request("domain-info", $params); $status = $response->Succeed ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; $ret = new GetRemoteDomainResponse($status, $response->ErrMsg, $response->Code); if ($ret->Succeed()) { $info = $response->Data->response->resData->children($this->XmlNamespaces['domain']); $info = $info[0]; $ret->CRID = (string) $info->crID[0]; $ret->CLID = (string) $info->clID[0]; if ($ret->CLID) { // Contacts $ret->RegistrantContact = (string) $info->registrant[0]; $contact = $info->xpath('domain:contact[@type="admin"]'); $ret->AdminContact = (string) $contact[0]; $contact = $info->xpath('domain:contact[@type="tech"]'); $ret->TechContact = (string) $contact[0]; $ret->CreateDate = strtotime($info->crDate[0]); $ret->ExpireDate = strtotime($info->exDate[0]); // Nameservers $ns_arr = array(); foreach ($info->xpath('domain:ns/domain:hostObj') as $hostObj) { $hostname = (string) $hostObj; if (FQDN::IsSubdomain($hostname, $domain->GetHostName())) { try { $ip = $this->GetHostIpAddress($hostname); $ns_arr[] = new NameserverHost($hostname, $ip); } catch (Exception $e) { $ns_arr[] = new NameserverHost($hostname, ''); } } else { // nameserver $ns_arr[] = new Nameserver($hostname); } } $ret->SetNameserverList($ns_arr); // Flags $flags = array(); if ($nodes = $info->xpath('domain:status/@s')) { foreach ($nodes as $flag) { $flags[] = (string) $flag; } } if ($nodes = $response->Data->xpath('//dnslu:domain/dnslu:status')) { foreach ($nodes as $flag) { $flags[] = (string) $flag; } } $ret->RegistryStatus = (string) $flags[0]; $flags = array_filter($flags); // Remove default 'ok' status from domain flags if (($i = array_search("ok", $flags)) !== false) { array_splice($flags, $i, 1); } $ret->SetFlagList($flags); } $ret->AuthCode = ''; $ret->Protocol = ''; } return $ret; }
$okmsg = sprintf(_("Managed DNS disabled successfully for %s"), $Domain->GetHostName()); CoreUtils::Redirect("ns.php"); } } elseif ($post_task == "modify") { $registryOptions = $Registry->GetManifest()->GetRegistryOptions(); $host_as_attr = (bool)$registryOptions->ability->hostattr; $nslist = array(); foreach ($post_ns as $k => $hostname) { if ($hostname && !in_array($hostname, (array)$post_delete)) { if ($host_as_attr && FQDN::IsSubdomain($hostname, $Domain->GetHostName())) { $nslist[] = new NameserverHost($hostname, $post_ns_ip[$k]); } else { $nslist[] = new Nameserver($hostname); } } } try { $Action = new UpdateDomainNameserversAction($Domain, $nslist); $result = $Action->Run($_SESSION['userid']); if ($result == UpdateDomainNameserversAction_Result::OK)
$full_dmn_name = "{$_SESSION["domaininfo"]["name"]}.{$_SESSION["domaininfo"]["extension"]}"; if ($_POST["enable_managed_dns"]) { $_POST["ns1"] = CONFIG::$NS1; $_POST["ns2"] = CONFIG::$NS2; } else { foreach (array("ns1", "ns2") as $k) { if (!$Validator->IsDomain($_POST[$k])) $exception->AddMessage(sprintf(_("%s is not a valid host"), $_POST[$k])); else { $isglue = FQDN::IsSubdomain($_POST[$k], $full_dmn_name); if ($isglue) $exception->AddMessage(sprintf(_("%s cannot be used as nameserver because %s is not registered yet."), $_POST[$k], $full_dmn_name)); } } if ($_POST["ns1"] == $_POST["ns2"]) $exception->AddMessage(_("You cannot use the same nameserver twice.")); } if ($exception->hasMessages()) throw $exception; if ($_SESSION["domaininfo"]["id"]) $Domain = DBDomain::GetInstance()->LoadByName($_SESSION["domaininfo"]["name"], $_SESSION["domaininfo"]["extension"]); else
/** * Return information about domain * * @access public * @param Domain $domain * @return GetRemoteDomainResponse Domain info if the following format: */ public function GetRemoteDomain(Domain $domain) { $params = array( "name" => $this->MakeNameIDNCompatible($domain->GetHostName()), 'authinfo' => '' ); if ($domain->AuthCode) $params['authinfo'] = "<domain:authInfo><domain:pw>".$this->EscapeXML($domain->AuthCode)."</domain:pw></domain:authInfo>"; $response = $this->Request("domain-info", $params); $status = ($response->Succeed) ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; $resp = new GetRemoteDomainResponse($status, $response->ErrMsg, $response->Code); if ($response->Succeed) { $info = $response->Data->response->resData->children("urn:ietf:params:xml:ns:domain-1.0"); $info = $info[0]; $resp->CLID = (string)$info->clID[0]; $resp->AuthCode = ($info->authInfo[0]) ? (string)$info->authInfo[0]->pw[0] : ""; if ($info->exDate[0]) { $resp->ExpireDate = $this->StrToTime((string)$info->exDate[0]); $resp->CreateDate = $resp->ExpireDate-(86400*365); } foreach ($info->contact as $k=>$v) { $attrs = $v->attributes(); $ctype = (string)$attrs["type"]; switch($ctype) { case "tech": $resp->TechContact = (string)$v; break; } } $resp->RegistrantContact = (string)$info->registrant[0]; // Get nameservers $ns_arr = array(); foreach ($info->ns->hostObj as $v) { $hostname = (string)$v; if (FQDN::IsSubdomain($hostname, $domain->GetHostName())) { try { $ip = $this->GetHostIpAddress($hostname); $ns_arr[] = new NameserverHost($hostname, $ip); } catch (Exception $e) { $ns_arr[] = new NameserverHost($hostname, ''); } } else { // nameserver $ns_arr[] = new Nameserver($hostname); } } $resp->SetNameserverList($ns_arr); if ($info->status[0]) $attrs = $info->status[0]->attributes(); elseif ($info->status) $attrs = $info->status->attributes(); else $attrs["s"] = false; $resp->RegistryStatus = (string)$attrs["s"]; } return $resp; }
private function CreateObject($row, RegistryManifest $registry_manifest = null) { /* if ($registry_manifest == null) { $registry = RegistryModuleFactory::GetInstance()->GetRegistryByExtension($row['TLD']); $registry_manifest = $registry->GetManifest(); unset($registry); } */ // TODO // ���������� ���������� �� ������������ ������, ���� ������� ���� �������� // ��������� ������� Domain // $registry = RegistryModuleFactory::GetInstance()->GetRegistryByExtension($row['TLD']); if (!$registry) { throw new Exception(sprintf(_("Registry module not defined for '%s' domain extension"), $row['TLD'])); } $domain = $registry->NewDomainInstance(); $registry_manifest = $registry->GetManifest(); //unset($registry); // Normalize DB data $row['start_date'] = strtotime($row['start_date']); $row['end_date'] = strtotime($row['end_date']); $row['dtTransfer'] = strtotime($row['dtTransfer']); $row["islocked"] = (bool) $row["islocked"]; $row['managed_dns'] = (bool) $row['managed_dns']; // Normalize nameservers data $ns_arr = array(); if ($row['ns1']) { $ns_arr[] = $row['ns1']; } if ($row['ns2']) { $ns_arr[] = $row['ns2']; } if ($row['ns_n']) { $ns_n = array_map('trim', explode(';', $row['ns_n'])); foreach ($ns_n as $hostname) { $ns_arr[] = $hostname; } } // Load glue records $arr = $this->DB->GetAll('SELECT * FROM nhosts WHERE domainid = ?', array($row['id'])); $glue_records = array(); foreach ($arr as $tmp) { $glue_records["{$tmp['hostname']}.{$row['name']}.{$row['TLD']}"] = $tmp; } // Create nameservers list $nslist = array(); foreach ($ns_arr as $hostname) { // Check that nameserver is glue record. if (FQDN::IsSubdomain($hostname, "{$row["name"]}.{$row["TLD"]}") && array_key_exists($hostname, $glue_records)) { $nshost = new NameserverHost($hostname, $glue_records[$hostname]['ipaddr']); $nshost->ID = $glue_records[$hostname]['id']; $nslist[] = $nshost; } else { $nslist[] = new Nameserver($hostname); } } // Map fields to properties foreach ($this->FieldPropertyMap as $field => $property) { $domain->{$property} = $row[$field]; } // Set nameservers $domain->SetNameserverList($nslist); // Load extra fields $extra_fields = $this->DB->GetAll('SELECT `key`, `value` FROM domains_data WHERE domainid = ?', array($domain->ID)); foreach ($extra_fields as $ext_row) { $domain->{$ext_row['key']} = $ext_row['value']; $domain->SetExtraField($ext_row['key'], $ext_row['value']); } // Load flags $flags_data = $this->DB->GetAll('SELECT DISTINCT flag FROM domains_flags WHERE domainid = ?', array($domain->ID)); $flag_list = array(); foreach ($flags_data as $flag_row) { $flag_list[] = $flag_row['flag']; } $domain->SetFlagList($flag_list); // Load contacts foreach ($this->ContactFieldTypeMap as $field => $contact_type) { $CLID = $row[$field]; if ($CLID) { try { $contact = $this->DBContact->LoadByCLID($CLID, $registry_manifest); } catch (Exception $e) { $contact = $registry->NewContactInstance($contact_type); $contact->CLID = $CLID; } $domain->SetContact($contact, $contact_type); } } // Add pending operations to domain $operations = $this->DB->Execute("SELECT * FROM pending_operations WHERE objecttype='DOMAIN' AND objectid=?", array($domain->ID)); while ($op = $operations->FetchRow()) { if ($op) { $domain->AddPendingOperation($op["operation"]); } } // Add domain to loaded objects storage $this->LoadedObjects[$domain->ID] = clone $domain; return $domain; }
/** * This method request registry for information about domain * * @param Domain $domain * @return GetRemoteDomainResponse */ public function GetRemoteDomain(Domain $domain) { $Resp = $this->Whois($domain); $status = $Resp->Succeed ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; $Ret = new GetRemoteDomainResponse($status, $Resp->ErrMsg); if ($Ret->Succeed()) { $ns_arr = array(); foreach ($Resp->Data as $k => $v) { if (stristr($k, "DNS SERVER")) { $hostname = (string) $v; if (FQDN::IsSubdomain($hostname, $domain->GetHostName())) { try { $ip = $this->GetHostIpAddress($hostname); $ns_arr[] = new NameserverHost($hostname, $ip); } catch (Exception $e) { $ns_arr[] = new NameserverHost($hostname, ''); } } else { // nameserver $ns_arr[] = new Nameserver($hostname); } } } $Ret->SetNameserverList($ns_arr); $Ret->CRID = $this->Config->GetFieldByName('Login')->Value; $Ret->CLID = $this->Config->GetFieldByName('Login')->Value; $Ret->CreateDate = (int) $Resp->Data['REGISTRATION DATE']; $Ret->ExpireDate = (int) $Resp->Data['EXPIRATION DATE']; $Ret->RegistryStatus = 'ok'; $Ret->RegistrantContact = $Resp->Data['RESPONSIBLE PERSON']; $Ret->BillingContact = $Resp->Data['BILLING CONTACT']; $Ret->AdminContact = $Resp->Data['ADMIN CONTACT']; $Ret->TechContact = $Resp->Data['TECHNICAL CONTACT']; } return $Ret; }
/** * Return information about domain * * @access public * @param Domain $domain * @return GetRemoteDomainResponse */ public function GetRemoteDomain(Domain $domain) { if ($domain->AuthCode) { $pw = "<domain:authInfo>\r\n\t\t\t\t\t\t<domain:pw>" . $this->EscapeXML($domain->AuthCode) . "</domain:pw>\r\n\t\t\t\t\t</domain:authInfo>"; } else { $pw = ''; } $response = $this->Request("domain-info", array("name" => "{$domain->Name}.{$this->Extension}", "pw" => $pw)); $status = $response->Succeed ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; $resp = new GetRemoteDomainResponse($status, $response->ErrMsg, $response->Code); if ($response->Succeed) { $info = $response->Data->response->resData->children("urn:ietf:params:xml:ns:domain-1.0"); $info = $info[0]; $resp->CLID = (string) $info->clID[0]; try { $resp->CRID = (string) $info->crID[0]; } catch (Exception $e) { } if ($resp->CRID) { $resp->AuthCode = $info->authInfo[0] ? (string) $info->authInfo[0]->pw[0] : ""; $resp->CreateDate = $this->StrToTime((string) $info->crDate[0]); $resp->ExpireDate = $this->StrToTime((string) $info->exDate[0]); $extdomain = $response->Data->response->extension->children("urn:ics-forth:params:xml:ns:extdomain-1.1"); $resp->Protocol = (string) $extdomain->resData->protocol[0]; foreach ($info->contact as $k => $v) { $attrs = $v->attributes(); $ctype = (string) $attrs["type"]; switch ($ctype) { case "admin": $resp->AdminContact = (string) $v; break; case "tech": $resp->TechContact = (string) $v; break; case "billing": $resp->BillingContact = (string) $v; break; } } $resp->RegistrantContact = (string) $info->registrant[0]; // Get nameservers // TODO: testit $ns_arr = array(); foreach ($info->ns->hostObj as $v) { $hostname = (string) $v; if (FQDN::IsSubdomain($hostname, $domain->GetHostName())) { try { $ip = $this->GetHostIpAddress($hostname); $ns_arr[] = new NameserverHost($hostname, $ip); } catch (Exception $e) { $ns_arr[] = new NameserverHost($hostname, ''); } } else { // nameserver $ns_arr[] = new Nameserver($hostname); } } $resp->SetNameserverList($ns_arr); if ($info->status[0]) { $attrs = $info->status[0]->attributes(); } elseif ($info->status) { $attrs = $info->status->attributes(); } else { $attrs["s"] = false; } $resp->RegistryStatus = (string) $attrs["s"]; } } return $resp; }
public function Run(Domain $Domain) { Log::Log("Start domain registration action", E_USER_NOTICE); $ErrList = new ErrorList(); if (!($Domain->Name && $Domain->Period && $Domain->UserID)) { throw new Exception("Domain must have name, period and userid filled"); } if ($this->do_check) { // Perform a domain check $chk = $this->Registry->DomainCanBeRegistered($Domain); if (!$chk->Result) { throw new Exception("Domain cannot be registered" . ($chk->Reason ? ". Reason: {$chk->Reason}" : "")); } } if ($this->period) { $Domain->Period = $this->period; } else { self::ValidatePeriod($Domain->Period, $this->Registry); } /* * Set nameservers */ if (!$this->managed_dns_enabled) { $domain_hostname = $Domain->GetHostName(); foreach ($this->nameserver_list as $Nameserver) { if (FQDN::IsSubdomain($Nameserver->HostName, $domain_hostname)) { $ErrList->AddMessage(sprintf(_("%s cannot be used as nameserver because %s is not registered yet."), $Nameserver->HostName, $domain_hostname)); } } } // Break on errors $this->ExceptionOnErrors($ErrList); $Domain->IsManagedDNSEnabled = $this->managed_dns_enabled; $Domain->SetNameserverList($this->nameserver_list); /* * Set contacts */ foreach ($this->contact_list as $ctype => $Contact) { try { $Domain->SetContact($Contact, $ctype); } catch (Exception $e) { $ErrList->AddMessage(sprintf(_("Cannot set %s contact to %s. %s"), $ctype, $clid, $e->getMessage())); } } // Break on errors $this->ExceptionOnErrors($ErrList); /* * Set additional domain data */ if ($this->extra_data) { foreach ($this->extra_data as $field) { $Domain->SetExtraField($field['name'], $this->extra_data[$field['name']]); } } /* * Register domain */ if ($Domain->IncompleteOrderOperation == INCOMPLETE_OPERATION::DOMAIN_CREATE) { Log::Log("Trying to register domain. (Postpaid)", E_USER_NOTICE); try { $this->Registry->CreateDomain($Domain, $Domain->Period, $this->extra_data); return $Domain->HasPendingOperation(Registry::OP_CREATE) ? RegisterDomainAction_Result::PENDING : RegisterDomainAction_Result::OK; } catch (Exception $e) { Log::Log($e->getMessage(), E_USER_ERROR); throw new RegisterDomainAction_Exception($e->getMessage()); } } else { $Domain->Status = DOMAIN_STATUS::AWAITING_PAYMENT; try { DBDomain::GetInstance()->Save($Domain); } catch (Exception $e) { Log::Log($e->getMessage(), E_USER_ERROR); throw new RegisterDomainAction_Exception(sprintf(_('Cannot save domain. Reason: %s'), $e->getMessage())); } try { $Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_CREATE, $Domain->ID, $Domain->UserID); $Invoice->Description = sprintf(_("%s domain name registration for %s year(s)"), $Domain->GetHostName(), $Domain->Period); if ($this->Order) { // In case of order add invoice. $this->Order->AddInvoice($Invoice); // Save operation must be called from order } else { $Invoice->Save(); $this->Invoice = $Invoice; } return RegisterDomainAction_Result::INVOICE_GENERATED; } catch (Exception $e) { throw new RegisterDomainAction_Exception(sprintf(_("Cannot create invoice. Reason: %s"), $e->getMessage())); } } }
/** * This method request registry for information about domain * * @param Domain $domain * @return GetRemoteDomainResponse */ public function GetRemoteDomain(Domain $domain) { $params = array("name" => $this->MakeNameIDNCompatible($domain->GetHostName()), 'authinfo' => '', 'subproduct' => 'dot' . strtoupper($this->Extension)); if ($domain->AuthCode) { $params['authinfo'] = "<domain:authInfo><domain:pw>{$domain->AuthCode}</domain:pw></domain:authInfo>"; } $response = $this->Request("domain-info", $params); $status = $response->Succeed ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; $resp = new GetRemoteDomainResponse($status, $response->ErrMsg, $response->Code); $response->Data->registerXPathNamespace('rgp', $this->XmlNamespaces['rgp']); if ($response->Succeed) { $info = $response->Data->response->resData->children($this->XmlNamespaces['domain']); $info = $info[0]; $resp->CLID = (string) $info->clID[0]; try { $resp->CRID = (string) $info->crID[0]; } catch (Exception $e) { } if ($resp->CRID) { $resp->AuthCode = $info->authInfo[0] ? (string) $info->authInfo[0]->pw[0] : ""; $resp->CreateDate = $this->StrToTime((string) $info->crDate[0]); $resp->ExpireDate = $this->StrToTime((string) $info->exDate[0]); // Request whois for contacts $domain_whois = $this->Db->GetRow("\r\n\t\t\t\t\t\tSELECT * FROM whois_domain WHERE domain = ?", array($domain->GetHostName())); if ($domain_whois) { $resp->RegistrantContact = $this->PersonIdToCLID($domain_whois['holder']); $resp->AdminContact = $this->PersonIdToCLID($domain_whois['admin_c']); $resp->TechContact = $this->PersonIdToCLID($domain_whois['tech_c']); $resp->BillingContact = $this->PersonIdToCLID($domain_whois['bill_c']); } // Get nameservers $ns_arr = array(); if ($info->ns) { foreach ($info->ns->hostObj as $v) { $hostname = (string) $v; if (FQDN::IsSubdomain($hostname, $domain->GetHostName())) { try { $ip = $this->GetHostIpAddress($hostname); $ns_arr[] = new NameserverHost($hostname, $ip); } catch (Exception $e) { $ns_arr[] = new NameserverHost($hostname, ''); } } else { // nameserver $ns_arr[] = new Nameserver($hostname); } } } $resp->SetNameserverList($ns_arr); // Flags (Domain status) $flags = array(); if ($nodes = $info->xpath('domain:status/@s')) { foreach ($nodes as $flag) { $flags[] = (string) $flag; } } // Not works. Why ?? // if ($nodes = $response->Data->response->xpath('//rgp:infData/rgp:rgpStatus/@s')) // foreach ($nodes as $flag) // $flags[] = (string)$flag; // Intead of glamour XPath expression use ugly hack if ($response->Data->response->extension) { $rgpInfo = $response->Data->response->extension->children($this->XmlNamespaces['rgp']); foreach ($rgpInfo->rgpStatus as $status) { $flag[] = (string) $status->attributes()->s; } } $resp->SetFlagList($flags); $resp->RegistryStatus = $flags[0]; } } return $resp; }