コード例 #1
0
ファイル: class.Registry.php プロジェクト: rchicoria/epp-drs
 function DispatchPollTransfer(PollTransferResponse $resp)
 {
     if ($resp->IsFailed()) {
         Log::Log(sprintf('DispatchPollTransfer failed. Registry response: %s', $resp->ErrMsg), E_USER_ERROR);
         throw new Exception($resp->ErrMsg, $resp->Code);
     }
     list($name, $extension) = FQDN::Parse($resp->HostName);
     $domain = $this->DBDomain->LoadByName($name, $extension, $this->GetManifest());
     if ($resp->TransferStatus == TRANSFER_STATUS::APPROVED) {
         $domain = $this->GetRemoteDomain($domain);
         $domain->Status = DOMAIN_STATUS::DELEGATED;
         // Update domain contacts
         $contact_types = array(CONTACT_TYPE::REGISTRANT, CONTACT_TYPE::ADMIN, CONTACT_TYPE::BILLING, CONTACT_TYPE::TECH);
         $SavedDomain = $this->DBDomain->GetInitialState($domain);
         // XXX Hack for RRPProxy.
         //
         // 1) RRPProxy domain comes after transfer without contacts.
         // All 4 contacts must be assigned to domain in a atomic operation
         // EPP-DRS module API doesn't support this
         //
         // 2) RRPPRoxy domains (.BE, .EU) comes with unoperation contacts (be.tr5544 like)
         // that couldn't be updated in a normal order. To set them, first TradeDomain must be initiated.
         // After that admin, tech, billing contacts could be updated with ModifyDomain command.
         if ($this->GetModuleName() == "RRPProxy") {
             $this->RegModule->UpdateContactsAfterTransfer($domain, $SavedDomain);
         } else {
             // Default behaviour
             Log::Log("Set contacts after transfer (Default behaviour)", E_USER_NOTICE);
             foreach ($contact_types as $type) {
                 $SavedContact = $SavedDomain->GetContact($type);
                 $Contact = $domain->GetContact($type);
                 Log::Log("{$type} '{$SavedContact->CLID}' is saved, '{$Contact->CLID}' is comming", E_USER_NOTICE);
                 if ($SavedContact && !$Contact || !$SavedContact && $Contact || $Contact->CLID != $SavedContact->CLID) {
                     // XXX Hack for EPPGR
                     if ($Contact->CLID && $SavedDomain->{'x-gr-trn-' . $type} == $Contact->CLID) {
                         // GR. registrant contact arrived
                         continue;
                     }
                     try {
                         Log::Log("Change {$type} contact from {$Contact->CLID} to {$SavedContact->CLID}", E_USER_NOTICE);
                         $Resp = $this->RegModule->UpdateDomainContact($domain, $type, $Contact, $SavedContact);
                         $this->ValidateModuleResponse($Resp, 'UpdateDomainContactResponse');
                         if ($Resp->Result) {
                             $domain->SetContact($SavedContact, $type);
                         } else {
                             throw new Exception("Module return fault. " . $Resp->ErrMsg);
                         }
                     } catch (Exception $e) {
                         Log::Log(sprintf("Failed to update '%s' contact for transferred domain '%s'. Reason: %s", $type, $domain->GetHostName(), $e->getMessage()), E_USER_ERROR);
                     }
                 }
             }
         }
         $this->FireEvent('DomainOperation', $domain, self::OP_TRANSFER);
         $this->FireEvent('DomainTransferApproved', $domain);
         $this->HandleImpendingExpiration($domain);
         $this->DBDomain->Save($domain);
         return true;
     } else {
         if ($resp->TransferStatus == TRANSFER_STATUS::DECLINED) {
             $domain->Status = DOMAIN_STATUS::TRANSFER_FAILED;
             $this->FireEvent('DomainOperation', $domain, self::OP_TRANSFER, true, $resp->FailReason);
             $this->FireEvent('DomainTransferDeclined', $domain);
             $this->DBDomain->Save($domain);
             return true;
         } else {
             if ($resp->TransferStatus == TRANSFER_STATUS::PENDING || $resp->Pending()) {
                 if ($domain->TransferDate !== null) {
                     // If transfer request was sent
                     $config = $this->GetManifest()->GetSectionConfig();
                     $timeout = (int) $config->domain->transfer->timeout;
                     if ($timeout) {
                         // Check for transfer timeout. If time exceed - transfer failed
                         if (strtotime("+{$timeout} day", $domain->TransferDate) <= time()) {
                             $timeExpired = true;
                             $resp->FailReason = _('We gave up while waiting for transfer authorization from domain owner');
                         }
                     }
                 }
             }
         }
     }
     if ($resp->TransferStatus == TRANSFER_STATUS::FAILED || $timeExpired) {
         $domain->Status = DOMAIN_STATUS::TRANSFER_FAILED;
         $this->FireEvent('DomainOperation', $domain, self::OP_TRANSFER, true, $resp->FailReason);
         $this->FireEvent('DomainTransferFailed', $domain);
         $this->DBDomain->Save($domain);
         return true;
     }
 }