Ejemplo n.º 1
0
 function DispatchPollUpdateDomain(PollUpdateDomainResponse $resp)
 {
     if ($resp->IsFailed()) {
         Log::Log(sprintf('DispatchPollUpdateDomain failed. Registry response: %s', $resp->ErrMsg), E_USER_ERROR);
         throw new Exception($resp->ErrMsg, $resp->Code);
     }
     if ($resp->Succeed()) {
         list($name, $extension) = FQDN::Parse($resp->HostName);
         $domain = $this->DBDomain->LoadByName($name, $extension, $this->GetManifest());
         if ($resp->Result) {
             $domain = $this->GetRemoteDomain($domain);
             $this->FireEvent('DomainOperation', $domain, self::OP_UPDATE);
             $this->FireEvent('DomainUpdated', $domain);
             $this->DBDomain->Save($domain);
         } else {
             $this->FireEvent('DomainOperation', $domain, self::OP_UPDATE, true, $resp->FailReason);
         }
         return true;
     }
 }
Ejemplo n.º 2
0
        function _testEPP ()
        {
			$Domain = $this->Registry->NewDomainInstance();
			$Domain->Name = 'webta' . rand(1000, 9999);
			
			// check domain
			try
			{
				$ok = $this->Registry->DomainCanBeRegistered($Domain);
				$this->assertTrue($ok, 'Domain available for registration');
			}
			catch (Exception $e)
			{
				return $this->fail('Domain available for registration. Error: ' . $e->getMessage());
			}
			
			////
			// Create contact

			try
			{
				$Registrant = $this->Registry->NewContactInstanceByGroup('generic');
				$Registrant->SetFieldList($this->contact_fields);
				
				$this->Registry->CreateContact($Registrant);
				
				$this->assertTrue(true, 'Create contact');
			}
			catch (Exception $e)
			{
				return $this->fail('Create contact. Error: ' . $e->getMessage());
			}
			
			////
			// Get contact INFO
			
			try
			{
				$RRegistrant = $this->Registry->NewContactInstanceByGroup('generic');
				$RRegistrant->CLID = $Registrant->CLID;
				
				$this->Registry->GetRemoteContact($RRegistrant);
				
				$fields = $Registrant->GetFieldList();
				$rfields = $RRegistrant->GetFieldList();
				ksort($fields);
				ksort($rfields);
				
				$discloses = $Registrant->GetDiscloseList();
				$rdiscloses = $RRegistrant->GetDiscloseList();
				ksort($discloses);
				ksort($rdiscloses);
				
				$this->assertTrue(
					$fields['name'] == $rfields['name'] &&
					$fields['email'] == $rfields['email'] &&
					$fields['voice'] == $rfields['voice'] &&
					$discloses == $rdiscloses, 'Get remote contact');
				
			}
			catch (Exception $e)
			{
				return $this->fail('Get remote contact. Error: ' . $e->getMessage());
			}
			
			try
			{
				$Domain->SetContact($Registrant, CONTACT_TYPE::REGISTRANT);
				$Domain->SetNameserverList(array(
					new Nameserver('ns.hostdad.com'),
					new Nameserver('ns2.hostdad.com')
				));
				
				$this->DBDomain->Save($Domain);
				
				$this->Registry->CreateDomain($Domain, 2, array('comment' => 'abc'));
				$this->assertTrue(true, 'Create domain');
			}
			catch (Exception $e)
			{
				return $this->fail('Create domain. Error: ' . $e->getMessage());
			}
			
			
        	$Obs = new TestRegistryObserver($this->Registry, $this);
        	$this->Registry->AttachObserver($Obs);
			$this->Registry->DispatchPendingOperations();
        }
Ejemplo n.º 3
0
 public function ConvertActiveDomains()
 {
     $this->Log('Import delegated domains');
     $this->FailedActiveDomains = array();
     // Import delegated domains
     $domains = $this->DbOld->GetAll("\r\n\t\t\t\tSELECT * FROM domains \r\n\t\t\t\tWHERE status='Delegated' \r\n\t\t\t\tORDER BY id ASC\r\n\t\t\t");
     $ok = $fail = 0;
     foreach ($domains as $i => $dmn) {
         // This is long time loop, DbOld connection may be lost due timeout,
         // so we need to ping it
         $this->PingDatabase($this->DbOld);
         // Check for duplicate domains
         $imported = (int) $this->DbNew->GetOne('SELECT COUNT(*) FROM domains WHERE name = ? AND TLD = ?', array($dmn['name'], $dmn['TLD']));
         if ($imported) {
             // Skip duplicate domain
             continue;
         }
         try {
             $Registry = $this->RegistryFactory->GetRegistryByExtension($dmn['TLD'], $db_check = false);
             $Domain = $Registry->NewDomainInstance();
             $Domain->Name = $dmn['name'];
             $this->Log("Import {$Domain->GetHostName()}");
             if (!DBDomain::ActiveDomainExists($Domain)) {
                 try {
                     $Domain = $Registry->GetRemoteDomain($Domain);
                 } catch (Exception $e) {
                     $err[] = sprintf("%s: %s", $Domain->GetHostName(), $e->getMessage());
                 }
                 if ($Domain->RemoteCLID) {
                     if ($Domain->RemoteCLID == $Registry->GetRegistrarID() || $Domain->AuthCode != '') {
                         $contacts_list = $Domain->GetContactList();
                         // Apply contacts to domain owner
                         foreach ($contacts_list as $Contact) {
                             $Contact->UserID = $dmn['userid'];
                         }
                         if (count($err) == 0) {
                             $period = date("Y", $Domain->ExpireDate) - date("Y", $Domain->CreateDate);
                             $Domain->Status = DOMAIN_STATUS::DELEGATED;
                             $Domain->Period = $period;
                             $Domain->UserID = $dmn['userid'];
                             $Domain->ID = $dmn['id'];
                             try {
                                 $this->DbNew->Execute('INSERT INTO domains SET id = ?', array($dmn['id']));
                                 $this->DBDomain->Save($Domain);
                                 $ok++;
                             } catch (Exception $e) {
                                 $err[] = sprintf("%s: %s", $Domain->GetHostName(), $e->getMessage());
                             }
                         }
                     } else {
                         $err[] = sprintf(_("'%s' cannot be imported because it does not belong to the current registar."), $Domain->GetHostName());
                     }
                 }
             } else {
                 $err[] = sprintf(_("Domain '%s' already exists in our database."), $Domain->GetHostName());
             }
             foreach ($err as $errmsg) {
                 $this->Log($errmsg, E_USER_ERROR);
                 $err = array();
                 $fail++;
             }
         } catch (Exception $e) {
             $this->Log($e->getMessage(), E_USER_ERROR);
             $fail++;
             if ($this->SaveFailedAsPending) {
                 $this->FailedActiveDomains[] = $dmn;
             }
         }
     }
     $this->Log(sprintf("Imported: %s; Failed: %s", $ok, $fail));
 }