/** * Executor * * @throws UpdateDomainContactTask_Exception */ public function Run($userid = null) { try { $Factory = RegistryModuleFactory::GetInstance(); $Registry = $Factory->GetRegistryByExtension($this->Domain->Extension); $Manifest = $Registry->GetManifest(); if ($userid && $this->Domain->UserID != $userid) { throw new UpdateDomainContactAction_Exception(_("You don't have permissions for manage this domain"), UpdateDomainContactAction_Exception::DOMAIN_NOT_BELONGS_TO_USER); } $OldContact = $this->Domain->GetContact($this->contact_type); if ($this->NewContact && $this->NewContact->UserID != $this->Domain->UserID) { throw new UpdateDomainContactAction_Exception(_("You don't have permissions for using this contact"), UpdateDomainContactAction_Exception::CONTACT_NOT_BELONGS_TO_USER); } $trade = $Manifest->GetRegistryOptions()->ability->trade == '1'; if ($this->contact_type != CONTACT_TYPE::REGISTRANT || !$trade) { try { $Registry->UpdateDomainContact($this->Domain, $this->contact_type, $OldContact, $this->NewContact); return $this->Domain->HasPendingOperation(Registry::OP_UPDATE) ? UpdateDomainContactAction_Result::PENDING : UpdateDomainContactAction_Result::OK; } catch (Exception $e) { throw new UpdateDomainContactAction_Exception(sprintf(_("Cannot change contact. Reason: %s"), $e->getMessage())); } } else { // Execute trade when: // - Trade invoice is paid // - Previous trade failed if ($this->Domain->IncompleteOrderOperation == INCOMPLETE_OPERATION::DOMAIN_TRADE || $this->Invoice && $this->Invoice->Status == INVOICE_STATUS::PAID) { $this->Domain->SetContact($this->NewContact, CONTACT_TYPE::REGISTRANT); $this->Domain->IncompleteOrderOperation = null; $extra["requesttype"] = "ownerChange"; try { $trade = $Registry->ChangeDomainOwner($this->Domain, 1, $extra); return $this->Domain->HasPendingOperation(Registry::OP_TRADE) ? UpdateDomainContactAction_Result::PENDING : UpdateDomainContactAction_Result::OK; } catch (Exception $e) { $this->Domain->IncompleteOrderOperation = INCOMPLETE_OPERATION::DOMAIN_TRADE; if ($this->Invoice) { $this->Invoice->ActionStatus = INVOICE_ACTION_STATUS::FAILED; $this->Invoice->ActionFailReason = $e->getMessage(); } throw new UpdateDomainContactAction_Exception(sprintf(_("Cannot change contact. Reason: %s"), $e->getMessage())); } } else { // Issue an invoice for trade operation $invoiceid = $this->Db->GetOne("SELECT * FROM invoices WHERE status=? AND itemid=? AND purpose=?", array(INVOICE_STATUS::PENDING, $this->Domain->ID, INVOICE_PURPOSE::DOMAIN_TRADE)); if (!$invoiceid) { $this->Domain->SetExtraField("NewRegistrantCLID", $this->NewContact->CLID); DBDomain::GetInstance()->Save($this->Domain); $Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_TRADE, $this->Domain->ID, $userid); $Invoice->Description = sprintf(_("%s domain name trade"), $this->Domain->GetHostName()); $Invoice->Save(); $this->Invoice = $Invoice; return UpdateDomainContactAction_Result::INVOICE_GENERATED; } else { throw new UpdateDomainContactAction_Exception(_("Another domain trade is already initiated")); } } } } catch (Exception $e) { throw new UpdateDomainContactAction_Exception($e->getMessage()); } }
/** * Update domain flags (options such as clientUpdateProhibited, clientDeleteProhibited) * * @param Domain $domain * @param IChangelist $changes flags changes * @version v1000 */ public function UpdateDomainFlags(Domain $domain, IChangelist $changes) { $params = array("name" => $this->MakeNameIDNCompatible($domain->GetHostName())); list($added, $removed) = $this->FixTransferLonelyFlag($domain, $changes); if ($added) { $params['add'] = '<domain:add>' . $this->GetFlagsXML($added) . '</domain:add>'; } else { $params['add'] = ''; } if ($removed) { $params['rem'] = '<domain:rem>' . $this->GetFlagsXML($removed) . '</domain:rem>'; } else { $params['rem'] = ''; } $response = $this->Request("domain-update-flags", $params); if ($response->Code == RFC3730_RESULT_CODE::OK_PENDING) { $status = REGISTRY_RESPONSE_STATUS::PENDING; } elseif ($response->Code == RFC3730_RESULT_CODE::OK) { $status = REGISTRY_RESPONSE_STATUS::SUCCESS; } else { $status = REGISTRY_RESPONSE_STATUS::FAILED; } $ret = new UpdateDomainFlagsResponse($status, $response->ErrMsg, $response->Code); $ret->Result = $status != REGISTRY_RESPONSE_STATUS::FAILED; return $ret; }
public function OnDomainCreated(Domain $domain) { if ($domain->IsManagedDNSEnabled) { $userinfo = $this->DB->GetRow("SELECT * FROM users WHERE id=?", array($domain->UserID)); $SOA_owner = str_replace("@", ".", $userinfo["email"]); $this->DB->Execute("INSERT INTO zones (\t`zone`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_owner`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_ttl`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_parent`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_serial`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_refresh`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_retry`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`soa_expire`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`min_ttl`, \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`isupdated`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t )\r\n\t \t\t\t\t\t\t\t\t VALUES (?,?,'14400',?,?,'14400','7200','3600000','86400',0)", array($domain->GetHostName(), $SOA_owner, CONFIG::$NS1, date("Ymd") . "01")); $zoneid = $this->DB->Insert_ID(); $this->DB->Execute("INSERT INTO records (id, zoneid, rtype, ttl, rpriority, rvalue, rkey) \r\n\t\t\t\t\t\t\t SELECT null, '{$zoneid}', rtype, ttl, rpriority, rvalue, rkey FROM records \r\n\t\t\t\t\t\t\t WHERE zoneid='0'\r\n\t\t\t\t\t\t\t "); } }
public function Run($userid) { try { $Factory = RegistryModuleFactory::GetInstance(); $Registry = $Factory->GetRegistryByExtension($this->Domain->Extension); $host_as_attr = (bool) $Registry->GetManifest()->GetRegistryOptions()->ability->hostattr; } catch (Exception $e) { throw new UpdateDomainNameserversAction_Exception(sprintf(_("Cannot change nameservers. Reason: %s"), $e->getMessage())); } // Check that all nameserver hosts are registered foreach ($this->nslist as &$NS) { $glue_record = preg_match("/^(.*)\\.{$this->Domain->GetHostName()}\$/", $NS->HostName, $matches); if ($glue_record) { $known_ns = $this->Db->GetRow("SELECT * FROM nhosts WHERE hostname=? AND domainid=?", array($matches[1], $this->Domain->ID)); if (!$known_ns) { if ($host_as_attr) { // No need to register nameserver hosts $this->Db->Execute("INSERT INTO nhosts SET domainid = ?, hostname = ?, ipaddr = ?", array($this->Domain->ID, $matches[1], $NS->IPAddr)); } else { throw new UpdateDomainNameserversAction_Exception(sprintf(_("Nameserver %s does not exist"), $NS->HostName), UpdateDomainNameserversAction_Exception::NAMESERVERHOST_NOT_REGISTERED); } } else { $NS = new NameserverHost($NS->HostName, $host_as_attr ? $NS->IPAddr : $known_ns['ipaddr']); $NS->ID = $known_ns['id']; } } } // Perform nameservers update try { $Changes = new Changelist($this->Domain->GetNameserverList(), $this->nslist); $Registry->UpdateDomainNameservers($this->Domain, $Changes); $DBNSHost = DBNameserverHost::GetInstance(); $DBNSHost->SaveList($this->Domain->GetNameserverHostList(), $this->Domain->ID); return $this->Domain->HasPendingOperation(Registry::OP_UPDATE) ? UpdateDomainNameserversAction_Result::PENDING : UpdateDomainNameserversAction_Result::OK; } catch (Exception $e) { throw new UpdateDomainNameserversAction_Exception(sprintf(_("Cannot change nameservers. Reason: %s"), $e->getMessage())); } }
public function Delete(Domain $domain) { $this->DB->BeginTrans(); try { $this->DB->Execute('DELETE FROM domains WHERE id = ?', array($domain->ID)); $this->DB->Execute('DELETE FROM domains_data WHERE domainid = ?', array($domain->ID)); $this->DB->Execute('DELETE FROM domains_flags WHERE domainid = ?', array($domain->ID)); $this->DB->Execute("UPDATE zones SET isdeleted = '1' WHERE zone=?", array($domain->GetHostName())); $purposes = implode(',', array($this->DB->qstr(INVOICE_PURPOSE::DOMAIN_CREATE), $this->DB->qstr(INVOICE_PURPOSE::DOMAIN_RENEW), $this->DB->qstr(INVOICE_PURPOSE::DOMAIN_TRANSFER), $this->DB->qstr(INVOICE_PURPOSE::DOMAIN_TRADE))); $this->DB->Execute("UPDATE invoices SET itemid=0, status=IF(status = 0, 2, status) WHERE itemid=? AND purpose IN ({$purposes})", array($domain->ID)); $this->DBNameserverHost->DeleteList($domain->ID); $domain->ID = null; } catch (Exception $e) { $this->DB->RollbackTrans(); Log::Log(sprintf("DBDomain::Delete failed. %s", $e->getMessage()), E_ERROR); throw new ApplicationException($e->getMessage(), $e->getCode()); } $this->DB->CompleteTrans(); // Remove it from loaded objects storage unset($this->LoadedObjects[$domain->ID]); }
public function OnDomainCreated (Domain $Domain) { if ($this->once_run) { return; } $this->once_run = true; //// // 3. CREATE 2 child name servers of newly created domain // try { $ns1 = new NameserverHost('ns1.' . $Domain->GetHostName(), gethostbyname('hostdad.com')); $ns2 = new NameserverHost('ns2.' . $Domain->GetHostName(), gethostbyname('hostdad.com')); $this->Registry->CreateNameserverHost($ns1); $this->Registry->CreateNameserverHost($ns2); $this->TestCase->assertTrue(true, 'Create nameservers'); } catch (Exception $e) { return $this->TestCase->fail('Create nameservers. Error: ' . $e->getMessage()); } //// // 4. UPDATE Domain to attach child name servers to domain // try { $nslist = $Domain->GetNameserverChangelist(); $nslist->Add($ns1); $nslist->Add($ns2); $this->Registry->UpdateDomainNameservers($Domain, $nslist); $this->TestCase->assertTrue( count($Domain->GetNameserverList()) == 4, 'Attach nameservers to domain' ); } catch (Exception $e) { return $this->TestCase->fail('Attach nameservers to domain. Error: ' . $e->getMessage()); } //// // Create tech contact // try { $Tech = $this->Registry->NewContactInstance(CONTACT_TYPE::TECH); $Tech->SetFieldList($this->contact_fields); $this->Registry->CreateContact($Tech); $this->TestCase->assertTrue(true, 'Create another contact'); } catch (Exception $e) { return $this->TestCase->fail('Create another contact. Error: ' . $e->getMessage()); } //// // Update domain contact try { $this->Registry->UpdateDomainContact($Domain, CONTACT_TYPE::TECH, null, $Tech); $this->TestCase->assertTrue(true, 'Attach contact to domain'); } catch (Exception $e) { return $this->TestCase->fail('Attach contact to domain. Error: ' . $e->getMessage()); } //// // 6. Perform an INFO command on the domain to verify update // try { $RDomain = $this->Registry->NewDomainInstance(); $RDomain->Name = $Domain->Name; $RDomain = $this->Registry->GetRemoteDomain($RDomain); $this->TestCase->assertTrue( $RDomain->Name == $Domain->Name && date('Ymd', $RDomain->CreateDate) == date('Ymd', $Domain->CreateDate) && date('Ymd', $RDomain->ExpireDate) == date('Ymd', $Domain->ExpireDate) && count($RDomain->GetNameserverList()) == count($Domain->GetNameserverList()) && $RDomain->GetContact(CONTACT_TYPE::TECH)->CLID == $Tech->CLID, 'Get remote domain' ); } catch (Exception $e) { return $this->TestCase->fail('Get remote domain. Error: ' . $e->getMessage()); } //// // 10. UPDATE one of the name server’s IP Address // try { $ns1->IPAddr = gethostbyname('ns.hostdad.com'); $Resp = $this->Registry->GetModule()->UpdateNameserverHost($ns1); $this->TestCase->assertTrue($Resp->Result, 'Update domain nameserver'); } catch (Exception $e) { return $this->TestCase->fail('Update domain nameserver. Error: ' . $e->getMessage()); } //// // 12. Renew Domain for 2 years // /* try { $this->Registry->RenewDomain($Domain, $extra=array('period' => 2)); $this->TestCase->assertFalse(true, 'Domain renewal. Exception expected'); } catch (Exception $e) { $this->TestCase->assertTrue($e->getMessage() == 'A domain can not be renewed earlier that 365 days from its expiration', 'Domain renewal'); } */ // secondary registry $DataForm = new DataForm(); $DataForm->AppendField( new DataFormField("ServerHost", FORM_FIELD_TYPE::TEXT, null, null, null, null, 'https://devepp.ics.forth.gr:700/epp/proxy')); $DataForm->AppendField( new DataFormField("Login", FORM_FIELD_TYPE::TEXT, null, null, null, null, 'digitalbox1')); $DataForm->AppendField( new DataFormField("Password", FORM_FIELD_TYPE::TEXT , null, null, null, null, 'agrigo')); $DataForm->AppendField( new DataFormField("ClientPrefix", FORM_FIELD_TYPE::TEXT, null, null, null, null, '371')); $DataForm->AppendField( new DataFormField("UseSSLCert", FORM_FIELD_TYPE::CHECKBOX, null, null, null, null, '1')); $DataForm->AppendField( new DataFormField("SSLpwd", FORM_FIELD_TYPE::TEXT, null, null, null, null, 'devepp')); $DataForm->AppendField( new DataFormField("CLID", FORM_FIELD_TYPE::TEXT, null, null, null, null, 'digitalbox1')); $DataForm->AppendField( new DataFormField("SSLCertPath", FORM_FIELD_TYPE::TEXT, null, null, null, null, '/home/marat/webdev/epp-drs/branches/dev/app/modules/registries/EPPGR/ssl/cert.pem')); $Module = new EPPGRRegistryModule(); $Module->InitializeModule('gr', $DataForm); $Registry2 = new Registry($Module); try { $ok = $Registry2->TransferRequest($Domain, array('pw' => $Domain->AuthCode)); $this->TestCase->assertTrue($ok, 'Request domain transfer from another session'); } catch (Exception $e) { $this->TestCase->fail('Request domain transfer from another session. Error: ' . $e->getMessage()); } //// // 17. Approve the Transfer using your OT&E1 account // try { $ok = $this->Registry->TransferApprove($Domain); $this->TestCase->assertTrue($ok, 'Approve transfer'); } catch (Exception $e) { return $this->TestCase->fail('Approve transfer. Error: ' . $e->getMessage()); } //// // 19. Initiate the Transfer again using your OT&E1 account // try { $ok = $this->Registry->TransferRequest($Domain, array('pw' => $Domain->AuthCode)); $this->TestCase->assertTrue($ok, 'Initiate transfer account 1'); } catch (Exception $e) { return $this->TestCase->fail('Initiate tranfer account 1. Error: ' . $e->getMessage()); } //// // 21. Reject the Transfer using your OT&E2 account // try { $ok = $Registry2->TransferReject($Domain); $this->TestCase->assertTrue($ok, 'Reject transfer account 2'); } catch (Exception $e) { return $this->TestCase->fail('Reject transfer account 2. Error: ' . $e->getMessage()); } //// // Remove domain nameservers try { $ns_list = $Domain->GetNameserverList(); $Changes = $Domain->GetNameserverChangelist(); foreach ($ns_list as $NS) { $Changes->Remove($NS); } $Registry2->UpdateDomainNameservers($Domain, $Changes); $this->TestCase->assertTrue(count($Domain->GetNameserverList()) == 0, 'Remove nameservers from domain'); } catch (Exception $e) { return $this->TestCase->fail('Remove nameservers from domain. Error: ' . $e->getMessage()); } //// // Delete nameservers try { $Registry2->DeleteNameserverHost($ns1); $Registry2->DeleteNameserverHost($ns2); $this->TestCase->assertTrue(true, 'Delete nameservers'); } catch (Exception $e) { return $this->TestCase->fail('Delete nameservers. Error: ' . $e->getMessage()); } //// // Delete domain try { $Registry2->DeleteDomain($Domain); $this->TestCase->assertTrue(true, 'Delete domain'); } catch (Exception $e) { return $this->TestCase->fail('Delete domain. Error: ' . $e->getMessage()); } //// /// Delete contact try { $Registry2->DeleteContact($Tech); $Registry2->DeleteContact($Domain->GetContact(CONTACT_TYPE::REGISTRANT)); $this->TestCase->assertTrue(true, 'Delete contact'); } catch (Exception $e) { return $this->TestCase->fail('Delete contact. Error: ' . $e->getMessage()); } }
public function HandleImpendingExpiration(Domain $domain) { // http://bugzilla.webta.net/show_bug.cgi?id=210 // Prevent domain expiration $Config = $this->GetManifest()->GetSectionConfig(); $days = $Config->domain->xpath("//renewal/notifications/period"); $last_notification_period = (int) end($days); $last_renewal_date = $domain->RenewalDate ? $domain->RenewalDate : $domain->ExpireDate; $days_before_expire = (int) ceil(($last_renewal_date - time()) / 86400); if ($days_before_expire <= $last_notification_period) { if ($days_before_expire < 0) { // Today will expire... OMG! $days_before_expire = 0; } // Set renew period $period = (int) $Config->domain->renewal->min_period; $domain->Period = $period; // Copypasta from class.RenewProcess.php // Issue invoice for renew and send notification to client. $Invoice = new Invoice(INVOICE_PURPOSE::DOMAIN_RENEW, $domain, $domain->UserID); $Invoice->Description = sprintf(_("%s domain name renewal for %s years"), $domain->GetHostName(), $period); $Invoice->Save(); if ($Invoice->Status == INVOICE_STATUS::PENDING) { $userinfo = $this->DB->GetRow("SELECT * FROM users WHERE id=?", array($domain->UserID)); $args = array("domain_name" => $domain->Name, "extension" => $domain->Extension, "invoice" => $Invoice, "expDays" => $days_before_expire, "client" => $userinfo, "renewal_date" => $domain->RenewalDate); mailer_send("renew_notice.eml", $args, $userinfo["email"], $userinfo["name"]); Application::FireEvent('DomainAboutToExpire', $domain, $days_before_expire); } } }
/** * This method request registry to renew domain * * @param string $domain Domain * @param array $extradata Extra fields * @return RenewDomainResponse */ public function RenewDomain(Domain $domain, $extra = array()) { $params = array('name' => $domain->GetHostName()); $response = $this->Request("domain-undelete", $params); $status = $response->Succeed ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; $ret = new RenewDomainResponse($status, $response->ErrMsg, $response->Code); if ($ret->Succeed()) { $ret->ExpireDate = $domain->ExpireDate + $domain->Period * 86400 * 365; } return $ret; }
public function UpdateDomainContact(Domain $domain, $contactType, Contact $oldContact, Contact $newContact) { if (!$newContact && !$oldContact) throw new Exception("At leat one contact (\$newContact or \$oldContact) must be passed into UpdateDomainContact"); if ($contactType == CONTACT_TYPE::TECH && preg_match('/^\d+/', $domain->GetContact(CONTACT_TYPE::REGISTRANT)->CLID)) { throw new Exception("Domain transfer from SWITCH was buggy. You must update registrant contact first"); } $params = array( "name" => $this->MakeNameIDNCompatible($domain->GetHostName()), "change" => "", "add" => "", "rem" => "" ); if ($contactType == CONTACT_TYPE::REGISTRANT) $params["change"] = "<domain:chg><domain:registrant>{$newContact->CLID}</domain:registrant></domain:chg>"; else { if ($newContact) $params['add'] = '<domain:add><domain:contact type="'.$contactType.'">'.$newContact->CLID.'</domain:contact></domain:add>'; if ($oldContact && !preg_match('/^\d+/', $oldContact->CLID)) $params['rem'] = '<domain:rem><domain:contact type="'.$contactType.'">'.$oldContact->CLID.'</domain:contact></domain:rem>'; } $response = $this->Request("domain-update-contact", $params); $status = ($response->Succeed) ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; // Hack for bad transferred from SWITCH if ($response->Succeed && preg_match('/^\d+/', $oldContact->CLID) && $contactType == CONTACT_TYPE::REGISTRANT) { $domain->SetContact(null, CONTACT_TYPE::TECH); } return new UpdateDomainContactResponse($status, $response->ErrMsg, $response->Code); }
public function OnDomainTransferFailed(Domain $domain) { var_dump('transfer failed: ' . $domain->GetHostName()); }
public function RenewDomain(Domain $domain, $extra=array()) { $params = array( "name" => $this->MakeNameIDNCompatible($domain->GetHostName()), "exDate" => date("Y-m-d", $domain->ExpireDate), "period" => $extra["period"] ); $this->BeforeRequest('domain-renew', $params, __METHOD__, $domain, $extra); $response = $this->Request("domain-renew", $params); $status = ($response->Succeed) ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; $resp = new RenewDomainResponse($status, $response->ErrMsg, $response->Code); if ($response->Succeed) { $Grd = $this->GetRemoteDomain($domain); $resp->ExpireDate = $Grd->ExpireDate; } return $resp; }
public function OnDomainDeleted(Domain $domain) { $id = $this->Db->GetOne("\r\n\t\t\t\tSELECT domain_key FROM whois_domain \r\n\t\t\t\tWHERE domain = ?", array($domain->GetHostName())); if ($id) { $this->Db->Execute("\r\n\t\t\t\t\tDELETE FROM whois_nameserver WHERE domain_fkey = ?", array($id)); $this->Db->Execute("\r\n\t\t\t\t\tDELETE FROM whois_domain \r\n\t\t\t\t\tWHERE domain = ?", array($domain->GetHostName())); } }
public function PollTransfer(Domain $domain) { $params = array('name' => $this->MakeNameIDNCompatible($domain->GetHostName()), 'pw' => $this->EscapeXML($domain->AuthCode)); $Resp = $this->Request('domain-info', $params); if ($Resp->Succeed) { $infData = $Resp->Data->response->resData->children("urn:ietf:params:xml:ns:domain-1.0"); $infData = $infData[0]; // transfer complete when trDate node exists. $ok = $infData->trDate->getName() != ''; $trStatus = $ok ? TRANSFER_STATUS::APPROVED : TRANSFER_STATUS::PENDING; $respStatus = $trStatus != TRANSFER_STATUS::PENDING ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::PENDING; $Ret = new PollTransferResponse($respStatus, $Resp->ErrMsg, $Resp->Code); $Ret->HostName = $domain->GetHostName(); $Ret->TransferStatus = $trStatus; return $Ret; } else { return new PollTransferResponse(REGISTRY_RESPONSE_STATUS::FAILED, $Resp->ErrMsg, $Resp->Code); } }
/** * This method request registry to transfer domain * In order to pending operation, response must have status REGISTRY_RESPONSE_STATUS::PENDING * * @param string $domain Domain * @param array $extradata Extra fields * @return TransferRequestResponse */ public function TransferRequest(Domain $domain, $extra = array()) { $params = array('name' => $domain->GetHostName(), 'pw' => $this->EscapeXML($extra["pw"]), 'type' => $this->GetDomainType()); $response = $this->Request('domain-trans-request', $params); $status = $response->Succeed ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; $ret = new TransferRequestResponse($status, $response->ErrMsg, $response->Code); $ret->Result = $response->Succeed; return $ret; }
/** * Called by system when domain transfer operation is pending. * Must return valid PollDomainTransfered on operatation is completed, * or response with Status = REGISTRY_RESPONSE_STATUS::PENDING if operation is still in progress * * @param Domain $domain * @return PollTransferResponse */ public function PollTransfer(Domain $domain) { $params = array('SLD' => $this->MakeNameIDNCompatible($domain->Name), 'TLD' => $this->Extension, 'TransferOrderID' => $domain->TransferID); $Resp = $this->Request('TP_GetOrder', $params); if ($Resp->Succeed) { $statusid = (int) $Resp->Data->transferorder->statusid; if ($statusid == self::TRANSFERSTATUS_COMPLETE) { $tstatus = TRANSFER_STATUS::APPROVED; } else { if ($statusid == self::TRANSFERSTATUS_CANCELLED) { $tstatus = TRANSFER_STATUS::DECLINED; } else { $tstatus = TRANSFER_STATUS::PENDING; } } $Ret = new PollTransferResponse($tstatus != TRANSFER_STATUS::PENDING ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::PENDING, $Resp->ErrMsg, $Resp->Code); $Ret->HostName = $domain->GetHostName(); $Ret->TransferStatus = $tstatus; return $Ret; } else { return new PollTransferResponse(REGISTRY_RESPONSE_STATUS::FAILED, $Resp->ErrMsg, $Resp->Code); } }
function OnDomainTransferRequested(Domain $domain) { $ops = $this->RegistryAccessible->GetPendingOperationList(Registry::OBJ_DOMAIN, $domain->ID); foreach ($ops as $op) { if ($op->Type == Registry::OP_TRANSFER) { $resp = new PollTransferResponse(); $resp->HostName = $domain->GetHostName(); $resp->TransferStatus = TRANSFER_STATUS::APPROVED; $this->RegistryAccessible->DispatchPollTransfer($resp); $this->RegistryAccessible->RemovePendingOperation($op->ID); break; } } }
public function TransferRequest(Domain $domain, $extra = array()) { $params = array('name' => $this->MakeNameIDNCompatible($domain->GetHostName()), 'c_registrant' => $extra['registrant'] ? $extra['registrant'] : "#AUTO#", 'c_onsite' => $extra['tech'], 'c_billing' => $this->Config->GetFieldByName('BillingContactCLID')->Value, 'ns' => '<' . $this->ExtPrefix . ':ns>' . $this->GetNSXML(array($extra["ns1"], $extra["ns2"])) . '</' . $this->ExtPrefix . ':ns>', 'pw' => $this->EscapeXML(trim($extra["pw"]))); if ($extra["type"] == self::$TransferTrade && $params['c_registrant'] == "#AUTO#") { throw new Exception(sprintf(_("%s contact required"), "Registrant")); } $res = $this->Request("domain-trans-request", $params); $status = $res->Succeed ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; return new TransferRequestResponse($status, $res->ErrMsg, $res->Code); }
/** * @param Domain $domain * @return PollTransferResponse */ public function PollTransfer(Domain $domain) { $params = array('name' => $domain->GetHostName(), 'pw' => $this->EscapeXML($domain->AuthCode)); $Resp = $this->Request('domain-trans-query', $params); if ($Resp->Succeed) { $trnInfo = $Resp->Data->response->resData->children('urn:ietf:params:xml:ns:domain-1.0'); $eppTrStatus = (string) $trnInfo[0]->trStatus; if ($eppTrStatus == 'clientApproved' || $eppTrStatus == 'serverApproved') { $trStatus = TRANSFER_STATUS::APPROVED; } else { if ($eppTrStatus == 'clientCancelled' || $eppTrStatus == 'clientRejected' || $eppTrStatus == 'serverCancelled') { $trStatus = TRANSFER_STATUS::DECLINED; } else { if ($eppTrStatus == 'pending') { $trStatus = TRANSFER_STATUS::PENDING; } else { throw new Exception(sprintf(_("Undefined transfer status: %s"), $trStatus)); } } } $respStatus = $trStatus != TRANSFER_STATUS::PENDING ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::PENDING; $Ret = new PollTransferResponse($respStatus, $Resp->ErrMsg, $Resp->Code); $Ret->HostName = $domain->GetHostName(); $Ret->TransferStatus = $trStatus; if ($trStatus == TRANSFER_STATUS::DECLINED) { $Ret->FailReason = _("Transfer was rejected by the current domain owner."); } return $Ret; } else { return new PollTransferResponse(REGISTRY_RESPONSE_STATUS::FAILED, $Resp->ErrMsg, $Resp->Code); } }
private function MarkAsExpired (Domain $Domain) { $db = Core::GetDBInstance(); //Set to domain 'Expired' Log::Log(sprintf("Mark domain '%s' as expired", $Domain->GetHostName()), E_USER_NOTICE); $db->Execute("UPDATE domains SET status = ? WHERE id = ?", array(DOMAIN_STATUS::EXPIRED, $Domain->ID)); // Mark invoice as 'Failed' $db->Execute("UPDATE invoices SET status = ? WHERE itemid = ? AND status = ? AND purpose = ?", array(INVOICE_STATUS::FAILED, $Domain->ID, INVOICE_STATUS::PENDING, INVOICE_PURPOSE::DOMAIN_RENEW)); $userinfo = $db->GetRow("SELECT * FROM users WHERE id = ?", array($Domain->UserID)); // Send domain expired notice $args = array ( "login" => $userinfo["login"], "domain_name" => $Domain->Name, "extension" => $Domain->Extension, "client" => $userinfo ); mailer_send("expired_notice.eml", $args, $userinfo["email"], $userinfo["name"]); }
/** * @param Domain $domain * @return PollTransferResponse */ public function PollTransfer(Domain $domain) { $params["domain"] = $this->MakeNameIDNCompatible($domain->GetHostName()); $response = $this->Request("StatusDomainTransfer", $params); if ($response->Succeed) { mparse_str(str_replace("\n", "&", $response->Data), $resp); $tstatus = trim($resp["property"]["transfer status"][0]); if (!$tstatus) { if (stripos($response->Data, "[SUCCESSFUL]") !== false) { $tstatus = TRANSFER_STATUS::APPROVED; } elseif (stripos($response->Data, "[FAILED]") !== false) { $tstatus = TRANSFER_STATUS::DECLINED; } else { $tstatus = TRANSFER_STATUS::PENDING; } } else { if ($tstatus == "SUCCESSFUL") { $tstatus = TRANSFER_STATUS::APPROVED; } elseif ($tstatus == "FAILED") { $tstatus = TRANSFER_STATUS::DECLINED; } else { $tstatus = TRANSFER_STATUS::PENDING; } } $resp = new PollTransferResponse($status, $response->ErrMsg, $response->Code); $resp->HostName = $domain->GetHostName(); $resp->TransferStatus = $tstatus; return $resp; } else { throw new Exception(sprintf(_("StatusDomainTransfer failed: %s"), $response->ErrMsg)); } }
/** * Send domain transfer rejection * * @param string $domain Domain required data: name, pw * @param array $extradata Extra fields * @return bool True on success of false on failure */ public function TransferReject(Domain $domain, $extra=array()) { $params = array( 'name' => $this->MakeNameIDNCompatible($domain->GetHostName()), "pw" => $this->EscapeXML($domain->AuthCode) ); $this->BeforeRequest('domain-trans-reject', $params, __METHOD__, $domain, $extra); $response = $this->Request("domain-trans-reject", $params); $status = ($response->Succeed) ? REGISTRY_RESPONSE_STATUS::SUCCESS : REGISTRY_RESPONSE_STATUS::FAILED; return new TransferRejectResponse($status, $response->ErrMsg, $response->Code); }
/** * Called by system when domain transfer operation is pending. * Must return valid PollDomainTransfered on operatation is finished, * or response with status = REGISTRY_RESPONSE_STATUS::PENDING if operation is still in progress * * @param Domain $domain * @return PollTransferResponse */ public function PollTransfer(Domain $domain) { $transferStatus = null; $respStatus = REGISTRY_RESPONSE_STATUS::SUCCESS; //// // Check owner has approved transfer $params = array('TRANSFERID' => $domain->TransferID); $Resp = $this->Request('QUERY TRANSFERID', $params); if (!$Resp->Succeed) { return new PollTransferResponse(REGISTRY_RESPONSE_STATUS::FAILED, $Resp->ErrMsg); } if ($Resp->Data['TRANSFER STATUS'] == 'REGISTRAR_TRANSFER_SUBMITTED') { $transferStatus = REGISTRY_RESPONSE_STATUS::SUCCESS; } else { //// // Check owner has rejected transfer $params = array('TRANSFERID' => $domain->TransferID); $Resp = $this->Request('QUERY REJECTED TRANSFER', $params); if ($Resp->Succeed) { $transferStatus = TRANSFER_STATUS::DECLINED; } else { //// // Search in pending transfered domains. $params = array('TRANSFER TYPE' => 'INBOUND'); $Resp = $this->Request('VIEW PENDING TRANSFER', $params); if (!$Resp->Succeed) { return new PollTransferResponse(REGISTRY_RESPONSE_STATUS::FAILED, $Resp->ErrMsg); } $i = 1; $in_pending = false; while (array_key_exists("DOMAIN {$i}", $Resp->Data)) { $hostname = sprintf('%s.%s', $Resp->Data["DOMAIN {$i}"], $Resp->Data["TLD {$i}"]); if ($hostname == $domain->GetHostName()) { $in_pending = true; $respStatus = REGISTRY_RESPONSE_STATUS::PENDING; $transferStatus = TRANSFER_STATUS::PENDING; break; } $i++; } if (!$in_pending) { $transferStatus = TRANSFER_STATUS::FAILED; } } } $Ret = new PollTransferResponse($respStatus); $Ret->HostName = $hostname; $Ret->TransferStatus = $transferStatus; return $Ret; }
public function RenewDomain (Domain $domain, $extra=array()) { $params = array( "name" => $this->MakeNameIDNCompatible($domain->GetHostName()) ); $Response = $this->Request("domain-restore", $params); $Ret = new RenewDomainResponse($this->GetResponseStatusFromEPPResponse($Response), $Response->ErrMsg, $Response->Code); if ($Response->Succeed) { $Ret->ExpireDate = $domain->ExpireDate + ($domain->Period*86400*365); } return $Ret; }
public function OnDomainTransferRequested(Domain $domain) { $this->AddHistoryEntry(HISTORY_OBJECT_TYPE::DOMAIN, HISTORY_OP::TRANSFER_REQUEST, $domain->GetHostName(), HISTORY_OP_STATE::COMPLETED); }